This commit is contained in:
2011-02-18 18:59:46 +00:00
parent 729c39a503
commit 7704e926df
6 changed files with 493 additions and 95 deletions

View File

@@ -19,6 +19,8 @@ namespace Volian.Controls.Library
public static extern int SendMessage(HandleRef hWndlock, Messages wMsg, RTBSelection wParam, ref CharFormat2 cf2);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int SendMessage(HandleRef hWndlock, Messages wMsg, int wParam, ref ParaFormat2 pf2);
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong (IntPtr hWin, int index);
#region RTB Messages
// EM_AUTOURLDETECT - An EM_AUTOURLDETECT message enables or disables automatic detection of URLs by a rich edit control.
// EM_CANPASTE - The EM_CANPASTE message determines whether a rich edit control can paste a specified clipboard format.
@@ -114,6 +116,10 @@ namespace Volian.Controls.Library
const int WM_USER = 0x0400;
const int GWL_STYLE = -16;
const int WS_HSCROLL = 0x100000;
const int WS_VSCROLL = 0x200000;
#endregion
#region Enums
public enum Messages : int
@@ -762,6 +768,16 @@ namespace Volian.Controls.Library
}
#endregion
#region Static Methods
public static bool HasVertScroll(Control ctl)
{
int dwstyle = GetWindowLong(ctl.Handle, GWL_STYLE);
return (dwstyle & WS_VSCROLL) != 0;
}
public static bool HasHorzScroll(Control ctl)
{
int dwstyle = GetWindowLong(ctl.Handle, GWL_STYLE);
return (dwstyle & WS_HSCROLL) != 0;
}
public static void SetScrollLocation(RichTextBox richTextBox, Point point)
{
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETSCROLLPOS, 0, ref point) == 0)