Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

373 lines
12 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1987-1990 **/
  4. /********************************************************************/
  5. /*
  6. * FILE STATUS:
  7. * 9/18/90 Copied from generic template
  8. * 1/12/91 Split from Logon App, reduced to just Shell Test APP
  9. */
  10. /****************************************************************************
  11. PROGRAM: apptest.cxx
  12. PURPOSE: Generic Shell test program
  13. FUNCTIONS:
  14. Provides access to test modules which call shell APIs.
  15. COMMENTS:
  16. Windows can have several copies of your application running at the
  17. same time. The variable hInstance keeps track of which instance this
  18. application is so that processing will be to the correct window.
  19. ****************************************************************************/
  20. #define INCL_GDI
  21. #include "apptest.hxx"
  22. HINSTANCE hInstance = 0; // Required by wnerr.cxx
  23. /****************************************************************************
  24. FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
  25. PURPOSE: calls initialization function, processes message loop
  26. COMMENTS:
  27. Windows recognizes this function by name as the initial entry point
  28. for the program. This function calls the application initialization
  29. routine, if no other instance of the program is running, and always
  30. calls the instance initialization routine. It then executes a message
  31. retrieval and dispatch loop that is the top-level control structure
  32. for the remainder of execution. The loop is terminated when a WM_QUIT
  33. message is received, at which time this function exits the application
  34. instance by returning the value passed by PostQuitMessage().
  35. If this function must abort before entering the message loop, it
  36. returns the conventional value NULL.
  37. ****************************************************************************/
  38. WinMain(
  39. HINSTANCE hInstance, /* current instance */
  40. HINSTANCE hPrevInstance, /* previous instance */
  41. LPSTR lpCmdLine, /* command line */
  42. int nCmdShow /* show-window type (open/icon) */
  43. )
  44. {
  45. MSG msg; /* message */
  46. UNUSED(lpCmdLine);
  47. if (!hPrevInstance) /* Other instances of app running? */
  48. if (!InitApplication(hInstance)) /* Initialize shared things */
  49. return (FALSE); /* Exits if unable to initialize */
  50. /* Perform initializations that apply to a specific instance */
  51. if (!InitInstance(hInstance, nCmdShow))
  52. return (FALSE);
  53. /* Acquire and dispatch messages until a WM_QUIT message is received. */
  54. while (GetMessage(&msg, /* message structure */
  55. NULL, /* handle of window receiving the message */
  56. NULL, /* lowest message to examine */
  57. NULL)) /* highest message to examine */
  58. {
  59. TranslateMessage(&msg); /* Translates virtual key codes */
  60. DispatchMessage(&msg); /* Dispatches message to window */
  61. }
  62. return (msg.wParam); /* Returns the value from PostQuitMessage */
  63. }
  64. /****************************************************************************
  65. FUNCTION: InitApplication(HANDLE)
  66. PURPOSE: Initializes window data and registers window class
  67. COMMENTS:
  68. This function is called at initialization time only if no other
  69. instances of the application are running. This function performs
  70. initialization tasks that can be done once for any number of running
  71. instances.
  72. In this case, we initialize a window class by filling out a data
  73. structure of type WNDCLASS and calling the Windows RegisterClass()
  74. function. Since all instances of this application use the same window
  75. class, we only need to do this when the first instance is initialized.
  76. ****************************************************************************/
  77. BOOL InitApplication(
  78. HINSTANCE hInstance /* current instance */
  79. )
  80. {
  81. WNDCLASS wc;
  82. /* Fill in window class structure with parameters that describe the */
  83. /* main window. */
  84. wc.style = NULL; /* Class style(s). */
  85. #ifdef WIN32
  86. wc.lpfnWndProc = (WNDPROC) MainWndProc;
  87. #else
  88. wc.lpfnWndProc = (LONGFARPROC) MainWndProc;
  89. #endif
  90. /* Function to retrieve messages for */
  91. /* windows of this class. */
  92. wc.cbClsExtra = 0; /* No per-class extra data. */
  93. wc.cbWndExtra = 0; /* No per-window extra data. */
  94. wc.hInstance = hInstance; /* Application that owns the class. */
  95. wc.hIcon = LoadIcon(hInstance, SZ("AppIcon")); /* load icon */
  96. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  97. wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
  98. wc.lpszMenuName = SZ("AppMenu");
  99. /* Name of menu resource in .RC file. */
  100. wc.lpszClassName = WC_MAINWINDOW; /* Name used in call to CreateWindow. */
  101. /* Register the window class and return success/failure code. */
  102. return (RegisterClass(&wc));
  103. }
  104. /****************************************************************************
  105. FUNCTION: InitInstance(HANDLE, int)
  106. PURPOSE: Saves instance handle and creates main window
  107. COMMENTS:
  108. This function is called at initialization time for every instance of
  109. this application. This function performs initialization tasks that
  110. cannot be shared by multiple instances.
  111. In this case, we save the instance handle in a static variable and
  112. create and display the main program window.
  113. ****************************************************************************/
  114. BOOL InitInstance(
  115. HINSTANCE hInstance, /* Current instance identifier. */
  116. int nCmdShow /* Param for first ShowWindow() call. */
  117. )
  118. {
  119. HWND hWnd; /* Main window handle. */
  120. TCHAR pszWindowTitle[MAXLEN_WINDOWTITLE_STRING+1];
  121. /* window title */
  122. /* Save the instance handle in static variable, which will be used in */
  123. /* many subsequence calls from this application to Windows. */
  124. ::hInstance = hInstance;
  125. /* Create a main window for this application instance. */
  126. hWnd = CreateWindow(
  127. WC_MAINWINDOW, /* See RegisterClass() call. */
  128. pszWindowTitle, /* Text for window title bar. */
  129. WS_OVERLAPPEDWINDOW, /* Window style. */
  130. /* Width? Height? Initial position? */
  131. CW_USEDEFAULT, /* Default horizontal position. */
  132. CW_USEDEFAULT, /* Default vertical position. */
  133. CW_USEDEFAULT, /* Default width. */
  134. CW_USEDEFAULT, /* Default height. */
  135. NULL, /* Overlapped windows have no parent. */
  136. LoadMenu( ::hInstance, SZ("AppMenu")), /* Use the window class menu. */
  137. hInstance, /* This instance owns this window. */
  138. NULL /* Pointer not needed. */
  139. );
  140. /* If window could not be created, return "failure" */
  141. if (!hWnd)
  142. return (FALSE);
  143. /* Make the window visible; update its client area; and return "success" */
  144. ShowWindow(hWnd, nCmdShow); /* Show the window */
  145. UpdateWindow(hWnd); /* Sends WM_PAINT message */
  146. return (TRUE); /* Returns the value from PostQuitMessage */
  147. }
  148. /****************************************************************************
  149. FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
  150. PURPOSE: Processes messages
  151. MESSAGES:
  152. WM_COMMAND - application menu (About dialog box)
  153. WM_DESTROY - destroy window
  154. COMMENTS:
  155. To process the IDM_ABOUT message, call MakeProcInstance() to get the
  156. current instance address of the About() function. Then call Dialog
  157. box which will create the box according to the information in your
  158. generic.rc file and turn control over to the About() function. When
  159. it returns, free the intance address.
  160. ****************************************************************************/
  161. long /* FAR PASCAL */ MainWndProc(
  162. HWND hWnd, /* window handle */
  163. unsigned message, /* type of message */
  164. WORD wParam, /* additional information */
  165. LONG lParam /* additional information */
  166. )
  167. {
  168. FARPROC lpProcAbout; /* pointer to the "About" function */
  169. switch (message) {
  170. case WM_COMMAND: /* message: command from application menu */
  171. switch (wParam)
  172. {
  173. case IDM_HELP_ABOUT:
  174. lpProcAbout = MakeProcInstance((FARPROC)About, ::hInstance);
  175. DialogBox(::hInstance, /* current instance */
  176. SZ("AboutBox"), /* resource to use */
  177. hWnd, /* parent handle */
  178. (DLGPROC) lpProcAbout); /* About() instance address */
  179. FreeProcInstance(lpProcAbout);
  180. break;
  181. #ifndef WIN32
  182. // Autologon and change password tests
  183. case IDM_TEST_1:
  184. // test1(hWnd);
  185. break;
  186. case IDM_TEST_2:
  187. // test2(hWnd);
  188. break;
  189. #endif //!WIN32
  190. case IDM_TEST_3:
  191. test3(hWnd);
  192. break;
  193. case IDM_TEST_4:
  194. // test4(hWnd);
  195. break;
  196. case IDM_TEST_5:
  197. //test5(hWnd);
  198. break;
  199. case IDM_TEST_6:
  200. // test6(hWnd);
  201. break;
  202. case IDM_TEST_7:
  203. // test7(hWnd);
  204. break;
  205. case IDM_TEST_8:
  206. // test8(hWnd);
  207. break;
  208. case IDM_TEST_9:
  209. // test9(hWnd);
  210. break;
  211. #ifdef WIN32
  212. case IDM_TEST_10:
  213. // test10(hInstance,hWnd);
  214. break;
  215. #endif
  216. case IDM_TEST_11:
  217. // test11(hWnd );
  218. break;
  219. default: /* Lets Windows process it */
  220. return (DefWindowProc(hWnd, message, wParam, lParam));
  221. }
  222. case WM_PAINT: /* message: update window */
  223. {
  224. PAINTSTRUCT ps;
  225. BeginPaint (hWnd, &ps);
  226. //DrawStrings(&ps);
  227. EndPaint (hWnd, &ps);
  228. }
  229. break;
  230. case WM_ACTIVATE: /* message: (de)activate window */
  231. return (DefWindowProc(hWnd, message, wParam, lParam));
  232. case WM_DESTROY: /* message: window being destroyed */
  233. PostQuitMessage(0);
  234. break;
  235. default: /* Passes it on if unproccessed */
  236. return (DefWindowProc(hWnd, message, wParam, lParam));
  237. }
  238. return (NULL);
  239. }
  240. /****************************************************************************
  241. FUNCTION: About(HWND, unsigned, WORD, LONG)
  242. PURPOSE: Processes messages for "About" dialog box
  243. MESSAGES:
  244. WM_INITDIALOG - initialize dialog box
  245. WM_COMMAND - Input received
  246. COMMENTS:
  247. No initialization is needed for this particular dialog box, but TRUE
  248. must be returned to Windows.
  249. Wait for user to click on "Ok" button, then close the dialog box.
  250. ****************************************************************************/
  251. BOOL /* FAR PASCAL */ About(
  252. HWND hDlg, /* window handle of the dialog box */
  253. unsigned message, /* type of message */
  254. WORD wParam, /* message-specific information */
  255. LONG lParam
  256. )
  257. {
  258. UNUSED(lParam);
  259. switch (message) {
  260. case WM_INITDIALOG: /* message: initialize dialog box */
  261. return (TRUE);
  262. case WM_COMMAND: /* message: received a command */
  263. if (wParam == IDOK /* "OK" box selected? */
  264. || wParam == IDCANCEL) { /* System menu close command? */
  265. EndDialog(hDlg, TRUE); /* Exits the dialog box */
  266. return (TRUE);
  267. }
  268. break;
  269. }
  270. return (FALSE); /* Didn't process a message */
  271. }