blob: 41036cb4a510a074df1470d5dc50a767351057b2 [file] [log] [blame]
Alexandre Julliard988ca971994-06-21 16:15:21 +00001#include <windows.h>
2
Alex Korobka5a3a9a81999-04-03 13:50:08 +00003char szAppName[] = "Hello";
4
5long FAR PASCAL WndProc(HWND, UINT, WPARAM, LPARAM);
6
Francois Gouget28fc36d2000-07-23 19:32:11 +00007int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine,
Alex Korobka5a3a9a81999-04-03 13:50:08 +00008 int nCmdShow)
Alexandre Julliard988ca971994-06-21 16:15:21 +00009{
Alex Korobka5a3a9a81999-04-03 13:50:08 +000010 HWND hwnd;
11 MSG msg;
12 WNDCLASS wndclass;
Alexandre Julliard988ca971994-06-21 16:15:21 +000013
Alex Korobka5a3a9a81999-04-03 13:50:08 +000014 if(!hPrevInst) {
15
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;
26
27 RegisterClass(&wndclass);
28
29
30 }
31
32 hwnd = CreateWindow(szAppName, szAppName,
33 WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
34 CW_USEDEFAULT, CW_USEDEFAULT, 600,
35 400, NULL, NULL, hInstance, NULL);
36
37 ShowWindow(hwnd, nCmdShow);
38 UpdateWindow(hwnd);
39
40
41 while(GetMessage(&msg, NULL, 0, 0)) {
42 TranslateMessage(&msg);
43 DispatchMessage(&msg);
44 }
45 return msg.wParam;
46}
47
48
49
50long FAR PASCAL WndProc(HWND hwnd, UINT message, WPARAM wParam,
51 LPARAM lParam)
Alexandre Julliard988ca971994-06-21 16:15:21 +000052{
Alex Korobka5a3a9a81999-04-03 13:50:08 +000053 HDC hdc;
54 RECT rect;
55 SIZE size;
56 PAINTSTRUCT ps;
Alexandre Julliard988ca971994-06-21 16:15:21 +000057
Alex Korobka5a3a9a81999-04-03 13:50:08 +000058 switch(message) {
59
60 case WM_PAINT:
61 hdc = BeginPaint(hwnd, &ps);
62 GetClientRect(hwnd, &rect);
63 InflateRect(&rect, -10, -10);
64 if( !IsRectEmpty( &rect ) )
65 {
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) );
73 }
74 EndPaint(hwnd, &ps);
75 return 0;
76
77 case WM_DESTROY:
78 PostQuitMessage(0);
79 return 0;
80 }
81 return DefWindowProc(hwnd, message, wParam, lParam);
82}
Alexandre Julliard988ca971994-06-21 16:15:21 +000083