[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);
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 (http://forum.valhallalegends.com/phpbbs/index.php?topic=9338.0) 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.
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);