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