Release 951212
[wine.git] / toolkit / hello3.c
blob5b9cd5118edf12389e725f5b9bee3b6a372cc2f0
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,hello3_DIALOG_DIADEMO.bytes,wnd,(WNDPROC)DlgProc);
37 return 0;
38 case 101:
40 BITMAPINFO *bm=hello3_BITMAP_BITDEMO.bytes;
41 char *bits=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;
73 if (!prev){
74 class.style = CS_HREDRAW | CS_VREDRAW;
75 class.lpfnWndProc = WndProc;
76 class.cbClsExtra = 0;
77 class.cbWndExtra = 0;
78 class.hInstance = inst;
79 class.hIcon = LoadIcon (0, IDI_APPLICATION);
80 class.hCursor = LoadCursor (0, IDC_ARROW);
81 class.hbrBackground = GetStockObject (WHITE_BRUSH);
82 class.lpszMenuName = 0;
83 class.lpszClassName = (SEGPTR)"class";
85 if (!RegisterClass (&class))
86 return FALSE;
88 wnd = CreateWindow ("class", "Test app", WS_OVERLAPPEDWINDOW,
89 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
90 LoadMenu(inst,"MAIN"), inst, 0);
91 ShowWindow (wnd, show);
92 UpdateWindow (wnd);
94 while (GetMessage (&msg, 0, 0, 0)){
95 TranslateMessage (&msg);
96 DispatchMessage (&msg);
98 return 0;