Release 980215
[wine/multimedia.git] / libtest / hello3.c
blob6a75ff42066117fe821dad666c4146ea71d9bd6f
1 #include <windows.h>
2 #include <resource.h>
3 #include "hello3res.h"
4 #include <commdlg.h>
6 BOOL FileOpen(HWND hWnd)
8 char filename[80] = "test.c";
9 OPENFILENAME ofn = { sizeof(OPENFILENAME),
10 hWnd, NULL, "C code\0*.c\0", NULL, 0, 0, filename, 80,
11 NULL, 0, NULL, NULL, OFN_CREATEPROMPT |
12 OFN_SHOWHELP, 0, 0, NULL, 0, NULL };
13 return GetOpenFileName(&ofn);
16 BOOL CALLBACK DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
18 switch(msg)
20 case WM_INITDIALOG:
21 return 1;
22 case WM_COMMAND:
23 if(wParam==100)
24 DestroyWindow(hWnd);
25 return 0;
27 return 0;
30 LRESULT WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
32 switch (msg){
34 case WM_COMMAND:
35 switch(w){
36 case 100:
37 CreateDialogIndirect(0,hello3res_DIALOG_DIADEMO.bytes,wnd,(WNDPROC)DlgProc);
38 return 0;
39 case 101:
41 BITMAPINFO *bm=(BITMAPINFO*)hello3res_BITMAP_BITDEMO.bytes;
42 char *bits=(char*)bm;
43 HDC hdc=GetDC(wnd);
44 bits+=bm->bmiHeader.biSize;
45 bits+=(1<<bm->bmiHeader.biBitCount)*sizeof(RGBQUAD);
46 SetDIBitsToDevice(hdc,0,0,bm->bmiHeader.biWidth,
47 bm->bmiHeader.biHeight,0,0,0,bm->bmiHeader.biHeight,
48 bits,bm,DIB_RGB_COLORS);
49 ReleaseDC(wnd,hdc);
50 return 0;
52 case 102:
53 FileOpen(wnd);
54 return 0;
55 default:
56 return DefWindowProc (wnd, msg, w, l);
58 case WM_DESTROY:
59 PostQuitMessage (0);
60 break;
62 default:
63 return DefWindowProc (wnd, msg, w, l);
65 return 0l;
68 int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
70 HWND wnd;
71 MSG msg;
72 WNDCLASS class;
73 char className[] = "class"; /* To make sure className >= 0x10000 */
74 char winName[] = "Test app";
76 if (!prev){
77 class.style = CS_HREDRAW | CS_VREDRAW;
78 class.lpfnWndProc = WndProc;
79 class.cbClsExtra = 0;
80 class.cbWndExtra = 0;
81 class.hInstance = inst;
82 class.hIcon = LoadIcon (0, IDI_APPLICATION);
83 class.hCursor = LoadCursor (0, IDC_ARROW);
84 class.hbrBackground = GetStockObject (WHITE_BRUSH);
85 class.lpszMenuName = 0;
86 class.lpszClassName = (SEGPTR)className;
88 if (!RegisterClass (&class))
89 return FALSE;
91 wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW,
92 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
93 LoadMenu(inst,"MAIN"), inst, 0);
94 ShowWindow (wnd, show);
95 UpdateWindow (wnd);
97 while (GetMessage (&msg, 0, 0, 0)){
98 TranslateMessage (&msg);
99 DispatchMessage (&msg);
101 return 0;