SendMessage(txtBook.Handle, WM_VSCROLL, SB_PAGEUP, 0);
}
private void butPageDown_Click(object sender, EventArgs e) {
// на одну страницу вниз
SendMessageCtxtBook.Handle, WM_VSCROLL, SB_PAGEDOWN, 0);
}
Внешний вид приложения показан на рис. 4.1.
Рис. 4.1. Программная прокрутка текста
Многострочный текст в кнопке
По умолчанию текст для кнопок может содержать только одну строку. Но при желании можно изменить этот стиль с помощью функций GetWindowLong и SetWindowLong, как показано в листинге 4.3.
[DllImport("coredll.dll")]
private static extern IntPtr GetCapture();
[DllImport("coredll.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("coredll.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex,
int dwNewLong);
public const int GWLSTYLE = -16;
// стиль многострочного текста
public const int BS_MULTILINE = 0x2000;
private void Form1_Load(object sender, EventArgs e) {
IntPtr hWnd;
int style;
this.butMultiline.Capture = true;
hWnd = GetCapture();
this.butMultiline.Capture = false;
style = GetWindowLong(hWnd, GWL_STYLE);
SetWindowLong(hWnd, GWL_STYLE, style | BS_MULTILINE);
}