Alexandre Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 1 | #include <windows.h> |
| 2 | |
Alex Korobka | 5a3a9a8 | 1999-04-03 13:50:08 +0000 | [diff] [blame] | 3 | char szAppName[] = "Hello"; |
| 4 | |
| 5 | long FAR PASCAL WndProc(HWND, UINT, WPARAM, LPARAM); |
| 6 | |
Francois Gouget | 28fc36d | 2000-07-23 19:32:11 +0000 | [diff] [blame] | 7 | int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, |
Alex Korobka | 5a3a9a8 | 1999-04-03 13:50:08 +0000 | [diff] [blame] | 8 | int nCmdShow) |
Alexandre Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 9 | { |
Alex Korobka | 5a3a9a8 | 1999-04-03 13:50:08 +0000 | [diff] [blame] | 10 | HWND hwnd; |
| 11 | MSG msg; |
| 12 | WNDCLASS wndclass; |
Alexandre Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 13 | |
Alex Korobka | 5a3a9a8 | 1999-04-03 13:50:08 +0000 | [diff] [blame] | 14 | 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 | |
| 50 | long FAR PASCAL WndProc(HWND hwnd, UINT message, WPARAM wParam, |
| 51 | LPARAM lParam) |
Alexandre Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 52 | { |
Alex Korobka | 5a3a9a8 | 1999-04-03 13:50:08 +0000 | [diff] [blame] | 53 | HDC hdc; |
| 54 | RECT rect; |
| 55 | SIZE size; |
| 56 | PAINTSTRUCT ps; |
Alexandre Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 57 | |
Alex Korobka | 5a3a9a8 | 1999-04-03 13:50:08 +0000 | [diff] [blame] | 58 | 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 Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 83 | |