home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / SHELL.PAK / SHELLAPP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.4 KB  |  147 lines

  1. //----------------------------------------------------------------------------
  2. //  Project Shell
  3. //  Borland International
  4. //  Copyright ⌐ 1995, 1996 Borland International. All Rights Reserved.
  5. //
  6. //  SUBSYSTEM:    shell.exe Application
  7. //  FILE:         shellapp.cpp
  8. //  AUTHOR:       The OWL Team
  9. //
  10. //  OVERVIEW
  11. //  ~~~~~~~~
  12. //  Source file for implementation of TShellApp (TApplication).
  13. //
  14. //----------------------------------------------------------------------------
  15.  
  16. #include <owl/pch.h>
  17.  
  18. #include <owl/controlb.h>
  19. #include <owl/buttonga.h>
  20. #include <owl/statusba.h>
  21.  
  22. #include "shellapp.h"
  23. #include "mdiclien.h"
  24. #include "aboutdlg.h"                        // Definition of about dialog.
  25.  
  26. //{{TShellApp Implementation}}
  27.  
  28. //
  29. // Build a response table for all messages/commands handled by the application.
  30. //
  31. DEFINE_RESPONSE_TABLE1(TShellApp, TApplication)
  32. //{{ShellAppRSP_TBL_BEGIN}}
  33.   EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
  34. //{{ShellAppRSP_TBL_END}}
  35. END_RESPONSE_TABLE;
  36.  
  37.  
  38. //--------------------------------------------------------
  39. // TShellApp
  40. // ~~~~~
  41. //
  42. TShellApp::TShellApp() : TApplication("OWL Win 95 Shell Classes Sample Application")
  43. {
  44.   CoInitialize(0);
  45. }
  46.  
  47.  
  48. TShellApp::~TShellApp()
  49. {
  50.   CoUninitialize();
  51. }
  52.  
  53.  
  54. bool TShellApp::CanClose()
  55. {
  56.   bool result = TApplication::CanClose();
  57.  
  58.   return result;
  59. }
  60.  
  61.  
  62. void TShellApp::SetupSpeedBar(TDecoratedMDIFrame* frame)
  63. {
  64.   // Create default toolbar New and associate toolbar buttons with commands.
  65.   //
  66.   TControlBar* cb = new TControlBar(frame);
  67.   cb->Insert(*new TButtonGadget(CM_MDIFILENEW, CM_MDIFILENEW));
  68.  
  69.   // Add fly-over help hints.
  70.   //
  71.   cb->SetHintMode(TGadgetWindow::EnterHints);
  72.  
  73.   frame->Insert(*cb, TDecoratedFrame::Top);
  74. }
  75.  
  76.  
  77. //--------------------------------------------------------
  78. // TShellApp
  79. // ~~~~~
  80. // Application intialization.
  81. //
  82. void TShellApp::InitMainWindow()
  83. {
  84.   if (nCmdShow != SW_HIDE)
  85.     nCmdShow = (nCmdShow != SW_SHOWMINNOACTIVE) ? SW_SHOWNORMAL : nCmdShow;
  86.  
  87.   MdiClient = new TShellMDIClient;
  88.   TDecoratedMDIFrame* frame = new TDecoratedMDIFrame(Name, IDM_MDI, *MdiClient, true);
  89.  
  90.   // Assign ICON w/ this application.
  91.   //
  92.   frame->SetIcon(0, IDI_WINLOGO);
  93.  
  94.   // Associate with the accelerator table.
  95.   //
  96.   frame->Attr.AccelTable = IDM_MDI;
  97.  
  98.   SetupSpeedBar(frame);
  99.  
  100.   TStatusBar* sb = new TStatusBar(frame, TGadget::Recessed,
  101.                                   TStatusBar::CapsLock        |
  102.                                   TStatusBar::NumLock         |
  103.                                   TStatusBar::ScrollLock);
  104.   frame->Insert(*sb, TDecoratedFrame::Bottom);
  105.   SetMainWindow(frame);
  106.  
  107.   frame->SetMenuDescr(TMenuDescr(IDM_MDI));
  108.  
  109.   // Windows 3-D controls.
  110.   //
  111.   EnableCtl3d(true);
  112. }
  113.  
  114.  
  115. // Response Table handlers:
  116. //
  117.  
  118.  
  119. // Menu Help About command
  120. void TShellApp::CmHelpAbout()
  121. {
  122.   TShellAboutDlg(&TWindow(::GetFocus(), this)).Execute();
  123. }
  124.  
  125.  
  126. //
  127. // Process application messages to provide context sensitive help
  128. //
  129. bool TShellApp::ProcessAppMsg(MSG& msg)
  130. {
  131.   return TApplication::ProcessAppMsg(msg);
  132. }
  133.  
  134. int OwlMain(int , char* [])
  135. {
  136.   if (TSystem::GetMajorVersion() < 4) {
  137.     ::MessageBox(0, "Windows 4.0 (or greater) is required to run this example.",
  138.                "OWL Shell Example", MB_OK | MB_ICONEXCLAMATION);
  139.     return 0;
  140.   }
  141.   else {
  142.     TShellApp   app;
  143.     return app.Run();
  144.   }
  145. }
  146.  
  147.