home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / EXPERT.PAK / MAIN.OWL < prev    next >
Text File  |  1995-08-29  |  7KB  |  173 lines

  1. ##--BEGIN-- @OPT_APPL_HELP 
  2.  
  3.  
  4. bool [[TApplication]]::ProcessAppMsg (MSG& msg)
  5. {
  6.     if (msg.message == WM_COMMAND) {
  7.         if (ContextHelp || (::GetKeyState(VK_F1) < 0)) {
  8.             ContextHelp = false;
  9.             GetMainWindow()->WinHelp(HelpFileName, HELP_CONTEXT, msg.wParam);
  10.             return true;
  11.         }
  12.     } else
  13.         switch (msg.message) {
  14.         case WM_KEYDOWN:
  15.             if (msg.wParam == VK_F1) {
  16. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  17.                 // If the Shift/F1 then set the help cursor and turn on the modal help state.
  18.                 if (::GetKeyState(VK_SHIFT) < 0) {
  19.                     ContextHelp = true;
  20.                     HelpCursor = ::LoadCursor(GetMainWindow()->GetModule()->GetInstance(), MAKEINTRESOURCE(IDC_HELPCURSOR));
  21.                     ::SetCursor(HelpCursor);
  22.                     return true;        // Gobble up the message.
  23.                 } else {
  24. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  25.                     // If F1 w/o the Shift key then bring up help's main index.
  26.                     GetMainWindow()->WinHelp(HelpFileName, HELP_INDEX, 0L);
  27.                     return true;        // Gobble up the message.
  28.                 }
  29.             } else {
  30.                 if (ContextHelp && (msg.wParam == VK_ESCAPE)) {
  31.                     if (HelpCursor)
  32.                         ::DestroyCursor(HelpCursor);
  33.                     ContextHelp = false;
  34.                     HelpCursor = 0;
  35.                     GetMainWindow()->SetCursor(0, IDC_ARROW);
  36.                     return true;    // Gobble up the message.
  37.                 }
  38.             }
  39.             break;
  40.  
  41.         case WM_MOUSEMOVE:
  42.         case WM_NCMOUSEMOVE:
  43.             if (ContextHelp) {
  44.                 ::SetCursor(HelpCursor);
  45.                 return true;        // Gobble up the message.
  46.             }
  47.             break;
  48.  
  49.         case WM_INITMENU:
  50.             if (ContextHelp) {
  51.                 ::SetCursor(HelpCursor);
  52.                 return true;        // Gobble up the message.
  53.             }
  54.             break;
  55.         
  56.         case WM_ENTERIDLE:
  57.             if (msg.wParam == MSGF_MENU)
  58.                 if (GetKeyState(VK_F1) < 0) {
  59.                     ContextHelp = true;
  60.                     GetMainWindow()->PostMessage(WM_KEYDOWN, VK_RETURN, 0L);
  61.                     return true;       // Gobble up the message.
  62.                 }
  63.             break;
  64.         
  65.         default:
  66.             ;
  67.         };  // End of switch
  68.  
  69.     // Continue normal processing.
  70.  
  71.     return TApplication::ProcessAppMsg(msg);
  72. }
  73.  
  74.  
  75. ##--END-- @OPT_APPL_HELP
  76. ##--BEGIN-- @OPT_APPL_PRINTING 
  77. void [[TApplication]]::EvWinIniChange (char far* section)
  78. {
  79.     if (strcmp(section, "windows") == 0) {
  80. ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  81.         // If the device changed in the WIN.INI file then the printer
  82.         // might have changed.  If we have a TPrinter (Printer) then
  83.         // check and make sure it's identical to the current device
  84.         // entry in WIN.INI.
  85. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  86.         if (Printer) {
  87.             char printDBuffer[255];
  88.             LPSTR printDevice = printDBuffer;
  89.             LPSTR devName;
  90.             LPSTR driverName = 0;
  91.             LPSTR outputName = 0;
  92.         
  93.             if (::GetProfileString("windows", "device", "", printDevice, sizeof(printDevice))) {
  94. ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  95.                 // The string which should come back is something like:
  96.                 //
  97.                 //      HP LaserJet III,hppcl5a,LPT1:
  98.                 //
  99.                 // Where the format is:
  100.                 //
  101.                 //      devName,driverName,outputName
  102.                 //
  103. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  104.                 devName = printDevice;
  105.                 while (*printDevice) {
  106.                     if (*printDevice == ',') {
  107.                         *printDevice++ = 0;
  108.                         if (!driverName)
  109.                             driverName = printDevice;
  110.                         else
  111.                             outputName = printDevice;
  112.                     } else
  113.                         printDevice = ::AnsiNext(printDevice);
  114.                 }
  115.  
  116.                 if ((Printer->GetSetup().Error != 0)                                ||
  117.                     (strcmp(devName, Printer->GetSetup().GetDeviceName()) != 0)    ||
  118.                     (strcmp(driverName, Printer->GetSetup().GetDriverName()) != 0) ||
  119.                     (strcmp(outputName, Printer->GetSetup().GetOutputName()) != 0)) {
  120.                 
  121.                     // New printer installed so get the new printer device now.
  122.                     delete Printer;
  123.                     Printer = new TPrinter(this);
  124.                 }
  125.             } else {
  126.                 // No printer installed (GetProfileString failed).
  127.                 delete Printer;
  128.                 Printer = new TPrinter(this);
  129.             }
  130.         }
  131.     }
  132. }
  133.  
  134.  
  135. ##--END-- @OPT_APPL_PRINTING 
  136. int OwlMain (int , char* [])
  137. {
  138.     try {
  139. ##--BEGIN-- @QUERY_APPL_OLE != VALUE_NOOLE
  140. ##      :!@QUERY_APPL_OLE_AUTO 2
  141.         ::Registrar = new TOcRegistrar(::ApplicationReg, TOleDocViewFactory<[[TApplication]]>(), TApplication::GetCmdLine(), ::DocTemplateStaticHead);
  142.         if (::Registrar->IsOptionSet(amAnyRegOption))
  143. ##      :@QUERY_APPL_OLE_AUTO 2
  144.         ::Registrar = new TOcRegistrar(::ApplicationReg, TOleDocViewAutoFactory<[[TApplication]]>(), TApplication::GetCmdLine(), ::DocTemplateStaticHead);
  145.         if (::Registrar->IsOptionSet(amAnyRegOption))
  146.             return 0;
  147.  
  148.         // If this is an exe server normal run, run the app now. Otherwise, wait
  149.         // until our factory gets a call.
  150.         return ::Registrar->Run();
  151. ##--END-- @QUERY_APPL_OLE != VALUE_NOOLE
  152. ##--BEGIN-- @QUERY_APPL_OLE == VALUE_NOOLE
  153. ##      :!@QUERY_APPL_OLE_AUTO 2
  154.         [[TApplication]]    app;
  155.         return app.Run();
  156. ##      --BEGIN-- @QUERY_APPL_OLE_AUTO
  157.         ::Registrar = new TRegistrar(::ApplicationReg, TAutoFactory<[[TApplication]]>(), TApplication::GetCmdLine(), _hInstance);
  158.         if (::Registrar->IsOptionSet(amAnyRegOption))
  159.             return 0;
  160.  
  161.         // If this is an exe server normal run, run the app now. Otherwise, wait
  162.         // until our factory gets a call.
  163.         return ::Registrar->Run();
  164. ##      --END-- @QUERY_APPL_OLE_AUTO
  165. ##--END-- @QUERY_APPL_OLE == VALUE_NOOLE
  166.     }
  167.     catch (xmsg& x) {
  168.         ::MessageBox(0, x.why().c_str(), "Exception", MB_OK);
  169.     }
  170.  
  171.     return -1;
  172. }
  173.