BeginDeferWindowPos should allow zero count.
[wine.git] / libtest / hello.c
bloba897e940cc18b2c04ad1122255591fce2a69922f
1 #include <windows.h>
3 char szAppName[] = "Hello";
5 long FAR PASCAL WndProc(HWND, UINT, WPARAM, LPARAM);
7 int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInst, LPSTR lpszCmdLine,
8 int nCmdShow)
10 HWND hwnd;
11 MSG msg;
12 WNDCLASS wndclass;
14 if(!hPrevInst) {
16 wndclass.style = CS_HREDRAW | CS_VREDRAW;
17 wndclass.lpfnWndProc = WndProc;
18 wndclass.cbClsExtra = 0;
19 wndclass.cbWndExtra = 0;
20 wndclass.hInstance = hInstance;
21 wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
22 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
23 wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
24 wndclass.lpszMenuName = NULL;
25 wndclass.lpszClassName = szAppName;
27 RegisterClass(&wndclass);
32 hwnd = CreateWindow(szAppName, szAppName,
33 WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
34 CW_USEDEFAULT, CW_USEDEFAULT, 600,
35 400, NULL, NULL, hInstance, NULL);
37 ShowWindow(hwnd, nCmdShow);
38 UpdateWindow(hwnd);
41 while(GetMessage(&msg, NULL, 0, 0)) {
42 TranslateMessage(&msg);
43 DispatchMessage(&msg);
45 return msg.wParam;
50 long FAR PASCAL WndProc(HWND hwnd, UINT message, WPARAM wParam,
51 LPARAM lParam)
53 HDC hdc;
54 RECT rect;
55 SIZE size;
56 PAINTSTRUCT ps;
58 switch(message) {
60 case WM_PAINT:
61 hdc = BeginPaint(hwnd, &ps);
62 GetClientRect(hwnd, &rect);
63 InflateRect(&rect, -10, -10);
64 if( !IsRectEmpty( &rect ) )
66 GetTextExtentPoint32(hdc, szAppName, strlen(szAppName), &size);
67 SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
68 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
69 rect.left = (rect.right + rect.left - size.cx) / 2;
70 rect.top = (rect.bottom + rect.top - size.cy) / 2;
71 SetBkMode(hdc, TRANSPARENT);
72 TextOut(hdc, rect.left, rect.top, szAppName, strlen(szAppName) );
74 EndPaint(hwnd, &ps);
75 return 0;
77 case WM_DESTROY:
78 PostQuitMessage(0);
79 return 0;
81 return DefWindowProc(hwnd, message, wParam, lParam);