4 char szAppName
[] = "Hello";
6 long FAR PASCAL
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
8 int PASCAL
WinMain (HINSTANCE hInstance
, HINSTANCE hPrevInst
, LPSTR lpszCmdLine
,
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
;
28 RegisterClass(&wndclass
);
33 hwnd
= CreateWindow(szAppName
, szAppName
,
34 WS_HSCROLL
| WS_VSCROLL
| WS_OVERLAPPEDWINDOW
,
35 CW_USEDEFAULT
, CW_USEDEFAULT
, 600,
36 400, NULL
, NULL
, hInstance
, NULL
);
38 ShowWindow(hwnd
, nCmdShow
);
42 while(GetMessage(&msg
, NULL
, 0, 0)) {
43 TranslateMessage(&msg
);
44 DispatchMessage(&msg
);
51 long FAR PASCAL
WndProc(HWND hwnd
, UINT message
, WPARAM wParam
,
62 hdc
= BeginPaint(hwnd
, &ps
);
63 GetClientRect(hwnd
, &rect
);
64 InflateRect(&rect
, -10, -10);
65 if( !IsRectEmpty( &rect
) )
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
) );
82 return DefWindowProc(hwnd
, message
, wParam
, lParam
);