test2.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /////////////////////////////////////////////////////////////////////////EA-V1
  19. // $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/test2/test2.cpp $
  20. // $Author: mhoffe $
  21. // $Revision: #1 $
  22. // $DateTime: 2003/07/03 11:55:26 $
  23. //
  24. // ©2003 Electronic Arts
  25. //
  26. // Debug module - Test 2 (Checking commands, CON I/O, cmddbg file)
  27. //////////////////////////////////////////////////////////////////////////////
  28. #include "stdafx.h"
  29. #include "resource.h"
  30. #include "..\debug.h"
  31. #define MAX_LOADSTRING 100
  32. // Global Variables:
  33. HINSTANCE hInst; // current instance
  34. TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
  35. TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
  36. // Foward declarations of functions included in this code module:
  37. ATOM MyRegisterClass(HINSTANCE hInstance);
  38. BOOL InitInstance(HINSTANCE, int);
  39. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  40. LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  41. class TestCmdInterface: public DebugCmdInterface
  42. {
  43. public:
  44. virtual bool Execute(class Debug& dbg, const char *cmd, CommandMode cmdmode,
  45. unsigned argn, const char * const * argv)
  46. {
  47. if (strcmp(cmd,"box"))
  48. return false;
  49. MessageBox(NULL,"Hello world!","Command",MB_OK);
  50. return true;
  51. }
  52. virtual void Delete(void) { delete this; }
  53. };
  54. DEBUG_CREATE_COMMAND_GROUP(test,TestCmdInterface)
  55. int APIENTRY WinMain(HINSTANCE hInstance,
  56. HINSTANCE hPrevInstance,
  57. LPSTR lpCmdLine,
  58. int nCmdShow)
  59. {
  60. // TODO: Place code here.
  61. MSG msg;
  62. HACCEL hAccelTable;
  63. // Initialize global strings
  64. LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  65. LoadString(hInstance, IDC_TEST2, szWindowClass, MAX_LOADSTRING);
  66. MyRegisterClass(hInstance);
  67. // Perform application initialization:
  68. if (!InitInstance (hInstance, nCmdShow))
  69. {
  70. return FALSE;
  71. }
  72. hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TEST2);
  73. // Send a command to Debug interface
  74. Debug::Command("debug.io ; send via EXE, try test.box!");
  75. // Main message loop:
  76. while (GetMessage(&msg, NULL, 0, 0))
  77. {
  78. if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  79. {
  80. TranslateMessage(&msg);
  81. DispatchMessage(&msg);
  82. }
  83. }
  84. return msg.wParam;
  85. }
  86. //
  87. // FUNCTION: MyRegisterClass()
  88. //
  89. // PURPOSE: Registers the window class.
  90. //
  91. // COMMENTS:
  92. //
  93. // This function and its usage is only necessary if you want this code
  94. // to be compatible with Win32 systems prior to the 'RegisterClassEx'
  95. // function that was added to Windows 95. It is important to call this function
  96. // so that the application will get 'well formed' small icons associated
  97. // with it.
  98. //
  99. ATOM MyRegisterClass(HINSTANCE hInstance)
  100. {
  101. WNDCLASSEX wcex;
  102. wcex.cbSize = sizeof(WNDCLASSEX);
  103. wcex.style = CS_HREDRAW | CS_VREDRAW;
  104. wcex.lpfnWndProc = (WNDPROC)WndProc;
  105. wcex.cbClsExtra = 0;
  106. wcex.cbWndExtra = 0;
  107. wcex.hInstance = hInstance;
  108. wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TEST2);
  109. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  110. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  111. wcex.lpszMenuName = (LPCSTR)IDC_TEST2;
  112. wcex.lpszClassName = szWindowClass;
  113. wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
  114. return RegisterClassEx(&wcex);
  115. }
  116. //
  117. // FUNCTION: InitInstance(HANDLE, int)
  118. //
  119. // PURPOSE: Saves instance handle and creates main window
  120. //
  121. // COMMENTS:
  122. //
  123. // In this function, we save the instance handle in a global variable and
  124. // create and display the main program window.
  125. //
  126. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  127. {
  128. HWND hWnd;
  129. hInst = hInstance; // Store instance handle in our global variable
  130. hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  131. CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
  132. if (!hWnd)
  133. {
  134. return FALSE;
  135. }
  136. // create a timer for calling Debug::Update
  137. SetTimer(hWnd,1,100,NULL);
  138. ShowWindow(hWnd, nCmdShow);
  139. UpdateWindow(hWnd);
  140. return TRUE;
  141. }
  142. //
  143. // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
  144. //
  145. // PURPOSE: Processes messages for the main window.
  146. //
  147. // WM_COMMAND - process the application menu
  148. // WM_PAINT - Paint the main window
  149. // WM_DESTROY - post a quit message and return
  150. //
  151. //
  152. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  153. {
  154. int wmId, wmEvent;
  155. PAINTSTRUCT ps;
  156. HDC hdc;
  157. TCHAR szHello[MAX_LOADSTRING];
  158. LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
  159. switch (message)
  160. {
  161. case WM_COMMAND:
  162. wmId = LOWORD(wParam);
  163. wmEvent = HIWORD(wParam);
  164. // Parse the menu selections:
  165. switch (wmId)
  166. {
  167. case IDM_ABOUT:
  168. DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
  169. break;
  170. case IDM_EXIT:
  171. DestroyWindow(hWnd);
  172. break;
  173. default:
  174. return DefWindowProc(hWnd, message, wParam, lParam);
  175. }
  176. break;
  177. case WM_PAINT:
  178. hdc = BeginPaint(hWnd, &ps);
  179. // TODO: Add any drawing code here...
  180. RECT rt;
  181. GetClientRect(hWnd, &rt);
  182. DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
  183. EndPaint(hWnd, &ps);
  184. break;
  185. case WM_DESTROY:
  186. PostQuitMessage(0);
  187. break;
  188. case WM_TIMER:
  189. Debug::Update();
  190. break;
  191. default:
  192. return DefWindowProc(hWnd, message, wParam, lParam);
  193. }
  194. return 0;
  195. }
  196. // Mesage handler for about box.
  197. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  198. {
  199. switch (message)
  200. {
  201. case WM_INITDIALOG:
  202. return TRUE;
  203. case WM_COMMAND:
  204. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  205. {
  206. EndDialog(hDlg, LOWORD(wParam));
  207. return TRUE;
  208. }
  209. break;
  210. }
  211. return FALSE;
  212. }