3 char szAppName
[] = "Hello";
5 long FAR PASCAL
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
7 int PASCAL
WinMain (HINSTANCE hInstance
, HINSTANCE hPrevInst
, LPSTR lpszCmdLine
,
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
);
41 while(GetMessage(&msg
, NULL
, 0, 0)) {
42 TranslateMessage(&msg
);
43 DispatchMessage(&msg
);
50 long FAR PASCAL
WndProc(HWND hwnd
, UINT message
, WPARAM wParam
,
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
) );
81 return DefWindowProc(hwnd
, message
, wParam
, lParam
);