Rewrite GetCommState16 using GetCommState.
[wine.git] / libtest / hello3.c
blob80e077bf9881434c193795f2ceb29a406a3b985f
1 #include <windows.h>
2 #include <commdlg.h>
4 typedef struct
6 HANDLE hInstance;
7 HWND hMainWnd;
8 HMENU hMainMenu;
9 } GLOBALS;
11 GLOBALS Globals;
13 BOOL FileOpen(HWND hWnd)
15 char filename[80] = "test.c";
16 OPENFILENAME ofn = { sizeof(OPENFILENAME),
17 hWnd, NULL, "C code\0*.c\0", NULL, 0, 0, filename, 80,
18 NULL, 0, NULL, NULL, OFN_CREATEPROMPT |
19 OFN_SHOWHELP, 0, 0, NULL, 0, NULL };
20 return GetOpenFileName(&ofn);
23 LRESULT CALLBACK DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
25 switch(msg)
27 case WM_INITDIALOG:
28 break;
29 case WM_COMMAND:
30 switch (wParam)
32 case 100:
33 EndDialog(hWnd, 100);
34 return TRUE;
37 return FALSE;
40 LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
42 switch (msg){
44 case WM_COMMAND:
45 switch(w){
46 case 100:
47 DialogBox(Globals.hInstance,
48 "DIADEMO", wnd,
49 (DLGPROC)DlgProc);
50 return 0;
51 case 101:
53 HDC hdc, hMemDC;
54 HBITMAP hBitmap, hPrevBitmap;
55 BITMAP bmp;
57 hBitmap = LoadBitmapA (Globals.hInstance, "BITDEMO");
58 hdc = GetDC (wnd);
59 hMemDC = CreateCompatibleDC (hdc);
60 hPrevBitmap = SelectObject (hMemDC, hBitmap);
61 GetObjectA (hBitmap, sizeof(BITMAP), &bmp);
62 BitBlt (hdc, 0, 0, bmp.bmWidth, bmp.bmHeight,
63 hMemDC, 0, 0, SRCCOPY);
64 SelectObject (hMemDC, hPrevBitmap);
65 DeleteDC (hMemDC);
66 ReleaseDC (wnd, hdc);
67 return 0;
69 case 102:
70 FileOpen(wnd);
71 return 0;
72 default:
73 return DefWindowProc (wnd, msg, w, l);
75 case WM_DESTROY:
76 PostQuitMessage (0);
77 break;
79 default:
80 return DefWindowProc (wnd, msg, w, l);
82 return 0l;
85 int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
87 MSG msg;
88 WNDCLASS class;
89 char className[] = "class"; /* To make sure className >= 0x10000 */
90 char winName[] = "Test app";
92 Globals.hInstance = inst;
93 if (!prev){
94 class.style = CS_HREDRAW | CS_VREDRAW;
95 class.lpfnWndProc = WndProc;
96 class.cbClsExtra = 0;
97 class.cbWndExtra = 0;
98 class.hInstance = inst;
99 class.hIcon = LoadIcon (0, IDI_APPLICATION);
100 class.hCursor = LoadCursor (0, IDC_ARROW);
101 class.hbrBackground = GetStockObject (WHITE_BRUSH);
102 class.lpszMenuName = 0;
103 class.lpszClassName = className;
105 if (!RegisterClass (&class))
106 return FALSE;
108 Globals.hMainWnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW,
109 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
110 LoadMenu(inst,"MAIN"), inst, 0);
111 ShowWindow (Globals.hMainWnd, show);
112 UpdateWindow (Globals.hMainWnd);
114 while (GetMessage (&msg, 0, 0, 0)){
115 TranslateMessage (&msg);
116 DispatchMessage (&msg);
118 return 0;