home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ACCHELP.ZIP / ACCHELP.CPP next >
Encoding:
C/C++ Source or Header  |  1992-05-28  |  2.5 KB  |  106 lines

  1. #include <owl.h>
  2.  
  3. #include "acchelpm.h"
  4. #include "acchelpr.h"
  5.  
  6. #include "acchelp.h"
  7.  
  8. TOWLHELPApp::TOWLHELPApp( LPSTR lpszNam, HANDLE hInst, HANDLE hPrevInst, LPSTR lpszCmdLn, int nCmdShw )
  9.     : TApplication( lpszNam, hInst, hPrevInst, lpszCmdLn, nCmdShw )
  10. {
  11. }
  12.  
  13. void TOWLHELPApp::InitInstance()
  14. {
  15.     TApplication::InitInstance();
  16.     HAccTable = LoadAccelerators( hInstance, MAKEINTRESOURCE( OWLHELPAPACCEL ) );
  17. }
  18.  
  19. void TOWLHELPApp::InitMainWindow()
  20. {
  21.     MainWindow = new TOWLHELPWnd( NULL, "OWL Help Example" );
  22. }
  23.  
  24. TOWLHELPWnd::TOWLHELPWnd( PTWindowsObject AParent, LPSTR ATitle )
  25.     : TWindow( AParent, ATitle )
  26. {
  27. }
  28.  
  29. LPSTR lpszClientAreaText = "The accelerator is SHIFT-F1 ";
  30.  
  31. void TOWLHELPWnd::Paint( HDC hdc, PAINTSTRUCT _FAR &)
  32. {
  33.     RECT rectClient;
  34.     GetClientRect( HWindow , &rectClient );
  35.  
  36.     int nWidth = rectClient.right;        // rectClient.left is 0
  37.     int nHeight = rectClient.bottom;    // rectClient.top is 0
  38.  
  39.     rectClient.left += (nWidth / 4);
  40.     rectClient.top  += (nHeight / 4);
  41.     rectClient.right -= (nWidth / 4);
  42.  
  43.     SetBkMode( hdc, TRANSPARENT );
  44.     DrawText( hdc, lpszClientAreaText, lstrlen( lpszClientAreaText ),
  45.         &rectClient, DT_CENTER | DT_VCENTER | DT_WORDBREAK );
  46. }
  47.  
  48. void TOWLHELPWnd::GetWindowClass( WNDCLASS &AWndClass )
  49. {
  50.     TWindow::GetWindowClass( AWndClass );
  51.     AWndClass.lpszMenuName = MAKEINTRESOURCE( OWLHELPAPMENU );
  52. }
  53.  
  54. LPSTR TOWLHELPWnd::GetClassName()
  55. {
  56.     return "TOWLHELPWnd";
  57. }
  58.  
  59. void TOWLHELPWnd::SetupWindow()
  60. {
  61. }
  62.  
  63. void TOWLHELPWnd::WMEnterIdle( RTMessage Msg )
  64. {
  65.     if( (Msg.WParam == MSGF_MENU ) && ((GetKeyState( VK_F1 ) & 0x8000) != 0) )
  66.         // if the high bit is set, then the key is pressed
  67.     {
  68.         PostMessage( HWindow, WM_KEYDOWN, VK_RETURN, 0L );
  69.     }
  70. }
  71.  
  72. void TOWLHELPWnd::CMUMenuItemA( RTMessage )
  73. {
  74.     MessageBox( HWindow, "In Menu Item A command", Title, MB_ICONINFORMATION );
  75. }
  76.  
  77. void TOWLHELPWnd::CMUMenuItemB( RTMessage )
  78. {
  79.     MessageBox( HWindow, "In Menu Item B Command", Title, MB_ICONINFORMATION );
  80. }
  81.  
  82. void TOWLHELPWnd::CMExit( RTMessage Msg )
  83. {
  84.     TWindow::CMExit( Msg );
  85. }
  86.  
  87. void TOWLHELPWnd::CMUHelpHelp( RTMessage )
  88. {
  89.     MessageBox( HWindow, "SHIFT-F1 was pressed!","AccHelp", MB_ICONINFORMATION );
  90. }
  91.  
  92. void TOWLHELPWnd::CMUHelpAbout( RTMessage )
  93. {
  94.     MessageBox( HWindow, "Written using ObjectWindows\n",
  95.                 "About ACCHELP", MB_ICONINFORMATION );
  96. }
  97.  
  98. int PASCAL WinMain( HANDLE hInst, HANDLE hPrevInst, LPSTR lpszCmdLn, int nCmdShw )
  99. {
  100.     TOWLHELPApp App( "OWLHELPAP", hInst, hPrevInst, lpszCmdLn, nCmdShw );
  101.  
  102.     App.Run();
  103.     return App.Status;
  104. }
  105.  
  106.