home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / APPEXPRT.PAK / MAIN.OWL < prev    next >
Encoding:
Text File  |  1997-05-06  |  5.6 KB  |  177 lines

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