static LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WINDOWPOS *wp = (WINDOWPOS *) lParam; switch (uMsg) { case WM_COMMAND: if (((HWND) lParam) == nhspinb || ((HWND) lParam) == nvspinb) if (HIWORD(wParam) == EN_CHANGE) areaUpdateScroll(area); break; case WM_WINDOWPOSCHANGED: if ((wp->flags & SWP_NOSIZE) != 0) break; repos(hwnd); return 0; case WM_CLOSE: PostQuitMessage(0); } return DefWindowProcW(hwnd, uMsg, wParam, lParam); }
void areaScrollOnResize(uiArea *a, RECT *client) { areaUpdateScroll(a); }
int main(void) { WNDCLASSW wc; HWND mainwin; MSG msg; CoInitialize(NULL); initDraw(); hInstance = GetModuleHandle(NULL); h.ah.Draw = handlerDraw; h.ah.HScrollMax = handlerHScrollMax; h.ah.VScrollMax = handlerVScrollMax; h.ah.RedrawOnResize = handlerRedrawOnResize; h.ah.MouseEvent = handlerMouseEvent; h.ah.DragBroken = handlerDragBroken; h.ah.KeyEvent = handlerKeyEvent; registerAreaClass(); ZeroMemory(&wc, sizeof (WNDCLASSW)); wc.lpszClassName = L"mainwin"; wc.lpfnWndProc = wndproc; wc.hInstance = hInstance; wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); RegisterClassW(&wc); mainwin = CreateWindowExW(0, L"mainwin", L"mainwin", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); area = makeArea(0, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, mainwin, (uiAreaHandler *) (&h)); nhspinb = CreateWindowExW(WS_EX_CLIENTEDGE, L"edit", L"0", ES_NUMBER | WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, mainwin, NULL, hInstance, NULL); nvspinb = CreateWindowExW(WS_EX_CLIENTEDGE, L"edit", L"0", ES_NUMBER | WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, mainwin, NULL, hInstance, NULL); // initial state repos(mainwin); areaUpdateScroll(area); ShowWindow(mainwin, SW_SHOWDEFAULT); UpdateWindow(mainwin); extern BOOL processAreaMessage(MSG *); while (GetMessage(&msg, NULL, 0, 0)) { if (processAreaMessage(&msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } uninitDraw(); CoUninitialize(); return 0; }