LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static RECT rect;
static int cxChar, cyChar, cyClient, cxClient;
HDC hdc;
PAINTSTRUCT ps;
int i;
LPDRAWITEMSTRUCT pdis;
TCHAR szBuffer[16];
static HWND ScrollBar;
static int pos;
switch (message)
{
case WM_CREATE:
cxChar = LOWORD(GetDialogBaseUnits());
cyChar = HIWORD(GetDialogBaseUnits());
ScrollBar = CreateWindow(
TEXT("scrollbar"),
NULL,
WS_CHILD | WS_VISIBLE | SBS_VERT | WS_TABSTOP,
0, 0, 0, 0,
hwnd,
(HMENU)1,
hin,
NULL
);
SetScrollRange(ScrollBar, SB_CTL, 0, 100, FALSE);
SetScrollPos(ScrollBar, SB_CTL, 0, FALSE);
ScrollPR = GetWindowLongPtr(ScrollBar, GWLP_WNDPROC);
SetWindowLongPtr(ScrollBar, GWLP_WNDPROC, (LONG)ScrollProc);
return 0;
return 0;
case WM_SIZE:
rect.left = 24 * cxChar;
rect.top = 2 * cyChar;
rect.right = LOWORD(lParam);
rect.bottom = HIWORD(lParam);
MoveWindow(ScrollBar, 10, 10, 20, 200, FALSE);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
LRESULT CALLBACK ScrollProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
MessageBeep(0);
TCHAR szBuffer[16];
wsprintf(szBuffer, TEXT("%d"), GetLastError());
MessageBox(hwnd, szBuffer, NULL, MB_OK);
switch (message)
{
case WM_KEYDOWN:
MessageBeep(0);
break;
default:
break;
}
return CallWindowProc(ScrollPR, hwnd, message, wParam, lParam);
}