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

  1. //----------------------------------------------------------------------------
  2. //  Project ApxDlg
  3. //  Borland International
  4. //  Copyright ⌐ 1996. All Rights Reserved.
  5. //
  6. //  SUBSYSTEM:    ApxDlg Application
  7. //  FILE:         apxdlgap.cpp
  8. //  AUTHOR:
  9. //
  10. //  OVERVIEW
  11. //  ~~~~~~~~
  12. //  Source file for implementation of TApxDlgApp (TApplication).
  13. //
  14. //----------------------------------------------------------------------------
  15.  
  16. #include <owl/pch.h>
  17.  
  18. #include <owl/buttonga.h>
  19. #include <owl/statusba.h>
  20. #include <classlib/cmdline.h>
  21. #include <winsys/registry.h>
  22. #include <stdio.h>
  23.  
  24. #include "apxdlgap.h"
  25. #include "apxdlgdc.h"                        // Definition of client class.
  26.  
  27.  
  28. //{{TApxDlgApp Implementation}}
  29.  
  30.  
  31. //
  32. // Build a response table for all messages/commands handled
  33. // by the application.
  34. //
  35. DEFINE_RESPONSE_TABLE1(TApxDlgApp, TApplication)
  36. //{{TApxDlgAppRSP_TBL_BEGIN}}
  37.   EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
  38. //{{TApxDlgAppRSP_TBL_END}}
  39. END_RESPONSE_TABLE;
  40.  
  41.  
  42. //--------------------------------------------------------
  43. // TApxDlgApp
  44. //
  45. TApxDlgApp::TApxDlgApp() : TApplication("AppExpert Dialog Client Example")
  46. {
  47.  
  48.   // INSERT>> Your constructor code here.
  49. }
  50.  
  51.  
  52. TApxDlgApp::~TApxDlgApp()
  53. {
  54.   // INSERT>> Your destructor code here.
  55. }
  56.  
  57.  
  58. //--------------------------------------------------------
  59. // TApxDlgApp
  60. // ~~~~~
  61. // Application intialization.
  62. //
  63. void TApxDlgApp::InitMainWindow()
  64. {
  65.   if (nCmdShow != SW_HIDE)
  66.     nCmdShow = (nCmdShow != SW_SHOWMINNOACTIVE) ? SW_SHOWNORMAL : nCmdShow;
  67.  
  68.   TSDIDecFrame* frame = new TSDIDecFrame(0, GetName(), 0, true);
  69.   frame->SetFlag(wfShrinkToClient);
  70.  
  71.   // Assign icons for this application.
  72.   //
  73.   frame->SetIcon(this, IDI_SDIAPPLICATION);
  74.   frame->SetIconSm(this, IDI_SDIAPPLICATION);
  75.  
  76.   SetMainWindow(frame);
  77.  
  78. }
  79.  
  80.  
  81. //--------------------------------------------------------
  82. // TApxDlgApp
  83. // ~~~~~
  84. // Application instance initialization.
  85. //
  86. void TApxDlgApp::InitInstance()
  87. {
  88.   TApplication::InitInstance();
  89.  
  90.   ProcessCmdLine(lpCmdLine);
  91. }
  92.  
  93.  
  94. //--------------------------------------------------------
  95. // TApxDlgApp
  96. // ~~~~~
  97. // Process command line parameters.
  98. //
  99. void TApxDlgApp::ProcessCmdLine(char * CmdLine)
  100. {
  101.   TCmdLine cmd(CmdLine);
  102.  
  103.   while (cmd.Kind != TCmdLine::Done) {
  104.     if (cmd.Kind == TCmdLine::Option) {
  105.       if (strnicmp(cmd.Token, "unregister", cmd.TokenLen) == 0) {
  106.         UnRegisterInfo();
  107.         return;
  108.       }
  109.     }
  110.     cmd.NextToken();
  111.   }
  112.  
  113.   RegisterInfo();
  114. }
  115.  
  116.  
  117. //--------------------------------------------------------
  118. // TApxDlgApp
  119. // ~~~~~
  120. // Register application info.
  121. //
  122. void TApxDlgApp::RegisterInfo()
  123. {
  124.   TAPointer<char> buffer = new char[_MAX_PATH];
  125.  
  126.   GetModuleFileName(buffer, _MAX_PATH);
  127.  
  128.   TRegKey(TRegKey::ClassesRoot, "ApxDlg.Application\\DefaultIcon").SetDefValue(0, REG_SZ, buffer, strlen(buffer));
  129.   strcat(buffer, ",1");
  130. }
  131.  
  132.  
  133. //--------------------------------------------------------
  134. // TApxDlgApp
  135. // ~~~~~
  136. // Unregister application info.
  137. //
  138. void TApxDlgApp::UnRegisterInfo()
  139. {
  140.   TAPointer<char> buffer = new char[_MAX_PATH];
  141.  
  142.   GetModuleFileName(buffer, _MAX_PATH);
  143.  
  144.   TRegKey(TRegKey::ClassesRoot, "ApxDlg.Application").DeleteKey("DefaultIcon");
  145.   TRegKey(TRegKey::ClassesRoot, "ApxDlg.Document.1").DeleteKey("DefaultIcon");
  146.  
  147.   TRegKey::ClassesRoot.DeleteKey("ApxDlg.Application");
  148. }
  149.  
  150.  
  151.  
  152. //{{TSDIDecFrame Implementation}}
  153.  
  154.  
  155. TSDIDecFrame::TSDIDecFrame(TWindow* parent, const char far* title, TWindow* clientWnd, bool trackMenuSelection, TModule* module)
  156. :
  157.   TDecoratedFrame(parent, title, !clientWnd ? new TApxDlgDlgClient(0) : clientWnd, trackMenuSelection, module)
  158. {
  159.   // INSERT>> Your constructor code here.
  160.  
  161. }
  162.  
  163.  
  164. TSDIDecFrame::~TSDIDecFrame()
  165. {
  166.   // INSERT>> Your destructor code here.
  167.  
  168. }
  169.  
  170.  
  171. void TSDIDecFrame::SetupWindow()
  172. {
  173.   TDecoratedFrame::SetupWindow();
  174.   TRect  r;
  175.   GetWindowRect(r);
  176.  
  177.   r.bottom += 30;
  178.   SetWindowPos(0, r, SWP_NOZORDER | SWP_NOMOVE);
  179.  
  180.   // INSERT>> Your code here.
  181.  
  182. }
  183.  
  184.  
  185. //--------------------------------------------------------
  186. // TApxDlgApp
  187. // ~~~~~~~~~~~
  188. // Menu Help About ApxDlg command
  189. //
  190. void TApxDlgApp::CmHelpAbout()
  191. {
  192. }
  193.  
  194.  
  195.  
  196. int OwlMain(int , char* [])
  197. {
  198.   TApxDlgApp   app;
  199.   return app.Run();
  200. }
  201.