scroll mode for very long start menus
[reactos.git] / reactos / apps / tests / tests / hello / hello.c
1 #include <windows.h>
2 #include <string.h>
3
4 char szAppName[] = "Hello";
5
6 long FAR PASCAL WndProc(HWND, UINT, WPARAM, LPARAM);
7
8 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine,
9 int nCmdShow)
10 {
11 HWND hwnd;
12 MSG msg;
13 WNDCLASS wndclass;
14
15 if(!hPrevInst) {
16
17 wndclass.style = CS_HREDRAW | CS_VREDRAW;
18 wndclass.lpfnWndProc = WndProc;
19 wndclass.cbClsExtra = 0;
20 wndclass.cbWndExtra = 0;
21 wndclass.hInstance = hInstance;
22 wndclass.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION));
23 wndclass.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
24 wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
25 wndclass.lpszMenuName = NULL;
26 wndclass.lpszClassName = szAppName;
27
28 RegisterClass(&wndclass);
29
30
31 }
32
33 hwnd = CreateWindow(szAppName, szAppName,
34 WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
35 CW_USEDEFAULT, CW_USEDEFAULT, 600,
36 400, NULL, NULL, hInstance, NULL);
37
38 ShowWindow(hwnd, nCmdShow);
39 UpdateWindow(hwnd);
40
41
42 while(GetMessage(&msg, NULL, 0, 0)) {
43 TranslateMessage(&msg);
44 DispatchMessage(&msg);
45 }
46 return msg.wParam;
47 }
48
49
50
51 long FAR PASCAL WndProc(HWND hwnd, UINT message, WPARAM wParam,
52 LPARAM lParam)
53 {
54 HDC hdc;
55 RECT rect;
56 SIZE size;
57 PAINTSTRUCT ps;
58
59 switch(message) {
60
61 case WM_PAINT:
62 hdc = BeginPaint(hwnd, &ps);
63 GetClientRect(hwnd, &rect);
64 InflateRect(&rect, -10, -10);
65 if( !IsRectEmpty( &rect ) )
66 {
67 GetTextExtentPoint32(hdc, szAppName, strlen(szAppName), &size);
68 SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
69 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
70 rect.left = (rect.right + rect.left - size.cx) / 2;
71 rect.top = (rect.bottom + rect.top - size.cy) / 2;
72 SetBkMode(hdc, TRANSPARENT);
73 TextOut(hdc, rect.left, rect.top, szAppName, strlen(szAppName) );
74 }
75 EndPaint(hwnd, &ps);
76 return 0;
77
78 case WM_DESTROY:
79 PostQuitMessage(0);
80 return 0;
81 }
82 return DefWindowProc(hwnd, message, wParam, lParam);
83 }
84