Made libtest/hello3 work again, now with Windows-compatible resource
[wine/multimedia.git] / libtest / hello3.c
blobef22314267c8e509402075a0646c304b42a0dfea
1 #include <windows.h>
2 #include <resource.h>
3 #include <commdlg.h>
4 #include "hello3res.h"
6 typedef struct
8 HANDLE hInstance;
9 HWND hMainWnd;
10 HMENU hMainMenu;
11 } GLOBALS;
13 GLOBALS Globals;
15 BOOL FileOpen(HWND hWnd)
17 char filename[80] = "test.c";
18 OPENFILENAME ofn = { sizeof(OPENFILENAME),
19 hWnd, NULL, "C code\0*.c\0", NULL, 0, 0, filename, 80,
20 NULL, 0, NULL, NULL, OFN_CREATEPROMPT |
21 OFN_SHOWHELP, 0, 0, NULL, 0, NULL };
22 return GetOpenFileName(&ofn);
25 BOOL CALLBACK DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
27 switch(msg)
29 case WM_INITDIALOG:
30 return 1;
31 case WM_COMMAND:
32 if(wParam==100)
33 DestroyWindow(hWnd);
34 return 0;
36 return 0;
39 LRESULT WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
41 switch (msg){
43 case WM_COMMAND:
44 switch(w){
45 case 100:
46 DialogBox(Globals.hInstance,
47 "DIADEMO", wnd,
48 (DLGPROC)DlgProc);
49 return 0;
50 case 101:
52 HDC hdc, hMemDC;
53 HBITMAP hBitmap, hPrevBitmap;
54 BITMAP bmp;
56 hBitmap = LoadBitmapA (Globals.hInstance, "BITDEMO");
57 hdc = GetDC (wnd);
58 hMemDC = CreateCompatibleDC (hdc);
59 hPrevBitmap = SelectObject (hMemDC, hBitmap);
60 GetObjectA (hBitmap, sizeof(BITMAP), &bmp);
61 BitBlt (hdc, 0, 0, bmp.bmWidth, bmp.bmHeight,
62 hMemDC, 0, 0, SRCCOPY);
63 SelectObject (hMemDC, hPrevBitmap);
64 DeleteDC (hMemDC);
65 ReleaseDC (wnd, hdc);
66 return 0;
68 case 102:
69 FileOpen(wnd);
70 return 0;
71 default:
72 return DefWindowProc (wnd, msg, w, l);
74 case WM_DESTROY:
75 PostQuitMessage (0);
76 break;
78 default:
79 return DefWindowProc (wnd, msg, w, l);
81 return 0l;
84 int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
86 MSG msg;
87 WNDCLASS class;
88 char className[] = "class"; /* To make sure className >= 0x10000 */
89 char winName[] = "Test app";
91 Globals.hInstance = inst;
92 if (!prev){
93 class.style = CS_HREDRAW | CS_VREDRAW;
94 class.lpfnWndProc = WndProc;
95 class.cbClsExtra = 0;
96 class.cbWndExtra = 0;
97 class.hInstance = inst;
98 class.hIcon = LoadIcon (0, IDI_APPLICATION);
99 class.hCursor = LoadCursor (0, IDC_ARROW);
100 class.hbrBackground = GetStockObject (WHITE_BRUSH);
101 class.lpszMenuName = 0;
102 class.lpszClassName = (SEGPTR)className;
104 if (!RegisterClass (&class))
105 return FALSE;
107 Globals.hMainWnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW,
108 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
109 LoadMenu(inst,"MAIN"), inst, 0);
110 ShowWindow (Globals.hMainWnd, show);
111 UpdateWindow (Globals.hMainWnd);
113 while (GetMessage (&msg, 0, 0, 0)){
114 TranslateMessage (&msg);
115 DispatchMessage (&msg);
117 return 0;