dosmod protocol revision 3, featuring MPROTECT and ENTERIDLE.
[wine] / rc / systest.c
1 #include <windows.h>\r
2 \r
3 LRESULT CALLBACK  _export WndProc(HWND hWnd, UINT message,\r
4               WPARAM wParam, LPARAM lParam);\r
5 \r
6 BOOL CALLBACK _export DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);\r
7 \r
8 HINSTANCE hInst;\r
9 HMENU hMenu,dummy;\r
10 extern char sysres_MENU_SYSMENU[],sysres_BITMAP_WINELOGO[],sysres_DIALOG_2[];\r
11 \r
12 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,\r
13                    LPSTR lpszCmdLine, int cmdShow)\r
14 {\r
15     MSG   msg;\r
16     WNDCLASS wcHdumpClass;\r
17     HWND hWndMain;\r
18 \r
19     hInst=hInstance;\r
20 \r
21     /* Define the window class for this application.\r */
22     wcHdumpClass.lpszClassName = "WrcTestClass";\r
23     wcHdumpClass.hInstance     = hInstance;\r
24     wcHdumpClass.lpfnWndProc   = WndProc;\r
25     wcHdumpClass.hCursor       = 0;\r
26     wcHdumpClass.hIcon         = 0;\r
27     wcHdumpClass.lpszMenuName  = 0;\r
28     wcHdumpClass.hbrBackground = GetStockObject(WHITE_BRUSH);\r
29     wcHdumpClass.style         = CS_HREDRAW | CS_VREDRAW;\r
30     wcHdumpClass.cbClsExtra    = 0;\r
31     wcHdumpClass.cbWndExtra    = 0;\r
32     RegisterClass(&wcHdumpClass);\r
33 \r
34     hWndMain = CreateWindow("WrcTestClass","WrcTest",\r
35                   WS_OVERLAPPEDWINDOW,\r
36                   CW_USEDEFAULT,           /* x  window location\r */
37                   CW_USEDEFAULT,           /* y\r */
38                   CW_USEDEFAULT,           /* cx and size\r */
39                   CW_USEDEFAULT,           /* cy\r */
40                   NULL,                    /* no parent for this window\r */
41                   NULL,                    /* use the class menu\r */
42                   hInstance,               /* who created this window\r */
43                   NULL                     /* no parms to pass on\r */
44                   );\r
45     ShowWindow(hWndMain,SW_SHOW);\r
46     UpdateWindow(hWndMain);\r
47     hMenu=LoadMenuIndirect(sysres_MENU_SYSMENU);\r
48 \r
49     /* see Q75254 on how to create a popup menu via LoadMenuIndirect */\r
50     dummy=CreateMenu();\r
51     InsertMenu(dummy,0,MF_POPUP,hMenu,NULL);\r
52     hMenu=GetSubMenu(dummy,0);\r
53 \r
54     while (GetMessage(&msg, NULL, NULL, NULL))\r
55     {\r
56         TranslateMessage(&msg);\r
57         DispatchMessage(&msg);\r
58     }\r
59 \r
60     return(msg.wParam);\r
61 }\r
62 \r
63 LRESULT CALLBACK  _export WndProc(HWND hWnd, UINT message,\r
64               WPARAM wParam, LPARAM lParam)\r
65 {\r
66     POINT ptCurrent;\r
67     switch(message)\r
68     {\r
69         case WM_LBUTTONDOWN:\r
70                 ptCurrent=MAKEPOINT(lParam);\r
71                 ClientToScreen(hWnd,&ptCurrent);\r
72                 TrackPopupMenu(hMenu,0,ptCurrent.x,ptCurrent.y,0,hWnd,0);\r
73                 break;\r
74         case WM_PAINT:\r
75         {       PAINTSTRUCT ps;\r
76                 BITMAPINFO *bm=sysres_BITMAP_WINELOGO;\r
77                 char *bits=bm;\r
78                 bits+=bm->bmiHeader.biSize;\r
79                 bits+=(1<<bm->bmiHeader.biBitCount)*sizeof(RGBQUAD);\r
80                 BeginPaint(hWnd,&ps);\r
81                 SetDIBitsToDevice(ps.hdc,0,0,bm->bmiHeader.biWidth,\r
82                 bm->bmiHeader.biHeight,0,0,0,bm->bmiHeader.biHeight,\r
83                 bits,bm,DIB_RGB_COLORS);\r
84                 EndPaint(hWnd,&ps);\r
85                 break;\r
86         }\r
87         case WM_COMMAND:\r
88                 CreateDialogIndirect(hInst,sysres_DIALOG_2,hWnd,DlgProc);\r
89                 break;\r
90         case WM_DESTROY:\r
91                  PostQuitMessage(0);\r
92                  break;     \r
93     default:return DefWindowProc(hWnd,message,wParam,lParam);\r
94     }\r
95     return 0L;\r
96 }\r
97 \r
98 BOOL CALLBACK _export DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)\r
99 {\r
100     switch(msg)\r
101     {\r
102         case WM_INITDIALOG:\r
103                 return 1;\r
104         case WM_COMMAND:\r
105                 DestroyWindow(hWnd);\r
106                 return 0;        \r
107     }\r
108     return 0;\r
109 }        \r