2 * Copyright 1994 Miguel de Icaza
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 char szAppName
[] = "Hello";
23 long FAR PASCAL
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
25 int PASCAL
WinMain (HINSTANCE hInstance
, HINSTANCE hPrevInst
, LPSTR lpszCmdLine
,
34 wndclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
35 wndclass
.lpfnWndProc
= WndProc
;
36 wndclass
.cbClsExtra
= 0;
37 wndclass
.cbWndExtra
= 0;
38 wndclass
.hInstance
= hInstance
;
39 wndclass
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
40 wndclass
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
41 wndclass
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
42 wndclass
.lpszMenuName
= NULL
;
43 wndclass
.lpszClassName
= szAppName
;
45 RegisterClass(&wndclass
);
50 hwnd
= CreateWindow(szAppName
, szAppName
,
51 WS_HSCROLL
| WS_VSCROLL
| WS_OVERLAPPEDWINDOW
,
52 CW_USEDEFAULT
, CW_USEDEFAULT
, 600,
53 400, NULL
, NULL
, hInstance
, NULL
);
55 ShowWindow(hwnd
, nCmdShow
);
59 while(GetMessage(&msg
, NULL
, 0, 0)) {
60 TranslateMessage(&msg
);
61 DispatchMessage(&msg
);
68 long FAR PASCAL
WndProc(HWND hwnd
, UINT message
, WPARAM wParam
,
79 hdc
= BeginPaint(hwnd
, &ps
);
80 GetClientRect(hwnd
, &rect
);
81 InflateRect(&rect
, -10, -10);
82 if( !IsRectEmpty( &rect
) )
84 GetTextExtentPoint32(hdc
, szAppName
, strlen(szAppName
), &size
);
85 SelectObject(hdc
, GetStockObject(LTGRAY_BRUSH
));
86 Rectangle(hdc
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
87 rect
.left
= (rect
.right
+ rect
.left
- size
.cx
) / 2;
88 rect
.top
= (rect
.bottom
+ rect
.top
- size
.cy
) / 2;
89 SetBkMode(hdc
, TRANSPARENT
);
90 TextOut(hdc
, rect
.left
, rect
.top
, szAppName
, strlen(szAppName
) );
99 return DefWindowProc(hwnd
, message
, wParam
, lParam
);