• Welcome to Valhalla Legends Archive.
 

[C#]SendMessage() problem?

Started by mentalCo., December 07, 2004, 07:02 PM

Previous topic - Next topic

mentalCo.

   
[DllImport("User32.dll")]
public static extern int SendMessage( System.IntPtr hwnd, Int32 uMsg, Int64 wParam, Int32 lParam);


i imported the function.  then i do this:


SendMessage(rtbMain.Handle, 0x115, 0x4, rtbMain.Text.Length);



im just tryin to scroll my rich text in c#.  what am i doing wrong?


edit:

sorry, MyndFyre already answered this:

[DllImport("user32.dll")]
private static extern int SetScrollInfo(
IntPtr hwnd,
ScrollBarTypes fnBar,
ref SCROLLINFO lpsi,
bool fRedraw);

MyndFyre

Quote from: mentalCo. on December 07, 2004, 07:02 PM
   
[DllImport("User32.dll")]
public static extern int SendMessage( System.IntPtr hwnd, Int32 uMsg, Int64 wParam, Int32 lParam);


i imported the function.  then i do this:


SendMessage(rtbMain.Handle, 0x115, 0x4, rtbMain.Text.Length);


Good call using my SetScrollInfo import -- does it work for you?

I noticed that in this post where you apparently got the code from, I discovered that SetScrollInfo wasn't working the way I wanted.  If you want to go up by different increments, you can still use SendMessage, but you were using a bad calling convention.  Use this import:


/// <summary>
/// <para>The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message. </para>
/// <para>To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.</para>
/// </summary>
/// <param name="hWnd">[in] Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</param>
/// <param name="Msg">[in] Specifies the message to be sent.</param>
/// <param name="wParam">[in] Specifies additional message-specific information.</param>
/// <param name="lParam">[in] Specifies additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd,
uint Msg,
uint wParam,
uint lParam
);


I'll have to look around for my constants later, but if you notice when I call it I had:

(uint)EditBoxMessages.EM_Scroll,
ScrollBarCommands.SB_Top,

Those were enumerations with values taken from (IIRC) windows.h.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

mentalCo.

ya I ended up using


public static extern int SendMessage(
IntPtr hWnd,
uint Msg,
uint wParam,
uint lParam
);


then the scroll message

SendMessage(
rtbMain.Handle,
(uint)0x115,
1,
0);