- Minor API file update.
[wine.git] / libtest / hello3.c
blobf71c25c5d8f041a0b94ea42def7639e744b3320d
1 /*
2 * Copyright 1995 Martin von Loewis
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
19 #include <windows.h>
20 #include <commdlg.h>
22 typedef struct
24 HANDLE hInstance;
25 HWND hMainWnd;
26 HMENU hMainMenu;
27 } GLOBALS;
29 GLOBALS Globals;
31 BOOL FileOpen(HWND hWnd)
33 char filename[80] = "test.c";
34 OPENFILENAME ofn = { sizeof(OPENFILENAME),
35 hWnd, NULL, "C code\0*.c\0", NULL, 0, 0, filename, 80,
36 NULL, 0, NULL, NULL, OFN_CREATEPROMPT |
37 OFN_SHOWHELP, 0, 0, NULL, 0, NULL };
38 return GetOpenFileName(&ofn);
41 LRESULT CALLBACK DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
43 switch(msg)
45 case WM_INITDIALOG:
46 break;
47 case WM_COMMAND:
48 switch (wParam)
50 case 100:
51 EndDialog(hWnd, 100);
52 return TRUE;
55 return FALSE;
58 LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
60 switch (msg){
62 case WM_COMMAND:
63 switch(w){
64 case 100:
65 DialogBox(Globals.hInstance,
66 "DIADEMO", wnd,
67 (DLGPROC)DlgProc);
68 return 0;
69 case 101:
71 HDC hdc, hMemDC;
72 HBITMAP hBitmap, hPrevBitmap;
73 BITMAP bmp;
75 hBitmap = LoadBitmapA (Globals.hInstance, "BITDEMO");
76 hdc = GetDC (wnd);
77 hMemDC = CreateCompatibleDC (hdc);
78 hPrevBitmap = SelectObject (hMemDC, hBitmap);
79 GetObjectA (hBitmap, sizeof(BITMAP), &bmp);
80 BitBlt (hdc, 0, 0, bmp.bmWidth, bmp.bmHeight,
81 hMemDC, 0, 0, SRCCOPY);
82 SelectObject (hMemDC, hPrevBitmap);
83 DeleteDC (hMemDC);
84 ReleaseDC (wnd, hdc);
85 return 0;
87 case 102:
88 FileOpen(wnd);
89 return 0;
90 default:
91 return DefWindowProc (wnd, msg, w, l);
93 case WM_DESTROY:
94 PostQuitMessage (0);
95 break;
97 default:
98 return DefWindowProc (wnd, msg, w, l);
100 return 0l;
103 int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
105 MSG msg;
106 WNDCLASS class;
107 char className[] = "class"; /* To make sure className >= 0x10000 */
108 char winName[] = "Test app";
110 Globals.hInstance = inst;
111 if (!prev){
112 class.style = CS_HREDRAW | CS_VREDRAW;
113 class.lpfnWndProc = WndProc;
114 class.cbClsExtra = 0;
115 class.cbWndExtra = 0;
116 class.hInstance = inst;
117 class.hIcon = LoadIcon (0, IDI_APPLICATION);
118 class.hCursor = LoadCursor (0, IDC_ARROW);
119 class.hbrBackground = GetStockObject (WHITE_BRUSH);
120 class.lpszMenuName = 0;
121 class.lpszClassName = className;
123 if (!RegisterClass (&class))
124 return FALSE;
126 Globals.hMainWnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW,
127 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
128 LoadMenu(inst,"MAIN"), inst, 0);
129 ShowWindow (Globals.hMainWnd, show);
130 UpdateWindow (Globals.hMainWnd);
132 while (GetMessage (&msg, 0, 0, 0)){
133 TranslateMessage (&msg);
134 DispatchMessage (&msg);
136 return 0;