WinMain.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: WinMain.cpp //////////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: GUIEdit.cpp
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: GUI Edit and window layout entry point
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  44. #include <stdlib.h>
  45. #include <windows.h>
  46. #include <commctrl.h>
  47. // USER INCLUDES //////////////////////////////////////////////////////////////
  48. #include "Common/Debug.h"
  49. #include "Common/GameMemory.h"
  50. #include "Common/GameEngine.h"
  51. #include "GameClient/GameWindowManager.h"
  52. #include "Win32Device/GameClient/Win32Mouse.h"
  53. #include "Resource.h"
  54. #include "Lib/BaseType.h"
  55. #include "GUIEdit.h"
  56. #include "EditWindow.h"
  57. #include "DialogProc.h"
  58. #include "LayoutScheme.h"
  59. // DEFINES ////////////////////////////////////////////////////////////////////
  60. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  61. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  62. static char *szWindowClass = "GUIEdit";
  63. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  64. HINSTANCE ApplicationHInstance; ///< main application instance
  65. HWND ApplicationHWnd; ///< main application HWnd
  66. Win32Mouse *TheWin32Mouse = NULL; ///< for Win32 mouse
  67. char *gAppPrefix = "ge_"; /// So GuiEdit can have a different debug log file name if we need it
  68. const Char *g_strFile = "data\\Generals.str";
  69. const Char *g_csfFile = "data\\%s\\Generals.csf";
  70. ///////////////////////////////////////////////////////////////////////////////
  71. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  72. ///////////////////////////////////////////////////////////////////////////////
  73. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  74. LRESULT CALLBACK AboutCallback(HWND, UINT, WPARAM, LPARAM);
  75. ///////////////////////////////////////////////////////////////////////////////
  76. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  77. ///////////////////////////////////////////////////////////////////////////////
  78. // initInstance ===============================================================
  79. //
  80. // FUNCTION: initInstance(HANDLE, int)
  81. //
  82. // PURPOSE: Saves instance handle and creates main window
  83. //
  84. // COMMENTS:
  85. //
  86. // In this function, we save the instance handle in a global variable and
  87. // create and display the main program window.
  88. //
  89. //=============================================================================
  90. static BOOL initInstance( HINSTANCE hInstance, int nCmdShow )
  91. {
  92. // store application instance
  93. ApplicationHInstance = hInstance;
  94. // create app window and keep handle
  95. ApplicationHWnd = CreateWindowEx( 0, // extended style
  96. szWindowClass, // window class name
  97. "GUIEdit", // window name
  98. WS_OVERLAPPEDWINDOW, // window styles
  99. 0, // x position
  100. 0, // y position
  101. GetSystemMetrics( SM_CXSCREEN ), // width
  102. GetSystemMetrics( SM_CYSCREEN ), // height
  103. NULL, // parent
  104. NULL, // menu
  105. ApplicationHInstance, // instance
  106. NULL ); // creation data
  107. if( ApplicationHWnd == NULL )
  108. return FALSE;
  109. // display the window
  110. ShowWindow( ApplicationHWnd, SW_MAXIMIZE );
  111. UpdateWindow( ApplicationHWnd );
  112. return TRUE;
  113. } // end initInstance
  114. // registerClass ==============================================================
  115. //
  116. // FUNCTION: registerClass()
  117. //
  118. // PURPOSE: Registers the window class.
  119. //
  120. // COMMENTS:
  121. //
  122. // This function and its usage is only necessary if you want this code
  123. // to be compatible with Win32 systems prior to the 'RegisterClassEx'
  124. // function that was added to Windows 95. It is important to call this function
  125. // so that the application will get 'well formed' small icons associated
  126. // with it.
  127. //
  128. //=============================================================================
  129. static ATOM registerClass(HINSTANCE hInstance)
  130. {
  131. WNDCLASSEX wcex;
  132. wcex.cbSize = sizeof( WNDCLASSEX );
  133. wcex.style = CS_HREDRAW | CS_VREDRAW;
  134. wcex.lpfnWndProc = (WNDPROC)WndProc;
  135. wcex.cbClsExtra = 0;
  136. wcex.cbWndExtra = 0;
  137. wcex.hInstance = hInstance;
  138. wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)GUIEDIT_LARGE_ICON);
  139. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  140. wcex.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
  141. wcex.lpszMenuName = (LPCSTR)GUIEDIT_MENU;
  142. wcex.lpszClassName = szWindowClass;
  143. wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)GUIEDIT_SMALL_ICON);
  144. return RegisterClassEx( &wcex );
  145. } // registerClass
  146. ///////////////////////////////////////////////////////////////////////////////
  147. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  148. ///////////////////////////////////////////////////////////////////////////////
  149. // WinMain ====================================================================
  150. /** Entry point for application */
  151. //=============================================================================
  152. Int APIENTRY WinMain(HINSTANCE hInstance,
  153. HINSTANCE hPrevInstance,
  154. LPSTR lpCmdLine,
  155. int nCmdShow)
  156. {
  157. MSG msg;
  158. Int returnValue;
  159. HACCEL hAccelTable;
  160. Bool quit = FALSE;
  161. /// @todo remove this force set of working directory later
  162. Char buffer[ _MAX_PATH ];
  163. GetModuleFileName( NULL, buffer, sizeof( buffer ) );
  164. Char *pEnd = buffer + strlen( buffer );
  165. while( pEnd != buffer )
  166. {
  167. if( *pEnd == '\\' )
  168. {
  169. *pEnd = 0;
  170. break;
  171. }
  172. pEnd--;
  173. }
  174. ::SetCurrentDirectory(buffer);
  175. // start the log
  176. DEBUG_INIT(DEBUG_FLAGS_DEFAULT);
  177. initMemoryManager();
  178. // register a class for our window with the OS
  179. registerClass( hInstance );
  180. // Perform application initialization:
  181. if( !initInstance( hInstance, nCmdShow ) )
  182. return FALSE;
  183. // load accellerator table
  184. hAccelTable = LoadAccelerators( hInstance, (LPCTSTR)GUIEDIT_ACCELERATORS );
  185. // initialize the common controls
  186. INITCOMMONCONTROLSEX controls;
  187. controls.dwSize = sizeof( controls );
  188. controls.dwICC = ICC_BAR_CLASSES;
  189. InitCommonControlsEx( &controls );
  190. // initialize GUIEdit data
  191. TheEditor = new GUIEdit;
  192. if( TheEditor == NULL )
  193. return FALSE;
  194. TheEditor->init();
  195. //
  196. // see if we have any messages to process, a NULL window handle tells the
  197. // OS to look at the main window associated with the calling thread, us!
  198. //
  199. while( quit == FALSE )
  200. {
  201. // is there is message ready for us?
  202. if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
  203. {
  204. // process ALL messages waiting
  205. while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
  206. {
  207. // get the message
  208. returnValue = GetMessage( &msg, NULL, 0, 0 );
  209. // check for quitting
  210. if( returnValue == 0 )
  211. quit = TRUE;
  212. // translate accelerator messages
  213. if( !TranslateAccelerator( msg.hwnd, hAccelTable, &msg ) )
  214. {
  215. // translate and dispatch the message
  216. TranslateMessage( &msg );
  217. DispatchMessage( &msg );
  218. } // end if
  219. } // end while
  220. } // end if
  221. else
  222. {
  223. // udpate our universe
  224. TheEditor->update();
  225. Sleep(1);
  226. } // end else
  227. } // end while
  228. // shutdown GUIEdit data
  229. delete TheEditor;
  230. TheEditor = NULL;
  231. // close the log
  232. shutdownMemoryManager();
  233. DEBUG_SHUTDOWN();
  234. return msg.wParam;
  235. } // end WinMain
  236. // WndProc ====================================================================
  237. //
  238. // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
  239. //
  240. // PURPOSE: Processes messages for the main window.
  241. //
  242. // WM_COMMAND - process the application menu
  243. // WM_PAINT - Paint the main window
  244. // WM_DESTROY - post a quit message and return
  245. //
  246. //=============================================================================
  247. LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
  248. WPARAM wParam, LPARAM lParam )
  249. {
  250. switch( message )
  251. {
  252. // ------------------------------------------------------------------------
  253. case WM_MOUSEMOVE:
  254. {
  255. // keep focus in our app
  256. if( GetFocus() != hWnd )
  257. SetFocus( hWnd );
  258. return 0;
  259. } // end move mouse
  260. // ------------------------------------------------------------------------
  261. case WM_COMMAND:
  262. {
  263. Int controlID = LOWORD( wParam );
  264. // Int nofifyCode = HIWORD( wParam );
  265. // HWND hWndControl = (HWND)lParam;
  266. switch( controlID )
  267. {
  268. // --------------------------------------------------------------------
  269. case MENU_EXIT:
  270. TheEditor->menuExit();
  271. break;
  272. //---------------------------------------------------------------------
  273. case MENU_NEW:
  274. TheEditor->menuNew();
  275. break;
  276. // --------------------------------------------------------------------
  277. case MENU_OPEN:
  278. TheEditor->menuOpen();
  279. break;
  280. // --------------------------------------------------------------------
  281. case MENU_SAVE:
  282. TheEditor->menuSave();
  283. break;
  284. // --------------------------------------------------------------------
  285. case MENU_SAVEAS:
  286. TheEditor->menuSaveAs();
  287. break;
  288. // --------------------------------------------------------------------
  289. case MENU_COPY:
  290. TheEditor->menuCopy();
  291. break;
  292. // --------------------------------------------------------------------
  293. case MENU_CUT:
  294. TheEditor->menuCut();
  295. break;
  296. // --------------------------------------------------------------------
  297. case MENU_PASTE:
  298. TheEditor->menuPaste();
  299. break;
  300. // --------------------------------------------------------------------
  301. case MENU_CALLBACKS:
  302. DialogBox( TheEditor->getInstance(), (LPCTSTR)CALLBACK_EDITOR_DIALOG,
  303. TheEditor->getWindowHandle(), CallbackEditorDialogProc );
  304. break;
  305. // --------------------------------------------------------------------
  306. case MENU_GRID_SETTINGS:
  307. DialogBox( TheEditor->getInstance(), (LPCTSTR)GRID_SETTINGS_DIALOG,
  308. TheEditor->getWindowHandle(), GridSettingsDialogProc );
  309. break;
  310. // --------------------------------------------------------------------
  311. case MENU_SHOW_HIDDEN_OUTLINES:
  312. TheEditor->setShowHiddenOutlines( !TheEditor->getShowHiddenOutlines() );
  313. break;
  314. // --------------------------------------------------------------------
  315. case MENU_SHOW_SEE_THRU_OUTLINES:
  316. TheEditor->setShowSeeThruOutlines( !TheEditor->getShowSeeThruOutlines() );
  317. break;
  318. // --------------------------------------------------------------------
  319. case MENU_TEST_MODE:
  320. // switch to test mode or edit mode
  321. if( TheEditor)
  322. {
  323. EditMode mode = TheEditor->getMode();
  324. if( mode != MODE_TEST_RUN )
  325. TheEditor->setMode( MODE_TEST_RUN );
  326. else
  327. TheEditor->setMode( MODE_EDIT );
  328. } // end if
  329. break;
  330. // --------------------------------------------------------------------
  331. case MENU_BACKGROUND_COLOR:
  332. if( TheEditWindow )
  333. {
  334. RGBColorReal color = TheEditWindow->getBackgroundColor();
  335. RGBColorInt *newColor;
  336. POINT mouse;
  337. // get mouse point
  338. GetCursorPos( &mouse );
  339. // select a new color
  340. newColor = SelectColor( (Int)(255.0f * color.red),
  341. (Int)(255.0f * color.green),
  342. (Int)(255.0f * color.blue),
  343. (Int)(255.0f * color.alpha),
  344. mouse.x, mouse.y );
  345. if( newColor )
  346. {
  347. color.red = (Real)newColor->red / 255.0f;
  348. color.green = (Real)newColor->green / 255.0f;
  349. color.blue = (Real)newColor->blue / 255.0f;
  350. color.alpha = (Real)newColor->alpha / 255.0f;
  351. TheEditWindow->setBackgroundColor( color );
  352. } // end if
  353. } // end if
  354. break;
  355. // --------------------------------------------------------------------
  356. case MENU_SCHEME:
  357. {
  358. // open the default scheme information
  359. if( TheDefaultScheme )
  360. TheDefaultScheme->openDialog();
  361. break;
  362. } // end scheme
  363. // --------------------------------------------------------------------
  364. case MENU_ABOUT:
  365. {
  366. DialogBox( ApplicationHInstance, (LPCTSTR)ABOUT_DIALOG,
  367. hWnd, (DLGPROC)AboutCallback );
  368. break;
  369. } // end about
  370. // --------------------------------------------------------------------
  371. default:
  372. {
  373. return DefWindowProc( hWnd, message, wParam, lParam );
  374. } // end default
  375. } // end switch( controlID )
  376. return 0;
  377. } // end command
  378. // ------------------------------------------------------------------------
  379. case WM_CLOSE:
  380. {
  381. // close gets initiated from the 'x' in the top right of the window
  382. TheEditor->menuExit();
  383. return 0;
  384. } // end close
  385. // ------------------------------------------------------------------------
  386. case WM_KEYDOWN:
  387. {
  388. Int virtualKey = wParam;
  389. // Int keyData = lParam;
  390. Bool controlDown = BitTest( GetKeyState( VK_CONTROL ), 0x1000 );
  391. switch( virtualKey )
  392. {
  393. // --------------------------------------------------------------------
  394. case VK_ESCAPE:
  395. {
  396. // unselect all windows
  397. if( TheEditor )
  398. if(TheEditor->getMode() == MODE_KEYBOARD_MOVE)
  399. TheEditor->setMode( MODE_EDIT );
  400. else
  401. TheEditor->clearSelections();
  402. break;
  403. } // end escape
  404. // --------------------------------------------------------------------
  405. case VK_DELETE:
  406. {
  407. // delete all selected windows
  408. if( TheEditor )
  409. TheEditor->deleteSelected();
  410. break;
  411. } // end delete
  412. // --------------------------------------------------------------------
  413. case VK_LEFT:
  414. {
  415. // delete all selected windows
  416. if( TheEditor && TheEditWindow)
  417. {
  418. if(TheEditor->getMode() == MODE_EDIT)
  419. {
  420. if(TheEditor->selectionCount() <= 0 )
  421. break;
  422. ICoord2D zero;
  423. zero.x = zero.y = 0;
  424. TheEditWindow->setDragMoveOrigin(&zero);
  425. TheEditWindow->setDragMoveDest(&zero);
  426. TheEditor->setMode(MODE_KEYBOARD_MOVE);
  427. }
  428. if(TheEditor->getMode() == MODE_KEYBOARD_MOVE)
  429. {
  430. ICoord2D temp;
  431. temp = TheEditWindow->getDragMoveDest();
  432. if(!controlDown && TheEditor->isGridSnapOn())
  433. {
  434. temp.x -= TheEditor->getGridResolution();
  435. TheEditor->gridSnapLocation(&temp,&temp);
  436. }
  437. else
  438. {
  439. temp.x--;
  440. }
  441. TheEditWindow->setDragMoveDest(&temp);
  442. }
  443. }
  444. break;
  445. } // end Left
  446. // --------------------------------------------------------------------
  447. case VK_RIGHT:
  448. {
  449. // delete all selected windows
  450. if( TheEditor && TheEditWindow)
  451. {
  452. if(TheEditor->getMode() == MODE_EDIT)
  453. {
  454. if(TheEditor->selectionCount() <= 0 )
  455. break;
  456. ICoord2D zero;
  457. zero.x = zero.y = 0;
  458. TheEditWindow->setDragMoveOrigin(&zero);
  459. TheEditWindow->setDragMoveDest(&zero);
  460. TheEditor->setMode(MODE_KEYBOARD_MOVE);
  461. }
  462. if(TheEditor->getMode() == MODE_KEYBOARD_MOVE)
  463. {
  464. ICoord2D temp;
  465. temp = TheEditWindow->getDragMoveDest();
  466. if(!controlDown && TheEditor->isGridSnapOn())
  467. {
  468. temp.x += TheEditor->getGridResolution();
  469. TheEditor->gridSnapLocation(&temp,&temp);
  470. }
  471. else
  472. {
  473. temp.x++;
  474. }
  475. TheEditWindow->setDragMoveDest(&temp);
  476. }
  477. }
  478. break;
  479. } // end RIGHT
  480. // --------------------------------------------------------------------
  481. case VK_UP:
  482. {
  483. // delete all selected windows
  484. if( TheEditor && TheEditWindow)
  485. {
  486. if(TheEditor->getMode() == MODE_EDIT)
  487. {
  488. if(TheEditor->selectionCount() <= 0 )
  489. break;
  490. ICoord2D zero;
  491. zero.x = zero.y = 0;
  492. TheEditWindow->setDragMoveOrigin(&zero);
  493. TheEditWindow->setDragMoveDest(&zero);
  494. TheEditor->setMode(MODE_KEYBOARD_MOVE);
  495. }
  496. if(TheEditor->getMode() == MODE_KEYBOARD_MOVE)
  497. {
  498. ICoord2D temp;
  499. temp = TheEditWindow->getDragMoveDest();
  500. if(!controlDown && TheEditor->isGridSnapOn())
  501. {
  502. temp.y -= TheEditor->getGridResolution();
  503. TheEditor->gridSnapLocation(&temp,&temp);
  504. }
  505. else
  506. {
  507. temp.y--;
  508. }
  509. TheEditWindow->setDragMoveDest(&temp);
  510. }
  511. }
  512. break;
  513. } // end Up
  514. // --------------------------------------------------------------------
  515. case VK_DOWN:
  516. {
  517. // delete all selected windows
  518. if( TheEditor && TheEditWindow)
  519. {
  520. if(TheEditor->getMode() == MODE_EDIT)
  521. {
  522. if(TheEditor->selectionCount() <= 0 )
  523. break;
  524. ICoord2D zero;
  525. zero.x = zero.y = 0;
  526. TheEditWindow->setDragMoveOrigin(&zero);
  527. TheEditWindow->setDragMoveDest(&zero);
  528. TheEditor->setMode(MODE_KEYBOARD_MOVE);
  529. }
  530. if(TheEditor->getMode() == MODE_KEYBOARD_MOVE)
  531. {
  532. ICoord2D temp;
  533. temp = TheEditWindow->getDragMoveDest();
  534. if(!controlDown && TheEditor->isGridSnapOn())
  535. {
  536. temp.y += TheEditor->getGridResolution();
  537. TheEditor->gridSnapLocation(&temp,&temp);
  538. }
  539. else
  540. {
  541. temp.y++;
  542. }
  543. TheEditWindow->setDragMoveDest(&temp);
  544. }
  545. }
  546. break;
  547. } // end Down
  548. // --------------------------------------------------------------------
  549. case VK_RETURN:
  550. {
  551. if( TheEditor && TheEditWindow && TheEditor->getMode() == MODE_KEYBOARD_MOVE )
  552. {
  553. ICoord2D tempOrigin, tempDest;
  554. tempDest = TheEditWindow->getDragMoveDest();
  555. tempOrigin = TheEditWindow->getDragMoveOrigin();
  556. // move the windows
  557. TheEditor->dragMoveSelectedWindows( &tempOrigin, &tempDest );
  558. // go back to normal mode
  559. TheEditor->setMode( MODE_EDIT );
  560. }
  561. break;
  562. }// end Enter
  563. } // end switch( virtualKey )
  564. return 0;
  565. } // end key down
  566. // ------------------------------------------------------------------------
  567. case WM_SIZE:
  568. {
  569. Int width = LOWORD( lParam );
  570. Int height = HIWORD( lParam );
  571. // resize status bar
  572. if( TheEditor )
  573. {
  574. HWND statusBar = TheEditor->getStatusBarWindowHandle();
  575. if( statusBar )
  576. {
  577. RECT rect;
  578. Int barX, barY;
  579. Int barWidth, barHeight;
  580. // keep status window height the same
  581. GetWindowRect( statusBar, &rect );
  582. barWidth = width;
  583. barHeight = rect.bottom - rect.top;
  584. barX = 0;
  585. barY = height - barHeight;
  586. MoveWindow( statusBar, barX, barY, barWidth, barHeight, TRUE );
  587. } // end if
  588. } // end if
  589. return 0;
  590. } // end size
  591. // ------------------------------------------------------------------------
  592. case WM_PAINT:
  593. {
  594. PAINTSTRUCT ps;
  595. HDC hdc;
  596. hdc = BeginPaint(hWnd, &ps);
  597. EndPaint(hWnd, &ps);
  598. break;
  599. } // end paint
  600. // ------------------------------------------------------------------------
  601. case WM_DESTROY:
  602. {
  603. PostQuitMessage(0);
  604. break;
  605. } // end destroy
  606. // ------------------------------------------------------------------------
  607. default:
  608. {
  609. return DefWindowProc(hWnd, message, wParam, lParam);
  610. } // end default
  611. } // end switch( message )
  612. return DefWindowProc( hWnd, message, wParam, lParam );
  613. } // end WndProc
  614. // AboutCallback ==============================================================
  615. /** Mesage handler for about box. */
  616. //=============================================================================
  617. LRESULT CALLBACK AboutCallback( HWND hDlg, UINT message,
  618. WPARAM wParam, LPARAM lParam )
  619. {
  620. switch (message)
  621. {
  622. case WM_INITDIALOG:
  623. return TRUE;
  624. case WM_COMMAND:
  625. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  626. {
  627. EndDialog(hDlg, LOWORD(wParam));
  628. return TRUE;
  629. }
  630. break;
  631. }
  632. return FALSE;
  633. } // end AboutCallback