Valhalla Legends Forums Archive | .NET Platform | [C#]SendMessage() problem?

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

i imported the function.  then i do this:

[code]
SendMessage(rtbMain.Handle, 0x115, 0x4, rtbMain.Text.Length);
[/code]


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


edit:

sorry, MyndFyre already answered this:

[code][DllImport("user32.dll")]
private static extern int SetScrollInfo(
IntPtr hwnd,
ScrollBarTypes fnBar,
ref SCROLLINFO lpsi,
bool fRedraw);
[/code]
December 8, 2004, 1:02 AM
Myndfyr
[quote author=mentalCo. link=topic=9819.msg91442#msg91442 date=1102467751]
[code]
[DllImport("User32.dll")]
public static extern int SendMessage( System.IntPtr hwnd, Int32 uMsg, Int64 wParam, Int32 lParam);
[/code]

i imported the function.  then i do this:

[code]
SendMessage(rtbMain.Handle, 0x115, 0x4, rtbMain.Text.Length);
[/code]
[/quote]

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:

[code]
/// <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
);
[/code]

I'll have to look around for my constants later, but if you notice when I call it I had:
[code]
(uint)EditBoxMessages.EM_Scroll,
ScrollBarCommands.SB_Top,
[/code]
Those were enumerations with values taken from (IIRC) windows.h.
December 8, 2004, 2:34 AM
mentalCo.
ya I ended up using

[code]
public static extern int SendMessage(
IntPtr hWnd,
uint Msg,
uint wParam,
uint lParam
);
[/code]

then the scroll message
[code]
SendMessage(
rtbMain.Handle,
(uint)0x115,
1,
0);
[/code]
December 8, 2004, 5:00 AM

Search