home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / GPF.ZIP / SAMPLE.SRC / SOURCES.ZIP / SAMPLE.SQC < prev    next >
Text File  |  1991-04-02  |  180KB  |  4,469 lines

  1. /********     Sample C Program Source Code File (.Sqc)           ********/
  2. /*                                      */
  3. /* PROGRAM NAME: Sample       Application (Sample)              */
  4. /* -------------                              */
  5. /* Generated by GPF (Gui Programming Facility)                  */
  6. /*                                      */
  7. /* DATABASE NAME: SAMPLE                          */
  8. /* -------------                              */
  9. /*                                      */
  10. /* DATE AND TIME: Tue Apr 02 17:42:44 1991                  */
  11. /*                                      */
  12. /* Presentation Manager                           */
  13. /*                                      */
  14. /* COPYRIGHT:                                  */
  15. /* ----------                                  */
  16. /* (C) Copyright  Jean Bernard CLERIN                      */
  17. /*                                      */
  18. /* REVISION LEVEL: 1.1                              */
  19. /* ---------------                              */
  20. /*                                      */
  21. /* WHAT YOU NEED TO COMPILE THIS PROGRAM:                  */
  22. /* --------------------------------------                  */
  23. /*                                      */
  24. /*  REQUIRED FILES:                              */
  25. /*  ---------------                              */
  26. /*                                      */
  27. /*    Sample.C         - Source code                      */
  28. /*    Sample.Cmd     - Command file to build this program          */
  29. /*    Sample.Mak     - Make file for this program              */
  30. /*    Sample.Def     - Module definition file                  */
  31. /*    Sample.Ext     - External definition file               */
  32. /*    Sample.Ids     - Pm header file                      */
  33. /*    Sample.L         - Linker automatic response file              */
  34. /*    Sample.Rc      - Resource file                      */
  35. /*                                      */
  36. /*    OS2.H         - Presentation Manager include file          */
  37. /*    STDLIB.H         - Miscellaneous function declarations          */
  38. /*    STDIO.H         - Declarations for standard I/O routines          */
  39. /*    STRING.H         - String function declarations              */
  40. /*    MEMORY.H         - Declarations for buffer (memory) manipulation  */
  41. /*    MALLOC.H         - Definitions for memory allocation functions    */
  42. /*    PROCESS.H      - Definitions for process control functions      */
  43. /*                                      */
  44. /*  REQUIRED LIBRARIES:                           */
  45. /*  -------------------                           */
  46. /*                                      */
  47. /*    OS2.LIB         - Presentation  Manager/OS2 library          */
  48. /*    LLIBCMT.LIB    - Protect mode/standard combined large model C   */
  49. /*               library multi-threaded.                  */
  50. /*                                      */
  51. /*  REQUIRED PROGRAMS:                              */
  52. /*  ------------------                              */
  53. /*                                      */
  54. /*    IBM C Compiler                              */
  55. /*    IBM Linker                              */
  56. /*    Resource Compiler                           */
  57. /*                                      */
  58. /**********************************************************************/
  59.  
  60. /**********************************************************************/
  61. /*                                      */
  62. /* Include relevant sections of the PM header file.              */
  63. /*                                      */
  64. /**********************************************************************/
  65.  
  66. /*====================================================================*/
  67. /*                                      */
  68. /*   #define:             To include:                  */
  69. /*                                      */
  70. /* + INCL_WINWINDOWMGR         General window management              */
  71. /* + INCL_WINMESSAGEMGR      Message management               */
  72. /* + INCL_WININPUT         Mouse and keyboard input              */
  73. /* + INCL_WINDIALOGS         Dialog boxes                  */
  74. /* + INCL_WINSTATICS         Static controls                  */
  75. /* + INCL_WINBUTTONS         Button controls                  */
  76. /* + INCL_WINENTRYFIELDS     Entry Fields                  */
  77. /*   INCL_WINMLE         Multiple Line Entry Fields           */
  78. /* + INCL_WINLISTBOXES         List box controls                  */
  79. /* + INCL_WINMENUS         Menu controls                  */
  80. /* + INCL_WINSCROLLBARS      Scroll bar controls              */
  81. /* + INCL_WINFRAMEMGR         Frame manager                  */
  82. /*   INCL_WINFRAMECTLS         Frame controls (title bars & size border)*/
  83. /*   INCL_WINRECTANGLES      Rectangle routines               */
  84. /*   INCL_WINSYS         System values (and colors)           */
  85. /*   INCL_WINTIMER         Timer routines                  */
  86. /* + INCL_WINACCELERATORS    Keyboard accelerators              */
  87. /*   INCL_WINTRACKRECT         WinTrackRect() function              */
  88. /*   INCL_WINCLIPBOARD         Clipboard manager                  */
  89. /* + INCL_WINCURSORS         Text cursors                  */
  90. /* + INCL_WINPOINTERS         Mouse pointers                  */
  91. /*   INCL_WINHOOKS         Hook manager                  */
  92. /* + INCL_WINSWITCHLIST      Shell Switch List API              */
  93. /*   INCL_WINPROGRAMLIST     Shell Program List API              */
  94. /*   INCL_WINSHELLDATA         Shell Data (?)                  */
  95. /*   INCL_WINCOUNTRY         Country support                  */
  96. /*   INCL_WINHEAP         Heap Manager                  */
  97. /*   INCL_WINATOM         Atom Manager                  */
  98. /*   INCL_WINCATCHTHROW      WinCatch/WinThrow support              */
  99. /*   INCL_WINERRORS         Error code definitions              */
  100. /*   INCL_NLS             DBCS window manager definition          */
  101. /* + INCL_WINHELP         Help Manager definitions              */
  102. /*   INCL_WINSEI         Set Error Info API               */
  103. /*   INCL_WINLOAD         Load/Delete Library/Procedure          */
  104. /*   INCL_WINTYPES         Definitions for Datatypes              */
  105. /*                                      */
  106. /* ===================================================================*/
  107. /*                                      */
  108. /* INCL_GPI           Include all of the GPI              */
  109. /* INCL_GPICONTROL       Basic PS control                  */
  110. /* INCL_GPICORRELATION       Picking, Boundary and Correlation          */
  111. /* INCL_GPISEGMENTS       Segment Control and Drawing              */
  112. /* INCL_GPISEGEDITING       Segment Editing via Elements           */
  113. /* INCL_GPITRANSFORMS       Transform and Transform Conversion          */
  114. /* INCL_GPIPATHS       Paths and Clipping with Paths          */
  115. /* INCL_GPILOGCOLORTABLE   Logical Color Tables               */
  116. /* INCL_GPIPRIMITIVES       Drawing Primitives and Primitive Attributes*/
  117. /* INCL_GPILCIDS       Phyical and Logical Fonts with Lcids       */
  118. /* INCL_GPIBITMAPS       Bitmaps and Pel Operations              */
  119. /* INCL_GPIREGIONS       Regions and Clipping with Regions          */
  120. /* INCL_GPIMETAFILES       Metafiles                      */
  121. /* INCL_GPIDEFAULTS       Default Primitive Attributes           */
  122. /* INCL_GPIERRORS       defined if INCL_ERRORS defined          */
  123. /*                                      */
  124. /**********************************************************************/
  125.  
  126. #define INCL_DOS        /*   Need DOS support              */
  127. #define INCL_DOSERRORS
  128.  
  129. #define INCL_WINWINDOWMGR    /*   General window management          */
  130. #define INCL_WINMESSAGEMGR    /*   Message management           */
  131. #define INCL_WININPUT        /*   Mouse and keyboard input          */
  132. #define INCL_WINDIALOGS     /*   Dialog boxes              */
  133. #define INCL_WINSTATICS     /*   Static controls              */
  134. #define INCL_WINBUTTONS     /*   Button controls              */
  135. #define INCL_WINENTRYFIELDS    /*   Entry Fields              */
  136. #define INCL_WINMLE        /*   Multiple Line Entry Fields       */
  137. #define INCL_WINLISTBOXES    /*   List box controls              */
  138. #define INCL_WINMENUS        /*   Menu controls              */
  139. #define INCL_WINSCROLLBARS    /*   Scroll bar controls          */
  140. #define INCL_WINFRAMEMGR    /*   Frame manager              */
  141. #define INCL_WINRECTANGLES    /*   Rectangle routines           */
  142. #define INCL_WINSYS        /*   System values (and colors)       */
  143. #define INCL_WINACCELERATORS    /*   Keyboard accelerators          */
  144. #define INCL_WINCLIPBOARD    /*   Clipboard manager              */
  145. #define INCL_WINCURSORS     /*   Text cursors              */
  146. #define INCL_WINPOINTERS    /*   Mouse pointers              */
  147. #define INCL_WINSWITCHLIST    /*   Shell Switch List API          */
  148. #define INCL_WINPROGRAMLIST    /*   Shell Program List API          */
  149. #define INCL_WINSHELLDATA    /*   Shell Data (?)              */
  150. #define INCL_WINERRORS        /*   Error code definitions          */
  151. #define INCL_WINHELP        /*   Help Manager definitions          */
  152. #define INCL_WINHEAP        /*   Heap Manager              */
  153. #define INCL_WINTIMER        /*   Timer routines              */
  154.  
  155. #define INCL_GPIPRIMITIVES    /*   Drawing Primitives and Attributes*/
  156. #define INCL_GPILCIDS        /*   Phyical and Logical Fonts Lcids  */
  157.  
  158. #include <os2.h>        /* Presentation Manager include file  */
  159.  
  160. /**********************************************************************/
  161. /*                                      */
  162. /* Include C library routine header files                  */
  163. /*                                      */
  164. /**********************************************************************/
  165.  
  166. #include <stdlib.h>     /* Miscellaneous function declarations       */
  167. #include <stdio.h>     /* Declarations for standard I/O routines    */
  168. #include <string.h>     /* String function declarations          */
  169. #include <memory.h>     /* Declarations for memory manipulation      */
  170. #include <malloc.h>     /* Definitions for memory allocation          */
  171. #include <process.h>     /* Definitions for process control functions */
  172.  
  173. /**********************************************************************/
  174. /*                                      */
  175. /* Include Sql library routine header files                  */
  176. /*                                      */
  177. /**********************************************************************/
  178. #include <sqlenv.h>
  179. #include <sql.h>
  180. #include <sqlca.h>
  181.  
  182. /**********************************************************************/
  183. /*                                      */
  184. /* Define GPFPARMS (Gpf Parameters)                      */
  185. /*                                      */
  186. /**********************************************************************/
  187.  
  188. #include "GpfParms.h"              /* Definitions for GpfParms */
  189.  
  190. /**********************************************************************/
  191. /*                                      */
  192. /*  Miscellaneous constants                          */
  193. /*                                      */
  194. /**********************************************************************/
  195.  
  196. #define EXTRAWORDS (4 * sizeof(PVOID))    /* Extra window words          */
  197. #define GPF_PMC_LEVEL 1         /* GpfPmc.lib Level          */
  198. #define COMMAND       0 /* Process commands received from the user    */
  199. #define EXTERN        
  200. #define STACKSIZE (1024*8)
  201.  
  202. /**********************************************************************/
  203. /*                                      */
  204. /* Miscellaneous constants Ids                          */
  205. /*                                      */
  206. /**********************************************************************/
  207.  
  208. #include "Sample.Ids"    
  209.  
  210. /**********************************************************************/
  211. /*                                      */
  212. /* Function prototypes for private C functions                  */
  213. /*                                      */
  214. /**********************************************************************/
  215.  
  216. #include "Sample.Ext"    
  217.  
  218. /**********************************************************************/
  219. /*                                      */
  220. /* STATIC Function prototypes for private C functions              */
  221. /*                                      */
  222. /**********************************************************************/
  223.  
  224. static VOID ActionMenuExit( PGPFPARMS pGpfParms );
  225. static VOID ActionListDep( PGPFPARMS pGpfParms );
  226. static VOID ActionOrgList( PGPFPARMS pGpfParms );
  227. static VOID ActionMsgInfo( PGPFPARMS pGpfParms );
  228. static VOID ActionMsg1( PGPFPARMS pGpfParms );
  229. static VOID ActionMsg2( PGPFPARMS pGpfParms );
  230. static VOID ActionMsg3( PGPFPARMS pGpfParms );
  231. static VOID ActionMsg4( PGPFPARMS pGpfParms );
  232. static VOID ActionMsg5( PGPFPARMS pGpfParms );
  233. static VOID ActionPullDownMark( PGPFPARMS pGpfParms );
  234. static VOID ActionPullDownUnMark( PGPFPARMS pGpfParms );
  235. static VOID ActionPullDownSwap( PGPFPARMS pGpfParms );
  236. static VOID ActionForHelp( PGPFPARMS pGpfParms );
  237. static VOID ActionExHelp( PGPFPARMS pGpfParms );
  238. static VOID ActionKeysHelp( PGPFPARMS pGpfParms );
  239. static VOID ActionIndxHelp( PGPFPARMS pGpfParms );
  240. static VOID ActionContHelp( PGPFPARMS pGpfParms );
  241. static VOID ActionAbout( PGPFPARMS pGpfParms );
  242. static VOID ActionExecExit( PGPFPARMS pGpfParms );
  243. static VOID ActionAbout3( PGPFPARMS pGpfParms );
  244. static VOID ActionAboutMenuBitMap( PGPFPARMS pGpfParms );
  245. static VOID WmInitWndMainWindow( PGPFPARMS pGpfParms );
  246. static VOID WmActiveMainWindow( PGPFPARMS pGpfParms );
  247. static VOID WmDeActiveMainWindow( PGPFPARMS pGpfParms );
  248. static VOID WmCreateMainWindow( PGPFPARMS pGpfParms );
  249. static VOID WmDestroyMainWindow( PGPFPARMS pGpfParms );
  250. static VOID WmPaintMainWindow( PGPFPARMS pGpfParms );
  251. static VOID WmShowMainWindow( PGPFPARMS pGpfParms );
  252. static VOID WmHideMainWindow( PGPFPARMS pGpfParms );
  253. static VOID CommandMainWindow( PGPFPARMS pGpfParms );
  254. static VOID ActionListBox( PGPFPARMS pGpfParms );
  255. static VOID ActionItalic( PGPFPARMS pGpfParms );
  256. static VOID ActionBold( PGPFPARMS pGpfParms );
  257. static VOID ActionUserButton( PGPFPARMS pGpfParms );
  258. static VOID ActionButtonStaff( PGPFPARMS pGpfParms );
  259. static VOID ActionShowStaf( PGPFPARMS pGpfParms );
  260. static VOID ActionCancel( PGPFPARMS pGpfParms );
  261. static VOID ActionButtonHelp( PGPFPARMS pGpfParms );
  262. static VOID WmInitWndListStaffWindow( PGPFPARMS pGpfParms );
  263. static VOID WmActiveListStaffWindow( PGPFPARMS pGpfParms );
  264. static VOID WmDeActiveListStaffWindow( PGPFPARMS pGpfParms );
  265. static VOID WmCreateListStaffWindow( PGPFPARMS pGpfParms );
  266. static VOID WmDestroyListStaffWindow( PGPFPARMS pGpfParms );
  267. static VOID WmPaintListStaffWindow( PGPFPARMS pGpfParms );
  268. static VOID WmShowListStaffWindow( PGPFPARMS pGpfParms );
  269. static VOID WmHideListStaffWindow( PGPFPARMS pGpfParms );
  270. static VOID CommandListStaffWindow( PGPFPARMS pGpfParms );
  271. static VOID InitializeApplication( VOID );
  272. static VOID EndApplication( VOID );
  273.  
  274. /*---------------------- Sql thread commands -------------------------*/
  275.  
  276. #define SQLEXEC     (WM_USER+1)  /* Execute SQL              */
  277. #define SQLEND        (WM_USER+2)  /* Execute SQL END (Return Code) */
  278. #define SQLCLOSE    (WM_USER+3)  /* Close SQL Terminate thread    */
  279.  
  280. #define FOREVER     1
  281.  
  282. HAB  habSqlThread;             /* Sqlthread anchor block handle */
  283. HMQ  hmqSqlThread;             /* SqlThread queue handle          */
  284. SEL  SelSqlThreadStack;
  285.  
  286. ULONG StartSqlSem = (ULONG)NULL;     /* Semaphore to signal that      */
  287. HSEM  hsemStartSqlThread = &StartSqlSem;  /* second thread has started*/
  288. ULONG KillSqlSem = (ULONG)NULL;      /* Semaphore to signal that      */
  289. HSEM  hsemKillSqlThread = &KillSqlSem;      /* second thread has ended. */
  290.  
  291. /*********************************************************************/
  292. /*                                     */
  293. /* SQL constants                             */
  294. /*                                     */
  295. /*********************************************************************/
  296.  
  297. struct sqlca sqlca;
  298.  
  299. EXEC SQL INCLUDE SQLCA;
  300. EXEC SQL INCLUDE SQLDA;
  301.  
  302. EXEC SQL BEGIN DECLARE SECTION;
  303.  
  304.  
  305. /*
  306.    Table   : ORG
  307.    Creator : USERID
  308. */
  309.  
  310.   char         ORG_DEPTNAME [15];
  311.   short      ORG_DEPTNAME_N;
  312.   short      ORG_DEPTNUMB;
  313.   char         ORG_DIVISION [11];
  314.   short      ORG_DIVISION_N;
  315.   char         ORG_LOCATION [14];
  316.   short      ORG_LOCATION_N;
  317.   short      ORG_MANAGER;
  318.   short      ORG_MANAGER_N;
  319.  
  320.  
  321. /*
  322.    Table   : STAFF
  323.    Creator : USERID
  324. */
  325.  
  326.   double     STAFF_COMM;
  327.   short      STAFF_COMM_N;
  328.   short      STAFF_DEPT;
  329.   short      STAFF_DEPT_N;
  330.   short      STAFF_ID;
  331.   char         STAFF_JOB [6];
  332.   short      STAFF_JOB_N;
  333.   char         STAFF_NAME [10];
  334.   short      STAFF_NAME_N;
  335.   double     STAFF_SALARY;
  336.   short      STAFF_SALARY_N;
  337.   short      STAFF_YEARS;
  338.   short      STAFF_YEARS_N;
  339.  
  340.  
  341. EXEC SQL END DECLARE SECTION;
  342.  
  343. UCHAR DataBaseName[9]       = {0};     /* DataBase Name         */
  344.  
  345. /****************** Start of main procedure ***************************/
  346. /**********************************************************************/
  347. /*                                      */
  348. /*  FUNCTION: main                              */
  349. /*                                      */
  350. /*  This is a typical PM main function.                   */
  351. /*  It initializes PM, creates a message queue, loads some strings ,  */
  352. /*  registers some window classes, creates a main window, gets and    */
  353. /*  dispatches messages to its window procedure until the time to     */
  354. /*  quit, and then tidies up before terminating.              */
  355. /*                                      */
  356. /*  It sets the values of the following globals:-              */
  357. /*                                      */
  358. /*  habMainTask, hwndFrameMainWindow, hwndMainWindow              */
  359. /*                                      */
  360. /**********************************************************************/
  361.  
  362. VOID cdecl main( SHORT argc, PUCHAR *argv)
  363. {
  364.   QMSG       qmsg;              /* Message structure          */
  365.   PID       Pid;               /* Process Id              */
  366.   TID       Tid;               /* Thread Id              */
  367.   HELPINIT hinit;              /* Help init              */
  368.   HPOINTER hptrIcon;              /* Handle of the Icon          */
  369.  
  370.    Argc = argc;
  371.    Argv = argv;
  372.  
  373.    EndOfAppl = FALSE;             /* Switch Accept End Application */
  374.    AcceptMsgInfo = TRUE;         /* Switch Accept MsgInfo          */
  375.    hmodSample = (HMODULE)NULL;         /* hMod Inline              */
  376.    hwndHelp     = (HWND)0;         /* Help Hwnd              */
  377.    szTaskList     = "Sample";
  378.  
  379.   /********************************************************************/
  380.   /* Initialize PM and Create application msg queue              */
  381.   /********************************************************************/
  382.                       /* Initialize PM              */
  383.   habMainTask = WinInitialize( 0 );
  384.                       /* Create application msg queue */
  385.   hmqMainTask = WinCreateMsgQueue(habMainTask,1024);
  386.  
  387.   WinSetPointer(HWND_DESKTOP,
  388.         WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE));
  389.  
  390.   /********************************************************************/
  391.   /* Query System preferences set by the user from the Control Panel  */
  392.   /********************************************************************/
  393.  
  394.   LogoTimer = WinQueryProfileInt(habMainTask,
  395.                 "PM_ControlPanel","LogoDisplayTime",-1);
  396.   WinQueryProfileString(habMainTask,"PM_National","sDecimal",
  397.             ".",sDecimal,sizeof(sDecimal));
  398.  
  399.   /********************************************************************/
  400.   /*   Initialize Application                          */
  401.   /********************************************************************/
  402.   InitializeApplication();
  403.  
  404.   /********************************************************************/
  405.   /* Initialize the help manager initialization structure, create an  */
  406.   /* instance of the help manager, and associate that instance with   */
  407.   /* the frame.                               */
  408.   /********************************************************************/
  409.                  /* size of initialization structure  */
  410.   hinit.cb             = sizeof(hinit);
  411.                  /* store HM return code from init.   */
  412.   hinit.ulReturnCode         = (ULONG)NULL;
  413.                  /* no tutorial program           */
  414.   hinit.pszTutorialName      = (PSZ)NULL;
  415.                  /* indicates help table is defined   */
  416.                  /* in the RC file.              */
  417.   hinit.phtHelpTable         = (PHELPTABLE)(0xFFFF0000 |
  418.                    ID_SAMPLE);    
  419.                   /* help table in Exe or a DLL       */
  420.   hinit.hmodHelpTableModule     = hmodSample;    
  421.   hinit.hmodAccelActionBarModule = (HMODULE)NULL;
  422.   hinit.idAccelTable         = (USHORT)NULL;
  423.                   /* action bar is not tailored       */
  424.   hinit.idActionBar         = (USHORT)NULL;
  425.                   /* help window title              */
  426.   hinit.pszHelpWindowTitle     = szTaskList;
  427.                  /* help panels ID is not displayed   */
  428.   hinit.usShowPanelId         = CMIC_HIDE_PANEL_ID;
  429.                   /* library with help panels          */
  430.   hinit.pszHelpLibraryName     = "Sample.Hlp";
  431.  
  432.   /********************************************************************/
  433.   /* Control Gpf Library Level                          */
  434.   /********************************************************************/
  435.   if (GpfPmcLevel() != GPF_PMC_LEVEL)
  436.      {
  437.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  438.              (PSZ) "Gpf Verion Error",
  439.              (PSZ) "Invalid Pmc Level",
  440.              1,
  441.              MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  442.       DosExit( EXIT_PROCESS, 0 );
  443.      }
  444.   /********************************************************************/
  445.   /* Create Instance of IPF, pass Anchor Block handle and address of  */
  446.   /* of IPF initialization structure, and check  that creation was    */
  447.   /* successful.                              */
  448.   /********************************************************************/
  449.   hwndHelp = WinCreateHelpInstance(habMainTask, &hinit);
  450.   if (!hwndHelp)
  451.      {
  452.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  453.              (PSZ) "Help Not Available",
  454.              (PSZ) "Help Creation Error",
  455.              1,
  456.              MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  457.      }
  458.   else
  459.      {
  460.       if (hinit.ulReturnCode)
  461.      {
  462.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  463.              (PSZ) "Help Terminated Due to Error",
  464.              (PSZ) "Help Creation Error",
  465.              1,
  466.              MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  467.       WinDestroyHelpInstance(hwndHelp);
  468.       hwndHelp = (HWND)NULL;
  469.      }
  470.      }
  471.  
  472.   /********************************************************************/
  473.   /* Create Async Sql Thread And Open DataBase "SAMPLE"           */
  474.   /********************************************************************/
  475.   GpfCreateSqlThread();  /* Create Async Sql Thread And Open DataBase */
  476.  
  477.   /********************************************************************/
  478.   /* Create Async WindowThreads                       */
  479.   /********************************************************************/
  480.   CreateAboutTask();
  481.  
  482.   /********************************************************************/
  483.   /*   Create the window "MainWindow".                      */
  484.   /********************************************************************/
  485.   CreateMainWindow(NULL);
  486.  
  487.   /********************************************************************/
  488.   /* Make sure the window was created.                      */
  489.   /********************************************************************/
  490.   if ((!hwndFrameMainWindow) || (!hwndMainWindow))
  491.      DosExit( EXIT_PROCESS, 0 );
  492.  
  493.   hptrIcon = (HPOINTER) WinSendMsg( hwndFrameMainWindow,
  494.                     WM_QUERYICON,NULL,NULL);
  495.   /********************************************************************/
  496.   /* Set the window title (Task List)                      */
  497.   /********************************************************************/
  498.   WinQueryWindowProcess(hwndFrameMainWindow,&Pid,&Tid);
  499.   Swctl.hwnd = hwndFrameMainWindow;
  500.   Swctl.hwndIcon = hptrIcon;
  501.   Swctl.hprog = NULL;
  502.   Swctl.idProcess = Pid;
  503.   Swctl.idSession = (USHORT)NULL;
  504.   Swctl.uchVisibility = SWL_VISIBLE;
  505.   Swctl.fbJump = SWL_JUMPABLE;
  506.   strncpy(Swctl.szSwtitle,szTaskList,sizeof(Swctl.szSwtitle)-1);
  507.   hSwitch = WinAddSwitchEntry(&Swctl);
  508.  
  509.  
  510.   /********************************************************************/
  511.   /*   Show the window "MainWindow".                      */
  512.   /********************************************************************/
  513.   ShowMainWindow(NULL);             /* Show Main Window   */
  514.  
  515.   /********************************************************************/
  516.   /*   SetFocus the window "MainWindow".                  */
  517.   /********************************************************************/
  518.   WinSetFocus( HWND_DESKTOP,hwndFrameMainWindow);
  519.  
  520.   /********************************************************************/
  521.   /* The font resources are loaded. It may not be necessary to do     */
  522.   /* this as fonts can be loaded automatically when the system is     */
  523.   /* started. However, this is a user option that can be turned off   */
  524.   /* via the Control Panel.                          */
  525.   /********************************************************************/
  526.  
  527.   GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\COURIER.FON");
  528.   GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\HELV.FON");
  529.   GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\TIMES.FON");
  530.   GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\SYSMONO.FON");
  531.  
  532.   /********************************************************************/
  533.   /* A heap for allocating temporary storage is created.          */
  534.   /********************************************************************/
  535.   hHeap = WinCreateHeap(0,0,0,0,0,0);
  536.  
  537.   /********************************************************************/
  538.   /*   Show the Logo window "AboutWindow".                  */
  539.   /********************************************************************/
  540.   if (LogoTimer)
  541.      ShowAboutWindow(NULL);          /* Show Logo Window          */
  542.   else
  543.      LogoTimer = -1;              /* Set Indefinite LogoTimer */
  544.  
  545.   /********************************************************************/
  546.   /* Main message-processing loop - get and dispatch messages until   */
  547.   /* WM_QUIT received and Accepted (EndOfAppl = TRUE)              */
  548.   /********************************************************************/
  549.  
  550.   while(!EndOfAppl)
  551.        {
  552.     if (! WinGetMsg( habMainTask, &qmsg, (HWND)NULL, 0, 0 ) )
  553.         EndApplication();
  554.     else
  555.         WinDispatchMsg( habMainTask, &qmsg );
  556.        }
  557.  
  558.   /********************************************************************/
  559.   /* Tidy up and terminate                          */
  560.   /********************************************************************/
  561.  
  562.   GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\COURIER.FON");
  563.   GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\HELV.FON");
  564.   GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\TIMES.FON");
  565.   GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\SYSMONO.FON");
  566.  
  567.   WinDestroyWindow( hwndFrameMainWindow );
  568.   if (hwndHelp != (HWND)NULL)
  569.       WinDestroyHelpInstance(hwndHelp);
  570.   WinDestroyHeap( hHeap );
  571.   WinDestroyMsgQueue( hmqMainTask );
  572.   WinTerminate( habMainTask );
  573.  
  574.   /********************************************************************/
  575.   /* Close DataBase "SAMPLE"                          */
  576.   /********************************************************************/
  577.   if (DataBaseName[0])
  578.       GpfKillSqlThread();            /* Close DataBase     */
  579.  
  580.   /********************************************************************/
  581.   /* Dos Exit                                  */
  582.   /********************************************************************/
  583.   DosExit( EXIT_PROCESS, 0 );
  584. }
  585. /**********************************************************************/
  586. /* End of main procedure                          */
  587. /**********************************************************************/
  588. /**********************************************************************/
  589.  
  590.  
  591. /**********************************************************************/
  592. /**********************************************************************/
  593. /*                                      */
  594. /*  WinProc: GpfDefWindowProc                          */
  595. /*                                      */
  596. /*  Controls the "DefaultWindowProc" Area.                  */
  597. /*                                      */
  598. /*                                      */
  599. /**********************************************************************/
  600.  
  601. MRESULT  EXPENTRY GpfDefWindowProc(
  602.           HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  603. {
  604.   LONG        Color;          /* Work BackGround Color         */
  605.   HWND        hwndActive;       /* Query Active Window         */
  606.   PGPFPARMS pGpfParms;          /* Far Pointer             */
  607.   SEL        Selector;          /* Seloctor                 */
  608.   USHORT    uShort;          /* Work uShort             */
  609.  
  610.   /*******************************************************************/
  611.   /* Initialize Gpf Parameters                         */
  612.   /*******************************************************************/
  613.   pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
  614.   if (!pGpfParms)
  615.       return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  616.  
  617.   switch(msg)
  618.   {
  619.  
  620.     /**************************************************************/
  621.     /* Things to do when the Window is first initalized          */
  622.     /**************************************************************/
  623.    case WM_INITDLG:
  624.     /**************************************************************/
  625.     /*  Save CreateUserParms                      */
  626.     /**************************************************************/
  627.     pGpfParms->pCrtParms = (PVOID)mp2;
  628.     /**************************************************************/
  629.     /*  Associate Help Instance                      */
  630.     /**************************************************************/
  631.     WinAssociateHelpInstance(hwndHelp,GpfGetHwndFrame(hwnd));
  632.     /**************************************************************/
  633.     /*  Set Default BackGroundColor                   */
  634.     /**************************************************************/
  635.     pGpfParms->BgColor = SYSCLR_WINDOW;
  636.     /**************************************************************/
  637.     /*  Query Presentation Parameters BackGroundColor          */
  638.     /**************************************************************/
  639.     if (WinQueryPresParam(hwnd,PP_BACKGROUNDCOLOR,
  640.                   (ULONG)NULL,(PULONG)NULL,
  641.                   4L,&Color,(USHORT)NULL))
  642.         pGpfParms->BgColor = Color;
  643.     /**************************************************************/
  644.     /*  Query Presentation Parameters BackGroundColor Index       */
  645.     /**************************************************************/
  646.     if (WinQueryPresParam(hwnd,(ULONG)NULL,
  647.                   PP_BACKGROUNDCOLORINDEX,(PULONG)NULL,
  648.                   4L,&Color,QPF_ID1COLORINDEX))
  649.        pGpfParms->BgColor = Color;
  650.     /**************************************************************/
  651.     /*  Set Default ForeGroundColor                   */
  652.     /**************************************************************/
  653.     pGpfParms->FgColor = SYSCLR_WINDOWTEXT;
  654.     /**************************************************************/
  655.     /*  Query Presentation Parameters ForeGroundColor          */
  656.     /**************************************************************/
  657.     if (WinQueryPresParam(hwnd,PP_FOREGROUNDCOLOR,
  658.                   (ULONG)NULL,(PULONG)NULL,
  659.                   4L,&Color,(USHORT)NULL))
  660.         pGpfParms->FgColor = Color;
  661.     /**************************************************************/
  662.     /*  Query Presentation Parameters ForeGroundColor Index       */
  663.     /**************************************************************/
  664.     if (WinQueryPresParam(hwnd,(ULONG)NULL,
  665.                   PP_FOREGROUNDCOLORINDEX,(PULONG)NULL,
  666.                   4L,&Color,QPF_ID1COLORINDEX))
  667.        pGpfParms->FgColor = Color;
  668.     /**************************************************************/
  669.     /*  Return pGpfParms Mresult                      */
  670.     /**************************************************************/
  671.     return (pGpfParms->mresult);
  672.  
  673.     /**************************************************************/
  674.     /* The application has asked for the window to be destroyed.  */
  675.     /**************************************************************/
  676.    case WM_DESTROY:
  677.     WinSetWindowULong(hwnd,QWL_USER,(ULONG)NULL);
  678.     GpfDestroyTemplate(hwnd);           /* Reset Help Instance */
  679.                  /* Extract selector from far pointer */
  680.     Selector = SELECTOROF(pGpfParms);
  681.     DosFreeSeg(Selector);               /* Freemain (GpfParms) */
  682.     break;
  683.  
  684.     /**************************************************************/
  685.     /* Let frame control erase background for us              */
  686.     /**************************************************************/
  687.    case WM_ERASEBACKGROUND:
  688.             /* The client window is cleared to SYSCLR_WINDOW. */
  689.     return (MRESULT)(FALSE);       /*  No background windows. */
  690.  
  691.        /***************************************************************/
  692.        /* The window needs painting.                      */
  693.        /***************************************************************/
  694.    case WM_PAINT:
  695.     uShort = pGpfParms->ShortMsgId;            /* Save    MsgId */
  696.     pGpfParms->ShortMsgId = -1;               /* Reset MsgId */
  697.     GpfSendMsgInfo(pGpfParms,uShort);
  698.     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  699.     break;
  700.  
  701.     /**************************************************************/
  702.     /*  Resize & Reposition all the BASE windows.              */
  703.     /*  WM_SIZE message was generated when window was created.    */
  704.     /**************************************************************/
  705.    case WM_SIZE:
  706.     if (pGpfParms->Options & GPF_OP_ADJUSTSIZE)
  707.         GpfAdjustControlSize(hwnd,mp1,mp2);     /* Adjust Size    */
  708.     return ((MRESULT) FALSE);
  709.  
  710.     /**************************************************************/
  711.     /* Receive Char ( Set Tabulation )                  */
  712.     /**************************************************************/
  713.    case WM_CHAR:
  714.     pGpfParms->mresult = GpfSetTabulation( hwnd, msg, mp1, mp2 );
  715.     uShort = WinQueryWindowUShort(WinQueryFocus(HWND_DESKTOP,FALSE),
  716.                       QWS_ID);
  717.     GpfSendMsgInfo(pGpfParms,uShort);
  718.     return (pGpfParms->mresult);
  719.     break;
  720.  
  721.    case WM_MOUSEMOVE:
  722.     /**************************************************************/
  723.     /* Process MouseMove for Information Msg              */
  724.     /**************************************************************/
  725.     uShort = WinQueryWindowUShort(GpfGetHwndFrame(hwnd),QWS_ID);
  726.     GpfSendMsgInfo(pGpfParms,uShort);
  727.     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  728.  
  729.     /**************************************************************/
  730.     /* Process ControlPointer & MenuSelected for Information Msg  */
  731.     /**************************************************************/
  732.    case WM_CONTROLPOINTER:
  733.    case WM_MENUSELECT:
  734.     GpfSendMsgInfo(pGpfParms,SHORT1FROMMP(mp1));
  735.     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  736.  
  737.     /**************************************************************/
  738.     /* Process MenuEnd for Information Msg                  */
  739.     /**************************************************************/
  740.    case WM_MENUEND:
  741.     pGpfParms->ShortMsgId = -1;               /* Reset MsgId */
  742.     GpfSendMsgInfo(pGpfParms,0);
  743.     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  744.  
  745.     /**************************************************************/
  746.     /* Things to do when the Window is Moved              */
  747.     /**************************************************************/
  748.    case WM_MOVE:
  749.     WinPostMsg( hwnd, WM_PAINT, NULL, NULL);
  750.     break;
  751.  
  752.     /**************************************************************/
  753.     /* Message from system to close the client window.          */
  754.     /**************************************************************/
  755.    case WM_CLOSE:
  756.     if (pGpfParms->Options & GPF_OP_MAINWINDOW)
  757.        {
  758.         WinPostMsg(hwnd,WM_QUIT,0L,0L);    /* Cause termination  */
  759.         return ((MRESULT) FALSE);
  760.        }
  761.     /**************************************************************/
  762.     /* Simulate CANCEL - Send Did CANCEL to Window.           */
  763.     /**************************************************************/
  764.     WinPostMsg( hwnd,            /* Send Message          */
  765.             WM_COMMAND,         /* simulate CANCEL          */
  766.             MPFROM2SHORT( DID_CANCEL   , 0 ),
  767.             MPFROM2SHORT( CMDSRC_OTHER , 0 )
  768.           );
  769.     break;
  770.  
  771.        /***************************************************************/
  772.        /*  The List Box needs to know how big to make an Item.          */
  773.        /***************************************************************/
  774.    case WM_MEASUREITEM:
  775.     return (MRESULT)GpfMeasureItem( hwnd, mp1, mp2 );
  776.     break;
  777.  
  778.     /**************************************************************/
  779.     /*  The List Box wants us to Draw an Item              */
  780.     /**************************************************************/
  781.    case WM_DRAWITEM:
  782.     return (MRESULT)GpfDrawItem( hwnd, mp1, mp2 );
  783.     break;
  784.  
  785.    case HM_HELPSUBITEM_NOT_FOUND:
  786.     /**************************************************************/
  787.     /* Help manager couldn't find a help panel for an item.       */
  788.     /* Returning FALSE will display the extended help for that    */
  789.     /* window.                              */
  790.     /**************************************************************/
  791.     return (MRESULT)(FALSE);
  792.     break;
  793.  
  794.    case HM_QUERY_KEYS_HELP:
  795.     /**************************************************************/
  796.     /* Return Keys help panel ID for the help manager          */
  797.     /**************************************************************/
  798.     /**************************************************************/
  799.     /*     QUERY_KEYS_HELP                          */
  800.     /*                                  */
  801.     /* If the user requests KEYS HELP from the help pull-down,    */
  802.     /* IPF sends the HM_QUERY_KEYS_HELP message to the application*/
  803.     /* which should return the panel id of the keys_help panel,   */
  804.     /* or a 0 to tell IPF to do nothing.                  */
  805.     /**************************************************************/
  806.     return (MRESULT)(ID_SAMPLE);    
  807.     break;
  808.  
  809.     case HM_ERROR:
  810.      /*************************************************************/
  811.      /* If an error occurs using IPF, an HM_ERROR msg will be     */
  812.      /* sent to the application.                      */
  813.      /*************************************************************/
  814.      hwndActive = WinQueryActiveWindow( HWND_DESKTOP, FALSE );
  815.      if (hwndHelp && ((ULONG) mp1 == HMERR_NO_MEMORY))
  816.         {
  817.          WinMessageBox( HWND_DESKTOP, hwndActive,
  818.                 (PSZ) "Help Terminated Due to Error",
  819.                 (PSZ) "Help Error",
  820.                 1,
  821.                 MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  822.          WinDestroyHelpInstance(hwndHelp);
  823.          hwndHelp = (HWND)NULL;
  824.         }
  825.      break;
  826.  
  827.        /***************************************************************/
  828.        /* Other messages are handled by the default window procedure. */
  829.        /***************************************************************/
  830.    default:
  831.     /* Pass all other messages to the default window procedure    */
  832.     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  833.   }
  834.   return ((MRESULT) FALSE);
  835. }
  836. /**********************************************************************/
  837. /* End of window procedure - WinProc: GpfDefWindowProc              */
  838. /**********************************************************************/
  839. /**********************************************************************/
  840.  
  841.  
  842. /**********************************************************************/
  843. /**********************************************************************/
  844. /*                                      */
  845. /*  PRIVATE FUNCTION : GpfGetHwnfFrame                      */
  846. /*                                      */
  847. /*  Get Hwnd Frame From Hwnd                          */
  848. /*                                      */
  849. /**********************************************************************/
  850.  
  851. HWND GpfGetHwndFrame( HWND hwnd )
  852. {
  853.  
  854.   if (WinQueryWindowUShort(hwnd,QWS_ID) == FID_CLIENT)
  855.       return (WinQueryWindow( hwnd, QW_PARENT, FALSE));
  856.   else
  857.       return (hwnd);
  858.  
  859. }
  860. /**********************************************************************/
  861. /* End of GpfGetHwndFrame Private Function                  */
  862. /**********************************************************************/
  863. /**********************************************************************/
  864.  
  865.  
  866. /**********************************************************************/
  867. /**********************************************************************/
  868. /*                                      */
  869. /*  PRIVATE FUNCTION : GpfSetTextTitleBar                  */
  870. /*                                      */
  871. /*  Set Text Title Bar                              */
  872. /*                                      */
  873. /**********************************************************************/
  874.  
  875. VOID GpfSetTextTitleBar(HWND hwnd,PUCHAR Text)
  876. {
  877.   HWND    hwndFrame;
  878.  
  879.   /*******************************************************************/
  880.   /* Query Hwnd Frame                             */
  881.   /*******************************************************************/
  882.   hwndFrame = GpfGetHwndFrame(hwnd);
  883.  
  884.   /*******************************************************************/
  885.   /* Set Text                                 */
  886.   /*******************************************************************/
  887.   WinSetWindowText(hwndFrame, Text);
  888.  
  889. }
  890. /**********************************************************************/
  891. /* End of GpfSetCentreWindow Private Function                  */
  892. /**********************************************************************/
  893. /**********************************************************************/
  894.  
  895.  
  896.  
  897. /**********************************************************************/
  898. /**********************************************************************/
  899. /*                                      */
  900. /*  PRIVATE FUNCTION : GpfSetCentreWindow                  */
  901. /*                                      */
  902. /*  Positions Window in the center of the screen              */
  903. /*                                      */
  904. /**********************************************************************/
  905.  
  906. VOID GpfSetCentreWindow( HWND hwnd )
  907. {
  908.   SHORT ix, iy;
  909.   SHORT iwidth, idepth;
  910.   SWP    swp;
  911.   HWND    hwndFrame;
  912.  
  913.   /*******************************************************************/
  914.   /* Query Hwnd Frame                             */
  915.   /*******************************************************************/
  916.   hwndFrame = GpfGetHwndFrame(hwnd);
  917.  
  918.   /*******************************************************************/
  919.   /* Query width and depth of screen device                 */
  920.   /*******************************************************************/
  921.   iwidth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
  922.   idepth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
  923.  
  924.   /*******************************************************************/
  925.   /* Query width and depth of Window                     */
  926.   /*******************************************************************/
  927.   WinQueryWindowPos( hwndFrame, (PSWP)&swp );
  928.  
  929.   /*******************************************************************/
  930.   /* Center Window within the screen                     */
  931.   /*******************************************************************/
  932.   ix = ( iwidth  - swp.cx ) / 2;
  933.   iy = ( idepth  - swp.cy ) / 2;
  934.   WinSetWindowPos( hwndFrame, HWND_TOP, ix, iy, 0, 0, SWP_MOVE );
  935. }
  936. /**********************************************************************/
  937. /* End of GpfSetCentreWindow Private Function                  */
  938. /**********************************************************************/
  939. /**********************************************************************/
  940.  
  941.  
  942.  
  943. /**********************************************************************/
  944. /**********************************************************************/
  945. /*                                      */
  946. /*  PRIVATE FUNCTION :      GpfSetTopWindow                  */
  947. /*                                      */
  948. /*  Positions the Window in the Top of the screen              */
  949. /*                                      */
  950. /**********************************************************************/
  951.  
  952. VOID GpfSetTopWindow( HWND hwnd )
  953. {
  954.   SHORT iy;
  955.   SHORT iwidth, idepth;
  956.   SWP    swp;
  957.   HWND    hwndFrame;
  958.  
  959.   /*******************************************************************/
  960.   /* Query Hwnd Frame                             */
  961.   /*******************************************************************/
  962.   hwndFrame = GpfGetHwndFrame(hwnd);
  963.  
  964.   /*******************************************************************/
  965.   /* Query width and depth of screen device                 */
  966.   /*******************************************************************/
  967.   iwidth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
  968.   idepth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
  969.  
  970.   /*******************************************************************/
  971.   /* Query Window Position                          */
  972.   /*******************************************************************/
  973.   WinQueryWindowPos( hwndFrame, (PSWP)&swp );
  974.  
  975.   /*******************************************************************/
  976.   /* Top Window within the screen                     */
  977.   /*******************************************************************/
  978.   iy = ( idepth  - swp.cy );
  979.   WinSetWindowPos( hwnd, HWND_TOP,  0, iy, 0, 0, SWP_MOVE );
  980. }
  981. /**********************************************************************/
  982. /* End of GpfSetTopWindow Private Function                  */
  983. /**********************************************************************/
  984. /**********************************************************************/
  985.  
  986.  
  987.  
  988. /**********************************************************************/
  989. /**********************************************************************/
  990. /*                                      */
  991. /*  PRIVATE FUNCTION : GpfSetMaxWindow                      */
  992. /*                                      */
  993. /*  Positions the Window in the Max of the screen              */
  994. /*                                      */
  995. /**********************************************************************/
  996.  
  997. VOID GpfSetMaxWindow( HWND hwnd )
  998. {
  999.   SHORT iwidth, idepth;
  1000.   HWND    hwndFrame;
  1001.  
  1002.   /*******************************************************************/
  1003.   /* Query Hwnd Frame                             */
  1004.   /*******************************************************************/
  1005.   hwndFrame = GpfGetHwndFrame(hwnd);
  1006.  
  1007.   /*******************************************************************/
  1008.   /* Query width and depth of screen device                  */
  1009.   /*******************************************************************/
  1010.   iwidth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
  1011.   idepth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
  1012.  
  1013.   /*******************************************************************/
  1014.   /* Top Window within the screen                      */
  1015.   /*******************************************************************/
  1016.   WinSetWindowPos( hwndFrame, HWND_TOP, 0 , 0 ,
  1017.            iwidth, idepth, SWP_MOVE|SWP_SIZE );
  1018. }
  1019. /**********************************************************************/
  1020. /* End of GpfSetMaxWindow Private Function                  */
  1021. /**********************************************************************/
  1022. /**********************************************************************/
  1023.  
  1024.  
  1025. /**********************************************************************/
  1026. /**********************************************************************/
  1027. /*                                      */
  1028. /* PRIVATE FUNCTION: GpfUpdateSysMenu                      */
  1029. /*                                      */
  1030. /* Edit items in the system menu to leave "Move", "Close", and          */
  1031. /* "Switch to Task Manager".                          */
  1032. /*                                      */
  1033. /**********************************************************************/
  1034. VOID GpfUpdateSysMenu( HWND hwnd )
  1035. {
  1036.   HWND       hwndSubMenu;         /* sys menu pull-down handle  */
  1037.   MENUITEM miTemp;            /* menu item template          */
  1038.   SHORT    sItemId;            /* system menu item ID          */
  1039.   SHORT    sItemIndex;            /* system menu item index     */
  1040.   HWND       hwndFrame;
  1041.   MRESULT  mresult;
  1042.  
  1043.   /* Query Hwnd Frame                             */
  1044.   hwndFrame = GpfGetHwndFrame(hwnd);
  1045.  
  1046.   /********************************************************************/
  1047.   /* Get the handle of the system menu pull-down.              */
  1048.   /********************************************************************/
  1049.   hwndSubMenu = WinWindowFromID( hwndFrame, FID_SYSMENU );
  1050.   WinSendMsg( hwndSubMenu,
  1051.           MM_QUERYITEM,
  1052.           MPFROM2SHORT( SC_SYSMENU, FALSE ),
  1053.           MPFROMP( (PSZ)&miTemp ));
  1054.   hwndSubMenu = miTemp.hwndSubMenu;
  1055.  
  1056.   /********************************************************************/
  1057.   /* Remove all items from the system menu pull-down that are no      */
  1058.   /* longer wanted.                              */
  1059.   /********************************************************************/
  1060.   mresult = WinSendMsg( hwndSubMenu,
  1061.             MM_QUERYITEMCOUNT,
  1062.             MPFROMSHORT(0),
  1063.             MPFROMSHORT(0));
  1064.   sItemIndex = SHORT1FROMMR(mresult);
  1065.   for ( sItemId = 0; sItemIndex != -1;sItemIndex--)
  1066.       {
  1067.        mresult = WinSendMsg( hwndSubMenu,
  1068.                  MM_ITEMIDFROMPOSITION,
  1069.                  MPFROMSHORT( sItemIndex ),
  1070.                  MPFROMSHORT(0) );
  1071.        sItemId = SHORT1FROMMR(mresult);
  1072.        if ( sItemId != MIT_ERROR &&
  1073.         sItemId != SC_MOVE     &&
  1074.         sItemId != SC_CLOSE  &&
  1075.         sItemId != SC_TASKMANAGER )
  1076.       {
  1077.        WinSendMsg( hwndSubMenu,
  1078.                MM_DELETEITEM,
  1079.                MPFROM2SHORT( sItemId, FALSE ),
  1080.                MPFROMSHORT(0) );
  1081.       }
  1082.       }
  1083. }
  1084. /**********************************************************************/
  1085. /* End of GpfUpdateSysMenu Private Function                  */
  1086. /**********************************************************************/
  1087. /**********************************************************************/
  1088.  
  1089. /************** Start of GpfSysMenuGray Private Function **************/
  1090. /**********************************************************************/
  1091. /* GpfSysMenuGray:                              */
  1092. /* This function enables and disables choices (menu items) as required*/
  1093. /**********************************************************************/
  1094.  
  1095. VOID  GpfSysMenuGray(HWND hwnd, USHORT item, BOOL option )
  1096. {
  1097.     WinSendMsg( WinWindowFromID( hwnd, FID_SYSMENU )
  1098.           , MM_SETITEMATTR
  1099.           , MPFROM2SHORT( item, TRUE)
  1100.           , MPFROM2SHORT( MIA_DISABLED,
  1101.                   option ? MIA_DISABLED : ~MIA_DISABLED )
  1102.           );
  1103.     return;
  1104. }
  1105. /**********************************************************************/
  1106. /*************** End of GpfSysMenuGray Private Function ***************/
  1107. /**********************************************************************/
  1108. /**********************************************************************/
  1109.  
  1110.  
  1111. /***************** Start of GpfMenuGray Private Function **************/
  1112. /**********************************************************************/
  1113. /*                                      */
  1114. /* PRIVATE FUNCTION : GpfMenuGray                      */
  1115. /*                                      */
  1116. /* This function enables and disables choices (menu items) as required*/
  1117. /*                                      */
  1118. /**********************************************************************/
  1119.  
  1120. VOID  GpfMenuGray(HWND hwnd, USHORT Item, BOOL Option )
  1121. {
  1122.   HWND    hwndFrame;
  1123.  
  1124.   /*******************************************************************/
  1125.   /* Query Hwnd Frame                             */
  1126.   /*******************************************************************/
  1127.   hwndFrame = GpfGetHwndFrame(hwnd);
  1128.  
  1129.   /********************************************************************/
  1130.   /* Enables or Disables choices (menu items) as required          */
  1131.   /********************************************************************/
  1132.   WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU )
  1133.           , MM_SETITEMATTR
  1134.           , MPFROM2SHORT( Item, TRUE)
  1135.           , MPFROM2SHORT( MIA_DISABLED,
  1136.                   Option ? MIA_DISABLED : ~MIA_DISABLED )
  1137.         );
  1138. }
  1139. /**********************************************************************/
  1140. /* End of GpfMenuGray Private Function                      */
  1141. /**********************************************************************/
  1142. /**********************************************************************/
  1143.  
  1144.  
  1145. /***************** Start of GpfMenuTick Private Function **************/
  1146. /**********************************************************************/
  1147. /*                                      */
  1148. /* PRIVATE FUNCTION : GpfMenuTick                      */
  1149. /*                                      */
  1150. /* This function updates the check marks against choices as required. */
  1151. /*                                      */
  1152. /**********************************************************************/
  1153. VOID  GpfMenuTick(HWND hwnd , USHORT Item, BOOL Option )
  1154. {
  1155.   HWND    hwndFrame;
  1156.  
  1157.   /*******************************************************************/
  1158.   /* Query Hwnd Frame                             */
  1159.   /*******************************************************************/
  1160.   hwndFrame = GpfGetHwndFrame(hwnd);
  1161.  
  1162.   /*******************************************************************/
  1163.   /* Updates the check marks against choices as required.         */
  1164.   /*******************************************************************/
  1165.   WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU )
  1166.           , MM_SETITEMATTR
  1167.           , MPFROM2SHORT( Item, TRUE)
  1168.           , MPFROM2SHORT( MIA_CHECKED,
  1169.                   Option ? MIA_CHECKED : ~MIA_CHECKED )
  1170.         );
  1171. }
  1172.  
  1173. /**********************************************************************/
  1174. /* End of GpfMenuTick Private Function                      */
  1175. /**********************************************************************/
  1176. /**********************************************************************/
  1177.  
  1178.  
  1179.  
  1180. /************** Start of GpfMenuSwapTick Private Function *************/
  1181. /**********************************************************************/
  1182. /*                                      */
  1183. /* PRIVATE FUNCTION : GpfMenuSwapTick                      */
  1184. /*                                      */
  1185. /* This function updates-Swap the check marks.                  */
  1186. /*                                      */
  1187. /**********************************************************************/
  1188. VOID  GpfMenuSwapTick(HWND hwnd , USHORT Item )
  1189. {
  1190.   HWND    hwndFrame;
  1191.  
  1192.   /*******************************************************************/
  1193.   /* Query Hwnd Frame                             */
  1194.   /*******************************************************************/
  1195.   hwndFrame = GpfGetHwndFrame(hwnd);
  1196.  
  1197.   /*******************************************************************/
  1198.   /* Updates the check marks.                         */
  1199.   /*******************************************************************/
  1200.   if (WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU ),
  1201.           MM_QUERYITEMATTR,
  1202.           MPFROM2SHORT( Item, TRUE ),
  1203.           MPFROM2SHORT(MIA_CHECKED, 0)))
  1204.      {
  1205.       WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU),
  1206.           MM_SETITEMATTR,
  1207.           MPFROM2SHORT( Item, TRUE),
  1208.           MPFROM2SHORT(MIA_CHECKED, 0));
  1209.      }
  1210.   else
  1211.      {
  1212.       WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU),
  1213.           MM_SETITEMATTR,
  1214.           MPFROM2SHORT( Item, TRUE),
  1215.           MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED));
  1216.      }
  1217. }
  1218.  
  1219. /**********************************************************************/
  1220. /* End of GpfMenuTick Private Function                      */
  1221. /**********************************************************************/
  1222. /**********************************************************************/
  1223.  
  1224.  
  1225.  
  1226. /************* Start of GpfStringIsNumeric Private Function ***********/
  1227. /**********************************************************************/
  1228. /*                                      */
  1229. /* PRIVATE FUNCTION : GpfStringIsNumeric                  */
  1230. /*                                      */
  1231. /**********************************************************************/
  1232. BOOL GpfStringIsNumeric( UCHAR String[] )
  1233. {
  1234.  SHORT Index;
  1235.  SHORT Length;
  1236.  
  1237.     Length = strlen(String);
  1238.     if (!Length)
  1239.        return FALSE;
  1240.     for (Index = 0; Index < Length; Index++)
  1241.     {
  1242.      if (String[Index] < '0' || String[Index] > '9')
  1243.          return FALSE;
  1244.     }
  1245.     return TRUE;
  1246. }
  1247.  
  1248. /**********************************************************************/
  1249. /* End of GpfStringIsNumeric Private Function                  */
  1250. /**********************************************************************/
  1251. /**********************************************************************/
  1252.  
  1253.  
  1254.  
  1255. /***************** Start of GpfSendMsg Private Function ***************/
  1256. /**********************************************************************/
  1257. /*                                      */
  1258. /* PRIVATE FUNCTION : GpfSendMsg                      */
  1259. /*                                      */
  1260. /* Display, and operate the message box window                  */
  1261. /**********************************************************************/
  1262. SHORT GpfSendMsg( SHORT Id )
  1263. {
  1264.  UCHAR       String[256];
  1265.  HWND       SysModalWindow;
  1266.  HWND       hwndActive;           /* Query Active Window (ApplModal) */
  1267.  USHORT    Reply = 0;
  1268.  SHORT       Alarm = -1;
  1269.  SHORT       Style = 0;
  1270.  PUCHAR    Token1 = 0;
  1271.  PUCHAR    Token2 = 0;
  1272.  UCHAR       szTitle[128];
  1273.  
  1274.  /*********************************************************************/
  1275.  /* Save Window (System Modal)                          */
  1276.  /*********************************************************************/
  1277.  SysModalWindow = WinQuerySysModalWindow(HWND_DESKTOP,FALSE);
  1278.  
  1279.  /*********************************************************************/
  1280.  /* Load Msg strings                              */
  1281.  /*********************************************************************/
  1282.  WinLoadString(habMainTask, hmodSample,
  1283.            Id, sizeof(String),(PSZ)String );
  1284.  
  1285.  Token1 = strchr(String,':');
  1286.  if (Token1)
  1287.     {
  1288.      *Token1 = 0;
  1289.      Alarm = atoi(String);
  1290.      Token2 = strchr(++Token1,' ');
  1291.      if (Token2)
  1292.     {
  1293.      *(Token2++) = 0;
  1294.      Style = atoi(Token1);
  1295.      /***************************************************/
  1296.      /* Set Alarm                        */
  1297.      /***************************************************/
  1298.      if (Alarm != -1)
  1299.          WinAlarm(HWND_DESKTOP,Alarm);
  1300.      /***************************************************/
  1301.      /* Query HwndOwner and Title                */
  1302.      /***************************************************/
  1303.      hwndActive = WinQueryActiveWindow( HWND_DESKTOP, FALSE );
  1304.      WinQueryWindowText(hwndFrameMainWindow,
  1305.                 sizeof(szTitle),szTitle);
  1306.      /***************************************************/
  1307.      /* Now, display the message, save the button press */
  1308.      /* for a return code.                    */
  1309.      /* Pop up a Message box.                */
  1310.      /***************************************************/
  1311.      Reply = WinMessageBox(HWND_DESKTOP,hwndActive,
  1312.                    Token2,szTitle,Id,Style);
  1313.      /***************************************************/
  1314.      /* Restore Window (System Modal)            */
  1315.      /***************************************************/
  1316.      WinSetSysModalWindow(HWND_DESKTOP,SysModalWindow);
  1317.      /***************************************************/
  1318.      /* Reset Information Message                */
  1319.      /***************************************************/
  1320.      hwndActive = WinWindowFromID( hwndActive, FID_CLIENT );
  1321.      WinPostMsg( hwndActive, WM_MOUSEMOVE, 0L, 0L );
  1322.     }
  1323.     }
  1324.  return(Reply);
  1325. }
  1326.  
  1327. /**********************************************************************/
  1328. /* End of GpfSendMsg Private Function                      */
  1329. /**********************************************************************/
  1330. /**********************************************************************/
  1331.  
  1332.  
  1333. /*************** Start of GpfSendMsgInfo Private Function *************/
  1334. /**********************************************************************/
  1335. /*                                      */
  1336. /* PRIVATE FUNCTION : GpfSendMsgInfo                      */
  1337. /*                                      */
  1338. /* Display, and operate the message                      */
  1339. /**********************************************************************/
  1340. VOID  GpfSendMsgInfo(PGPFPARMS pGpfParms,SHORT ShortMsgId)
  1341.  {
  1342.   if (!(pGpfParms->Options & GPF_OP_MSGINFO))
  1343.       return;
  1344.   if (pGpfParms->ShortMsgId == ShortMsgId)
  1345.       return;
  1346.   if (!(AcceptMsgInfo | pGpfParms->ShortMsgId))
  1347.       return;
  1348.   if (!(AcceptMsgInfo))              /* Accept Msg Info ...   */
  1349.       pGpfParms->ShortMsgId = 0;         /* No... Reset MsgId     */
  1350.   else
  1351.       pGpfParms->ShortMsgId = ShortMsgId;    /* Save Msg Id          */
  1352.   GpfDisplayMsgInformation(pGpfParms->hwnd,pGpfParms->ShortMsgId,
  1353.                pGpfParms->BgColor,pGpfParms->hmod);
  1354.  }
  1355. /**********************************************************************/
  1356. /* End of GpfSendMsgInfo Private Function                  */
  1357. /**********************************************************************/
  1358. /**********************************************************************/
  1359.  
  1360.  
  1361.  
  1362. /**********************************************************************/
  1363. /* GpfCreateSqlThread:                              */
  1364. /* Allocate a stack for the Sql thread, and set it running.          */
  1365. /**********************************************************************/
  1366. VOID GpfCreateSqlThread( VOID )
  1367. {
  1368.  
  1369.   /********************************************************************/
  1370.   /* Allocate Stack                              */
  1371.   /********************************************************************/
  1372.   DosAllocSeg( STACKSIZE, &SelSqlThreadStack, 0 );
  1373.   /********************************************************************/
  1374.   /* Begin Thread                              */
  1375.   /********************************************************************/
  1376.   DosSemSet( hsemStartSqlThread );
  1377.   _beginthread ( GpfSqlThread,
  1378.          MAKEP( SelSqlThreadStack, 0),
  1379.          STACKSIZE ,NULL);
  1380.   DosSemWait( hsemStartSqlThread, (ULONG)-1);
  1381. }
  1382.  
  1383. /**********************************************************************/
  1384. /* GpfKillSqlThread:                              */
  1385. /* Close down the Sql thread. Wait on the semaphore to indicate that  */
  1386. /* the Sql thread has ended, before freeing its stack.              */
  1387. /**********************************************************************/
  1388. VOID GpfKillSqlThread( VOID )
  1389. {
  1390.   DosSemSet( hsemKillSqlThread );
  1391.  
  1392.   if(WinPostQueueMsg( hmqSqlThread,
  1393.               SQLCLOSE,
  1394.               MPFROMLONG(NULL),
  1395.               MPFROMLONG(NULL)))
  1396.       while( DosSemWait( hsemKillSqlThread, (ULONG)-1));
  1397.  
  1398.   DosFreeSeg( SelSqlThreadStack );
  1399. }
  1400.  
  1401.  
  1402. /**********************************************************************/
  1403. /* GpfSqlThread:                              */
  1404. /* Execute Sql Command.                           */
  1405. /**********************************************************************/
  1406. VOID  cdecl GpfSqlThread ( PVOID Arg )
  1407. {
  1408. QMSG    qmsgSqlThread;        /* qMsg Sql Thread              */
  1409. LONG    ReturnCode;        /* Sql Return Code              */
  1410. /* Union  - ANSI standard for C - Compiler Option -W3 and -W4          */
  1411. /* Delete - Warning Msg - Cast of Data Pointer to Function Pointer    */
  1412. union    { PVOID PointerData; PFNSQL PointerProc; } U;
  1413.  
  1414.   Arg = Arg;    /* Delete - Warning Msg - Compiler Option -W3 and -W4 */
  1415.  
  1416.   habSqlThread = WinInitialize( (USHORT)NULL );
  1417.   hmqSqlThread = WinCreateMsgQueue( habSqlThread, (SHORT)NULL );
  1418.  
  1419.   DosSemClear( hsemStartSqlThread );
  1420.  
  1421.   /********************************************************************/
  1422.   /* Open DataBase "SAMPLE"                          */
  1423.   /********************************************************************/
  1424.   strcpy(DataBaseName,"SAMPLE");        /* Set DataBase Name      */
  1425.   sqlestar();                    /* Start Database Manager */
  1426.   sqleisig(&sqlca);                /* install signal handler */
  1427.   sqlestrd(DataBaseName,'S',&sqlca);        /* Start Using DataBase   */
  1428.   if (sqlca.sqlcode == SQLE_RC_NOLOGON)     /* User not logged on     */
  1429.      {                      /* -1093 User not logged on     */
  1430.       GpfDisplaySqlError(&sqlca);
  1431.       DosExit( EXIT_PROCESS, 0 );
  1432.      }
  1433.   if (sqlca.sqlcode == SQLE_RC_DB_RESTART)  /* DataBase needs Restart */
  1434.      {                      /* -1015 DataBase needs Restart */
  1435.       sqlerest(DataBaseName,&sqlca);        /* Restart DataBase       */
  1436.       sqlestrd(DataBaseName,'S',&sqlca);    /* Start Database Again   */
  1437.      }
  1438.   if (sqlca.sqlcode)
  1439.      {
  1440.       GpfDisplaySqlError(&sqlca);
  1441.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  1442.              (PSZ) "Couldn't Open DataBase - SAMPLE",    
  1443.              (PSZ) "Open DataBase Error",
  1444.              1,
  1445.              MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  1446.       WinPostQueueMsg( hmqMainTask,
  1447.                WM_QUIT, NULL, NULL );    /* Cause termination  */
  1448.       DosExit( EXIT_PROCESS, 0 );
  1449.      }
  1450.  
  1451.   if ( hmqSqlThread != (HMQ)NULL )
  1452.      {
  1453.      /*****************************************************************/
  1454.      /* Main message processing loop.                      */
  1455.      /* Terminates on receipt of a SQLCLOSE message from the main     */
  1456.      /* thread.                               */
  1457.      /*****************************************************************/
  1458.       do
  1459.     {
  1460.      WinGetMsg( habSqlThread, &qmsgSqlThread, (HWND)NULL, 0, 0 );
  1461.      if ( qmsgSqlThread.msg == SQLEXEC )
  1462.         {
  1463.          /*********************************************************/
  1464.          /* Execute Sql Command                      */
  1465.          /*********************************************************/
  1466.          U.PointerData = PVOIDFROMMP(qmsgSqlThread.mp1);
  1467.          ReturnCode = (*U.PointerProc)();
  1468.          if (qmsgSqlThread.mp2)
  1469.         {
  1470.          /*****************************************************/
  1471.          /* Post SQLEND and Sql Code                  */
  1472.          /*****************************************************/
  1473.          WinPostMsg( HWNDFROMMP(qmsgSqlThread.mp2),
  1474.                  SQLEND,
  1475.                  MPFROMLONG(ReturnCode),
  1476.                  NULL);
  1477.         }
  1478.         }
  1479.     }
  1480.       while (qmsgSqlThread.msg != SQLCLOSE);
  1481.      }
  1482.   /********************************************************************/
  1483.   /* Close DataBase "SAMPLE"                          */
  1484.   /********************************************************************/
  1485.   if (DataBaseName[0])
  1486.      sqlestpd(&sqlca);            /* Close DataBase          */
  1487.  
  1488.   /********************************************************************/
  1489.   /* Close Thread                              */
  1490.   /********************************************************************/
  1491.   WinDestroyMsgQueue( hmqSqlThread );    /* Destroy Msg Queue          */
  1492.   WinTerminate( habSqlThread );     /* Terminate              */
  1493.   DosEnterCritSec();
  1494.   DosSemClear( hsemKillSqlThread );
  1495.   DosExit( EXIT_THREAD, 0 );
  1496. }
  1497.  
  1498. /**********************************************************************/
  1499. /* GpfExecuteSql:                              */
  1500. /* Execute Sql.                               */
  1501. /**********************************************************************/
  1502. VOID  GpfExecuteSql( PFNSQL Proc ,HWND hwnd )
  1503. {
  1504.   WinPostQueueMsg( hmqSqlThread, SQLEXEC,
  1505.            MPFROMP(Proc),
  1506.            MPFROMHWND(hwnd));
  1507. }
  1508.  
  1509. /**********************************************************************/
  1510. /* GpfSqlWait:                                  */
  1511. /* Wait SQLEND Message.                           */
  1512. /**********************************************************************/
  1513. LONG  GpfSqlWait ( HWND hwnd )
  1514. {
  1515.   QMSG    qmsg;                  /* Message structure          */
  1516.   HAB    hab;                  /* Anchor block handle      */
  1517.   HPOINTER hptrWait;
  1518.  
  1519.    hptrWait  =    WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE);
  1520.    hab = WinQueryAnchorBlock(hwnd);
  1521.  
  1522.   /********************************************************************/
  1523.   /* Wind message-processing loop - get and dispatch messages until   */
  1524.   /* SQLEND received                              */
  1525.   /********************************************************************/
  1526.  
  1527.   do
  1528.     {
  1529.      WinGetMsg( hab, &qmsg, (HWND)NULL, 0, 0 );
  1530.      if (qmsg.msg != SQLEND)    /* If Not End Sql              */
  1531.     {
  1532.      switch (qmsg.msg)    /* Dispatch Or Delete Message          */
  1533.         {
  1534.          /*****************************************************/
  1535.          /* Set Wait Pointer                      */
  1536.          /*****************************************************/
  1537.          case WM_MOUSEMOVE:        /* Set Wait Pointer   */
  1538.               WinSetPointer(HWND_DESKTOP,hptrWait);
  1539.               break;            /* Delete Msg          */
  1540.  
  1541.          /*****************************************************/
  1542.          /* Set Focus To Window                   */
  1543.          /*****************************************************/
  1544.          case WM_BUTTON1UP:        /* Set              */
  1545.          case WM_BUTTON2UP:        /*     Focus          */
  1546.          case WM_BUTTON3UP:        /*        to Window */
  1547.               WinSetFocus( HWND_DESKTOP,hwnd );
  1548.               break;            /* Delete Msg          */
  1549.  
  1550.          /*****************************************************/
  1551.          /* Set Focus To Window And Alarm Warning          */
  1552.          /*****************************************************/
  1553.          case WM_BUTTON1DOWN:        /* Set              */
  1554.          case WM_BUTTON2DOWN:        /*     Focus          */
  1555.          case WM_BUTTON3DOWN:        /*        to Window */
  1556.          case WM_BUTTON1DBLCLK:     /* And              */
  1557.          case WM_BUTTON2DBLCLK:     /*     Alarm          */
  1558.          case WM_BUTTON3DBLCLK:     /*        Warning   */
  1559.          case WM_CHAR:
  1560.               WinSetFocus( HWND_DESKTOP,hwnd );
  1561.               WinAlarm(HWND_DESKTOP,WA_WARNING);
  1562.               break;            /* Delete Msg          */
  1563.  
  1564.          /*****************************************************/
  1565.          /* Dispatch Pass all other messages              */
  1566.          /*****************************************************/
  1567.          default:    /* Dispatch Pass all other messages   */
  1568.               WinDispatchMsg( hab, &qmsg );
  1569.               break;
  1570.         }
  1571.     }
  1572.     }
  1573.   while (qmsg.msg != SQLEND);    /* While Not End Sql Message          */
  1574.  
  1575.   return(LONGFROMMP(qmsg.mp1)); /* Return SqlCa.SqlCode           */
  1576. }
  1577.  
  1578. /**********************************************************************/
  1579. /*                                      */
  1580. /*   name:     GpfDisplaySqlError                      */
  1581. /*                                      */
  1582. /*   purpose:                                  */
  1583. /*         Display SQL error message                      */
  1584. /*                                      */
  1585. /*   returns:                                  */
  1586. /*         SqlCa.SqlCode                          */
  1587. /*                                      */
  1588. /**********************************************************************/
  1589.  
  1590. LONG GpfDisplaySqlError(struct sqlca *SqlCa)
  1591. {
  1592.  char     mbuff[256];
  1593.  LONG     SqlCode;
  1594.  HWND     SysModalWindow;
  1595.  
  1596.   SqlCode = SqlCa->sqlcode;
  1597.   if (SqlCode >= 0)
  1598.      return(SqlCode);
  1599.  
  1600.   /********************************************************************/
  1601.   /* Save Window (System Modal)                       */
  1602.   /********************************************************************/
  1603.   SysModalWindow = WinQuerySysModalWindow(HWND_DESKTOP,FALSE);
  1604.  
  1605.   /********************************************************************/
  1606.   /* Query error message                          */
  1607.   /********************************************************************/
  1608.   sqlaintp(mbuff,255,254,SqlCa);
  1609.  
  1610.   /********************************************************************/
  1611.   /* Print error message                          */
  1612.   /********************************************************************/
  1613.   WinAlarm(HWND_DESKTOP,WA_WARNING);    /* Set Beep ( Warning )       */
  1614.   WinMessageBox( HWND_DESKTOP,
  1615.          HWND_DESKTOP,
  1616.          mbuff,         /* Display Message Sql Error  */
  1617.          "Sql Error",
  1618.          0,
  1619.          MB_ENTER | MB_WARNING | MB_SYSTEMMODAL);
  1620.  
  1621.   /********************************************************************/
  1622.   /* Restore Window (System Modal)                      */
  1623.   /********************************************************************/
  1624.   WinSetSysModalWindow(HWND_DESKTOP,SysModalWindow);
  1625.  
  1626.   SqlCa->sqlcode = SqlCode;             /* Restore SqlCode   */
  1627.   return(SqlCode);
  1628. }
  1629. /**********************************************************************/
  1630. /*   End GpfDisplaySqlError                          */
  1631. /**********************************************************************/
  1632. /**********************************************************************/
  1633.  
  1634.  
  1635.  
  1636. /**********************************************************************/
  1637. /**********************************************************************/
  1638. /*                                      */
  1639. /*   PRIVATE FUNCTION: Initialize Application                  */
  1640. /*                                      */
  1641. /**********************************************************************/
  1642.  
  1643. static VOID InitializeApplication( VOID )
  1644.  {
  1645.  }
  1646. /**********************************************************************/
  1647. /* End of Private Function: Initialize Application              */
  1648. /**********************************************************************/
  1649. /**********************************************************************/
  1650.  
  1651.  
  1652.  
  1653. /**********************************************************************/
  1654. /**********************************************************************/
  1655. /*                                      */
  1656. /*   PRIVATE FUNCTION: End Application                      */
  1657. /*                                      */
  1658. /**********************************************************************/
  1659.  
  1660. static VOID EndApplication( VOID )
  1661.  {
  1662.  
  1663.     EndOfAppl = TRUE;
  1664.     /**************************************************************/
  1665.     /* User Function ActionEndApplication                  */
  1666.     /**************************************************************/
  1667.     /**************************************************************/
  1668.     /* Send Message "Msg006".                      */
  1669.     /**************************************************************/
  1670.     if (GpfSendMsg(ID_MSG006) == MBID_YES)    
  1671.         EndOfAppl = TRUE;
  1672.     else
  1673.         EndOfAppl = FALSE;
  1674.  
  1675.  }
  1676. /**********************************************************************/
  1677. /* End of Private Function: End Application                  */
  1678. /**********************************************************************/
  1679. /**********************************************************************/
  1680.  
  1681.  
  1682. /**********************************************************************/
  1683. /**********************************************************************/
  1684. /*                                      */
  1685. /*   PRIVATE FUNCTION: ShowMainWindow                      */
  1686. /*                                      */
  1687. /*   Show Window "MainWindow".                          */
  1688. /*                                      */
  1689. /**********************************************************************/
  1690.  
  1691. BOOL  ShowMainWindow( PVOID pCrtParms )
  1692.  {
  1693.  SWP Swp;
  1694.  
  1695.               /* Make sure the window was not created. */
  1696.    if (!hwndFrameMainWindow)
  1697.     CreateMainWindow(pCrtParms);
  1698.    WinSetWindowPos( hwndFrameMainWindow,
  1699.             NULL,0,0,0,0,SWP_RESTORE);
  1700.    WinQueryWindowPos( hwndFrameMainWindow, &Swp );
  1701.    WinSetWindowPos( hwndFrameMainWindow,
  1702.             HWND_TOP,
  1703.             Swp.x,Swp.y,Swp.cx,Swp.cy,
  1704.             SWP_ZORDER | SWP_SIZE | SWP_MOVE |
  1705.             SWP_ACTIVATE | SWP_SHOW
  1706.           );
  1707.    return(FALSE);
  1708.  }
  1709.  
  1710. /**********************************************************************/
  1711. /**********************************************************************/
  1712. /*                                      */
  1713. /*   PRIVATE FUNCTION: DismissMainWindow                  */
  1714. /*                                      */
  1715. /*   Dismiss Window Hide - Window "MainWindow".               */
  1716. /*                                      */
  1717. /**********************************************************************/
  1718.  
  1719. VOID  DismissMainWindow( BOOL Rcode )
  1720.  {
  1721.  
  1722.    Rcode = Rcode;  /* Null , For Delete Unreferenced Formal Parameter */
  1723.                                /* Hide Window */
  1724.    WinShowWindow(hwndFrameMainWindow, FALSE);
  1725.  
  1726.  }
  1727.  
  1728. /**********************************************************************/
  1729. /**********************************************************************/
  1730. /*                                      */
  1731. /*   PRIVATE FUNCTION: CreateMainWindow                   */
  1732. /*                                      */
  1733. /*   Create the window "MainWindow" And Controls.              */
  1734. /*                                      */
  1735. /**********************************************************************/
  1736.  
  1737. VOID CreateMainWindow( PVOID pCrtParms)
  1738.  {
  1739.   /********************************************************************/
  1740.   /*   Register the window class "MainWindow".                  */
  1741.   /********************************************************************/
  1742.   WinRegisterClass(              /* Register window class    */
  1743.       habMainTask,              /* Anchor block handle      */
  1744.       "MainWindow",           /* Window class name          */
  1745.       fnwpMainWindow,          /* Address window procedure */
  1746.       CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style          */
  1747.       CS_MOVENOTIFY |          /* Class style          */
  1748.       CS_SIZEREDRAW | CS_SYNCPAINT,   /* Class style          */
  1749.       EXTRAWORDS              /* Extra window words       */
  1750.       );
  1751.  
  1752.   /********************************************************************/
  1753.   /*   Create the window "MainWindow".                      */
  1754.   /********************************************************************/
  1755.   hwndFrameMainWindow =                   /* Save Hwnd    */
  1756.   GpfCreateTemplate( ID_MAINWINDOW,              /* Ressource Id */
  1757.              hmodSample,              /* Ressource Md */
  1758.              HWND_DESKTOP,              /* Hwnd Parent  */
  1759.              HWND_DESKTOP,              /* Hwnd Owner   */
  1760.              pCrtParms);              /* User Parms   */
  1761.  }
  1762. /**********************************************************************/
  1763. /* End of Private Function - CreateMainWindow                  */
  1764. /**********************************************************************/
  1765. /**********************************************************************/
  1766.  
  1767.  
  1768.  
  1769. /**********************************************************************/
  1770. /**********************************************************************/
  1771. /*                                      */
  1772. /*  WinProc: fnwpMainWindow                          */
  1773. /*                                      */
  1774. /*  Controls the "MainWindow" Area.                      */
  1775. /*                                      */
  1776. /*                                      */
  1777. /**********************************************************************/
  1778.  
  1779. MRESULT  EXPENTRY fnwpMainWindow(
  1780.           HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  1781. {
  1782.   HPS        hps;          /* Presentation space handle         */
  1783.   RECTL     rcl;          /* Window rectangle             */
  1784.   PGPFPARMS pGpfParms;          /* Far Pointer             */
  1785.   SEL        Selector;          /* Seloctor                 */
  1786.  
  1787.   /*******************************************************************/
  1788.   /* Initialize Gpf Parameters                         */
  1789.   /*******************************************************************/
  1790.   pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
  1791.   if (pGpfParms)
  1792.      {
  1793.       pGpfParms->hwnd     = hwnd;      /* window handle             */
  1794.       pGpfParms->msg     = msg;       /* message number          */
  1795.       pGpfParms->mp1     = mp1;       /* 1st (packed) parms         */
  1796.       pGpfParms->mp2     = mp2;       /* 2nd (packed) parms         */
  1797.       pGpfParms->mresult = (MRESULT) FALSE; /* Mresult             */
  1798.       pGpfParms->Command = 0;          /* Command From mp1 (SHORT 1)  */
  1799.       pGpfParms->Notify  = 0;          /* Notify  From mp1 (SHORT 2)  */
  1800.      }
  1801.  
  1802.   switch(msg)
  1803.   {
  1804.     /**************************************************************/
  1805.     /* Things to do when the Window is first initalized          */
  1806.     /**************************************************************/
  1807.    case WM_INITDLG:
  1808.     /**************************************************************/
  1809.     /*  Initialize Window 'MainWindow'                  */
  1810.     /**************************************************************/
  1811.     GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1812.     WmInitWndMainWindow(pGpfParms); /* Init Dialog              */
  1813.     /**************************************************************/
  1814.     /*  Return pGpfParms Mresult                      */
  1815.     /**************************************************************/
  1816.     return (pGpfParms->mresult);
  1817.  
  1818.     /**************************************************************/
  1819.     /* Things to do when the Window is Activated/Deactivated      */
  1820.     /**************************************************************/
  1821.    case WM_ACTIVATE:
  1822.     if (SHORT1FROMMP(mp1))
  1823.         WmActiveMainWindow(pGpfParms);     /* Activate Window   */
  1824.     else
  1825.         WmDeActiveMainWindow(pGpfParms);     /* DeActivate Window */
  1826.     return (pGpfParms->mresult);
  1827.  
  1828.     /**************************************************************/
  1829.     /* Things to do when the Window is "Show/Hide"              */
  1830.     /**************************************************************/
  1831.    case WM_SHOW:
  1832.     if (SHORT1FROMMP(mp1))
  1833.         WmShowMainWindow(pGpfParms);           /* Show Window */
  1834.     else
  1835.         WmHideMainWindow(pGpfParms);           /* Hide Window */
  1836.     return (pGpfParms->mresult);
  1837.  
  1838.     /**************************************************************/
  1839.     /* The application has asked for the window to be created.    */
  1840.     /**************************************************************/
  1841.    case WM_CREATE:
  1842.     DosAllocSeg(sizeof(GPFPARMS),&Selector,0);    /* Getmain    */
  1843.     pGpfParms = MAKEP(Selector, 0);         /* Set Pointer*/
  1844.     WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
  1845.     memset(pGpfParms,0,sizeof(GPFPARMS));        /* Clear Area */
  1846.     pGpfParms->Options |= GPF_OP_MAINWINDOW; /* Set MainWindow    */
  1847.     hwndMainWindow = hwnd;                 /* Save Hwnd */
  1848.     hwndFrameMainWindow = GpfGetHwndFrame(hwnd);
  1849.     pGpfParms->hwnd = hwnd;            /* window handle       */
  1850.     pGpfParms->msg    = msg;               /* message number      */
  1851.     pGpfParms->mp1    = mp1;               /* 1st (packed) parms  */
  1852.     pGpfParms->mp2    = mp2;               /* 2nd (packed) parms  */
  1853.     pGpfParms->hmod = hmodSample;    
  1854.     pGpfParms->hab    = habMainTask;           /* Anchor block handle */
  1855.     WmCreateMainWindow(pGpfParms);           /* Create  Window      */
  1856.     break;
  1857.  
  1858.     /**************************************************************/
  1859.     /* The application has asked for the window to be destroyed.  */
  1860.     /**************************************************************/
  1861.    case WM_DESTROY:
  1862.     WmDestroyMainWindow(pGpfParms);         /* Destroy Window */
  1863.     hwndFrameMainWindow = (HWND)NULL;        /* Reset HwndFrm  */
  1864.     hwndMainWindow = (HWND)NULL;            /* Reset Hwnd     */
  1865.     /* Destroy Template , Help Instance and GpfParms          */
  1866.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1867.  
  1868.     /**************************************************************/
  1869.     /* The window needs painting.                      */
  1870.     /**************************************************************/
  1871.    case WM_PAINT:
  1872.     /**************************************************************/
  1873.     /* Obtain a cache PS                          */
  1874.     /**************************************************************/
  1875.     hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
  1876.     WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect          */
  1877.     pGpfParms->hps = hps;            /* Pass Hps ( Paint ) */
  1878.     WmPaintMainWindow(pGpfParms);        /* Paint Window       */
  1879.     WinEndPaint( hps );            /* Release cache PS   */
  1880.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1881.  
  1882.     /**************************************************************/
  1883.     /* Process ScrollBar received from the user              */
  1884.     /**************************************************************/
  1885.     case WM_VSCROLL:
  1886.     case WM_HSCROLL:
  1887.     /* Set Command From mp1 */
  1888.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1889.     /* Set Notify From mp2    */
  1890.     pGpfParms->Notify = SHORT2FROMMP( mp2 );
  1891.     CommandMainWindow( pGpfParms );       /* Process the command  */
  1892.     return (pGpfParms->mresult);
  1893.  
  1894.     /**************************************************************/
  1895.     /* Process Controls received from the user              */
  1896.     /**************************************************************/
  1897.    case WM_CONTROL:
  1898.     /* Set Command From mp1 */
  1899.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1900.     /* Set Notify From mp1    */
  1901.     pGpfParms->Notify = SHORT2FROMMP( mp1 );
  1902.     CommandMainWindow( pGpfParms );       /* Process the command  */
  1903.     return (pGpfParms->mresult);
  1904.  
  1905.     /**************************************************************/
  1906.     /* Process commands received from the user              */
  1907.     /**************************************************************/
  1908.    case WM_SYSCOMMAND:
  1909.    case WM_HELP:
  1910.    case WM_COMMAND:
  1911.     /* Set Command From mp1 */
  1912.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1913.     pGpfParms->Notify = COMMAND;          /* Set Notify From mp1  */
  1914.     CommandMainWindow( pGpfParms );       /* Process the command  */
  1915.     if (pGpfParms->mresult)
  1916.         return (pGpfParms->mresult);
  1917.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1918.  
  1919.     /**************************************************************/
  1920.     /* All other messages are passed to the default procedure.    */
  1921.     /**************************************************************/
  1922.    default:
  1923.     /* Pass all other messages to the default window procedure    */
  1924.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1925.   }
  1926.   return ((MRESULT) FALSE);
  1927. }
  1928. /**********************************************************************/
  1929. /* End of window procedure - WinProc: fnwpMainWindow              */
  1930. /**********************************************************************/
  1931. /**********************************************************************/
  1932.  
  1933.  
  1934.  
  1935. /**********************************************************************/
  1936. /**********************************************************************/
  1937. /*                                      */
  1938. /*   PRIVATE FUNCTION: CommandMainWindow                  */
  1939. /*                                      */
  1940. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  1941. /*   received by the window procedure.                      */
  1942. /*   Window "MainWindow".                          */
  1943. /*                                      */
  1944. /**********************************************************************/
  1945.  
  1946. static VOID CommandMainWindow ( PGPFPARMS pGpfParms )
  1947. {
  1948.   pGpfParms->mresult = (MRESULT) TRUE;        /* Set Return Code    */
  1949.   /* Switch according to Control chosen                   */
  1950.   switch( pGpfParms->Command )
  1951.   {
  1952.     /******************************************************************/
  1953.     /* Name  "MenuExit".                          */
  1954.     /* Text  "~Exit\tF3".                          */
  1955.     /******************************************************************/
  1956.     case ID_MENUEXIT:
  1957.      ActionMenuExit(pGpfParms);
  1958.      return;
  1959.     /******************************************************************/
  1960.     /* Name  "ListDep".                           */
  1961.     /* Text  "~List...".                          */
  1962.     /******************************************************************/
  1963.     case ID_LISTDEP:
  1964.      ActionListDep(pGpfParms);
  1965.      return;
  1966.     /******************************************************************/
  1967.     /* Name  "OrgList".                           */
  1968.     /* Text  "~List...".                          */
  1969.     /******************************************************************/
  1970.     case ID_ORGLIST:
  1971.      ActionOrgList(pGpfParms);
  1972.      return;
  1973.     /******************************************************************/
  1974.     /* Name  "MsgInfo".                           */
  1975.     /* Text  "~MsgInfo".                          */
  1976.     /******************************************************************/
  1977.     case ID_MSGINFO:
  1978.      ActionMsgInfo(pGpfParms);
  1979.      return;
  1980.     /******************************************************************/
  1981.     /* Name  "Msg1".                              */
  1982.     /* Text  "Msg1 ~Information Icon".                      */
  1983.     /******************************************************************/
  1984.     case ID_MSG1:
  1985.      ActionMsg1(pGpfParms);
  1986.      return;
  1987.     /******************************************************************/
  1988.     /* Name  "Msg2".                              */
  1989.     /* Text  "Msg2 ~Question Icon".                      */
  1990.     /******************************************************************/
  1991.     case ID_MSG2:
  1992.      ActionMsg2(pGpfParms);
  1993.      return;
  1994.     /******************************************************************/
  1995.     /* Name  "Msg3".                              */
  1996.     /* Text  "Msg3 ~Warning Icon".                      */
  1997.     /******************************************************************/
  1998.     case ID_MSG3:
  1999.      ActionMsg3(pGpfParms);
  2000.      return;
  2001.     /******************************************************************/
  2002.     /* Name  "Msg4".                              */
  2003.     /* Text  "Msg4 ~Error Icon".                      */
  2004.     /******************************************************************/
  2005.     case ID_MSG4:
  2006.      ActionMsg4(pGpfParms);
  2007.      return;
  2008.     /******************************************************************/
  2009.     /* Name  "Msg5".                              */
  2010.     /* Text  "Msg5 ~No Icon".                          */
  2011.     /******************************************************************/
  2012.     case ID_MSG5:
  2013.      ActionMsg5(pGpfParms);
  2014.      return;
  2015.     /******************************************************************/
  2016.     /* Name  "PullDownMark".                          */
  2017.     /* Text  "~Mark".                              */
  2018.     /******************************************************************/
  2019.     case ID_PULLDOWNMARK:
  2020.      ActionPullDownMark(pGpfParms);
  2021.      return;
  2022.     /******************************************************************/
  2023.     /* Name  "PullDownUnMark".                          */
  2024.     /* Text  "~UnMark".                           */
  2025.     /******************************************************************/
  2026.     case ID_PULLDOWNUNMARK:
  2027.      ActionPullDownUnMark(pGpfParms);
  2028.      return;
  2029.     /******************************************************************/
  2030.     /* Name  "PullDownSwap".                          */
  2031.     /* Text  "~Swap".                              */
  2032.     /******************************************************************/
  2033.     case ID_PULLDOWNSWAP:
  2034.      ActionPullDownSwap(pGpfParms);
  2035.      return;
  2036.     /******************************************************************/
  2037.     /* Name  "ForHelp".                           */
  2038.     /* Text  "~Help For Help...".                      */
  2039.     /******************************************************************/
  2040.     case ID_FORHELP:
  2041.      ActionForHelp(pGpfParms);
  2042.      return;
  2043.     /******************************************************************/
  2044.     /* Name  "ExHelp".                              */
  2045.     /* Text  "~Extended Help...".                      */
  2046.     /******************************************************************/
  2047.     case ID_EXHELP:
  2048.      ActionExHelp(pGpfParms);
  2049.      return;
  2050.     /******************************************************************/
  2051.     /* Name  "KeysHelp".                          */
  2052.     /* Text  "~Keys Help...".                          */
  2053.     /******************************************************************/
  2054.     case ID_KEYSHELP:
  2055.      ActionKeysHelp(pGpfParms);
  2056.      return;
  2057.     /******************************************************************/
  2058.     /* Name  "IndxHelp".                          */
  2059.     /* Text  "Help ~Index...".                          */
  2060.     /******************************************************************/
  2061.     case ID_INDXHELP:
  2062.      ActionIndxHelp(pGpfParms);
  2063.      return;
  2064.     /******************************************************************/
  2065.     /* Name  "ContHelp".                          */
  2066.     /* Text  "Help ~Contents...".                      */
  2067.     /******************************************************************/
  2068.     case ID_CONTHELP:
  2069.      ActionContHelp(pGpfParms);
  2070.      return;
  2071.     /******************************************************************/
  2072.     /* Name  "About".                              */
  2073.     /* Text  "~About".                              */
  2074.     /******************************************************************/
  2075.     case ID_ABOUT:
  2076.      ActionAbout(pGpfParms);
  2077.      return;
  2078.     /******************************************************************/
  2079.     /* Name  "ExecExit".                          */
  2080.     /* Text  "~Exit...".                          */
  2081.     /******************************************************************/
  2082.     case ID_EXECEXIT:
  2083.      ActionExecExit(pGpfParms);
  2084.      return;
  2085.     /******************************************************************/
  2086.     /* Name  "About3".                              */
  2087.     /* Text  "~About".                              */
  2088.     /******************************************************************/
  2089.     case ID_ABOUT3:
  2090.      ActionAbout3(pGpfParms);
  2091.      return;
  2092.     /******************************************************************/
  2093.     /* Name  "AboutMenuBitMap".                       */
  2094.     /* Text  " ".                              */
  2095.     /******************************************************************/
  2096.     case ID_ABOUTMENUBITMAP:
  2097.      ActionAboutMenuBitMap(pGpfParms);
  2098.      return;
  2099.   }
  2100.   /* Take no action for any other selections                  */
  2101.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2102. }
  2103. /**********************************************************************/
  2104. /* End of Private Function: CommandMainWindow                  */
  2105. /**********************************************************************/
  2106. /**********************************************************************/
  2107.  
  2108.  
  2109. /**********************************************************************/
  2110. /**********************************************************************/
  2111. /*                                      */
  2112. /*   STATIC PRIVATE FUNCTION: ActionMenuExit                  */
  2113. /*                                      */
  2114. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2115. /*   received by the window procedure.                      */
  2116. /*   Window "MainWindow".                          */
  2117. /*                                      */
  2118. /**********************************************************************/
  2119.  
  2120. static VOID ActionMenuExit( PGPFPARMS pGpfParms )
  2121. {
  2122.   /* Switch according to Control chosen                   */
  2123.   switch( pGpfParms->Notify )
  2124.   {
  2125.    case COMMAND:
  2126.     /**************************************************************/
  2127.     /* Exit selected                          */
  2128.     /**************************************************************/
  2129.     WinPostMsg( hwndMainWindow, WM_QUIT, 0L, 0L );    
  2130.     return;
  2131.   }
  2132.   /* Take no action for any other selections                  */
  2133. }
  2134. /**********************************************************************/
  2135. /* End of Private Function                          */
  2136. /**********************************************************************/
  2137. /**********************************************************************/
  2138.  
  2139.  
  2140. /**********************************************************************/
  2141. /**********************************************************************/
  2142. /*                                      */
  2143. /*   STATIC PRIVATE FUNCTION: ActionListDep                  */
  2144. /*                                      */
  2145. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2146. /*   received by the window procedure.                      */
  2147. /*   Window "MainWindow".                          */
  2148. /*                                      */
  2149. /**********************************************************************/
  2150.  
  2151. static VOID ActionListDep( PGPFPARMS pGpfParms )
  2152. {
  2153.   /* Switch according to Control chosen                   */
  2154.   switch( pGpfParms->Notify )
  2155.   {
  2156.    case COMMAND:
  2157.     /**************************************************************/
  2158.     /* Show Window "ListStaffWindow".                  */
  2159.     /**************************************************************/
  2160.     ShowListStaffWindow(NULL);
  2161.     return;
  2162.   }
  2163.   /* Take no action for any other selections                  */
  2164. }
  2165. /**********************************************************************/
  2166. /* End of Private Function                          */
  2167. /**********************************************************************/
  2168. /**********************************************************************/
  2169.  
  2170.  
  2171. /**********************************************************************/
  2172. /**********************************************************************/
  2173. /*                                      */
  2174. /*   STATIC PRIVATE FUNCTION: ActionOrgList                  */
  2175. /*                                      */
  2176. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2177. /*   received by the window procedure.                      */
  2178. /*   Window "MainWindow".                          */
  2179. /*                                      */
  2180. /**********************************************************************/
  2181.  
  2182. static VOID ActionOrgList( PGPFPARMS pGpfParms )
  2183. {
  2184.   /* Switch according to Control chosen                   */
  2185.   switch( pGpfParms->Notify )
  2186.   {
  2187.    case COMMAND:
  2188.     /**************************************************************/
  2189.     /* Show Window "ListOrgWindow".                   */
  2190.     /**************************************************************/
  2191.     ShowListOrgWindow(NULL);
  2192.     return;
  2193.   }
  2194.   /* Take no action for any other selections                  */
  2195. }
  2196. /**********************************************************************/
  2197. /* End of Private Function                          */
  2198. /**********************************************************************/
  2199. /**********************************************************************/
  2200.  
  2201.  
  2202. /**********************************************************************/
  2203. /**********************************************************************/
  2204. /*                                      */
  2205. /*   STATIC PRIVATE FUNCTION: ActionMsgInfo                  */
  2206. /*                                      */
  2207. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2208. /*   received by the window procedure.                      */
  2209. /*   Window "MainWindow".                          */
  2210. /*                                      */
  2211. /**********************************************************************/
  2212.  
  2213. static VOID ActionMsgInfo( PGPFPARMS pGpfParms )
  2214. {
  2215.   /* Switch according to Control chosen                   */
  2216.   switch( pGpfParms->Notify )
  2217.   {
  2218.    case COMMAND:
  2219.     /**************************************************************/
  2220.     /* SwapMark Menu/Item "MsgInfo".                  */
  2221.     /* Window "MainWindow".                       */
  2222.     /**************************************************************/
  2223.     GpfMenuSwapTick(hwndFrameMainWindow,ID_MSGINFO);
  2224.     /**************************************************************/
  2225.     /* Alternate MsgInfo.                          */
  2226.     /**************************************************************/
  2227.     if (AcceptMsgInfo)
  2228.         AcceptMsgInfo = FALSE;
  2229.     else
  2230.         AcceptMsgInfo = TRUE;
  2231.     return;
  2232.   }
  2233.   /* Take no action for any other selections                  */
  2234. }
  2235. /**********************************************************************/
  2236. /* End of Private Function                          */
  2237. /**********************************************************************/
  2238. /**********************************************************************/
  2239.  
  2240.  
  2241. /**********************************************************************/
  2242. /**********************************************************************/
  2243. /*                                      */
  2244. /*   STATIC PRIVATE FUNCTION: ActionMsg1                  */
  2245. /*                                      */
  2246. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2247. /*   received by the window procedure.                      */
  2248. /*   Window "MainWindow".                          */
  2249. /*                                      */
  2250. /**********************************************************************/
  2251.  
  2252. static VOID ActionMsg1( PGPFPARMS pGpfParms )    
  2253. {
  2254.   /* Switch according to Control chosen                   */
  2255.   switch( pGpfParms->Notify )
  2256.   {
  2257.    case COMMAND:
  2258.     /**************************************************************/
  2259.     /* Send Message "Msg001".                      */
  2260.     /**************************************************************/
  2261.     GpfSendMsg(ID_MSG001);    
  2262.     return;
  2263.   }
  2264.   /* Take no action for any other selections                  */
  2265. }
  2266. /**********************************************************************/
  2267. /* End of Private Function                          */
  2268. /**********************************************************************/
  2269. /**********************************************************************/
  2270.  
  2271.  
  2272. /**********************************************************************/
  2273. /**********************************************************************/
  2274. /*                                      */
  2275. /*   STATIC PRIVATE FUNCTION: ActionMsg2                  */
  2276. /*                                      */
  2277. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2278. /*   received by the window procedure.                      */
  2279. /*   Window "MainWindow".                          */
  2280. /*                                      */
  2281. /**********************************************************************/
  2282.  
  2283. static VOID ActionMsg2( PGPFPARMS pGpfParms )    
  2284. {
  2285.   /* Switch according to Control chosen                   */
  2286.   switch( pGpfParms->Notify )
  2287.   {
  2288.    case COMMAND:
  2289.     /**************************************************************/
  2290.     /* Send Message "Msg002".                      */
  2291.     /**************************************************************/
  2292.     GpfSendMsg(ID_MSG002);    
  2293.     return;
  2294.   }
  2295.   /* Take no action for any other selections                  */
  2296. }
  2297. /**********************************************************************/
  2298. /* End of Private Function                          */
  2299. /**********************************************************************/
  2300. /**********************************************************************/
  2301.  
  2302.  
  2303. /**********************************************************************/
  2304. /**********************************************************************/
  2305. /*                                      */
  2306. /*   STATIC PRIVATE FUNCTION: ActionMsg3                  */
  2307. /*                                      */
  2308. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2309. /*   received by the window procedure.                      */
  2310. /*   Window "MainWindow".                          */
  2311. /*                                      */
  2312. /**********************************************************************/
  2313.  
  2314. static VOID ActionMsg3( PGPFPARMS pGpfParms )    
  2315. {
  2316.   /* Switch according to Control chosen                   */
  2317.   switch( pGpfParms->Notify )
  2318.   {
  2319.    case COMMAND:
  2320.     /**************************************************************/
  2321.     /* Send Message "Msg003".                      */
  2322.     /**************************************************************/
  2323.     GpfSendMsg(ID_MSG003);    
  2324.     return;
  2325.   }
  2326.   /* Take no action for any other selections                  */
  2327. }
  2328. /**********************************************************************/
  2329. /* End of Private Function                          */
  2330. /**********************************************************************/
  2331. /**********************************************************************/
  2332.  
  2333.  
  2334. /**********************************************************************/
  2335. /**********************************************************************/
  2336. /*                                      */
  2337. /*   STATIC PRIVATE FUNCTION: ActionMsg4                  */
  2338. /*                                      */
  2339. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2340. /*   received by the window procedure.                      */
  2341. /*   Window "MainWindow".                          */
  2342. /*                                      */
  2343. /**********************************************************************/
  2344.  
  2345. static VOID ActionMsg4( PGPFPARMS pGpfParms )    
  2346. {
  2347.   /* Switch according to Control chosen                   */
  2348.   switch( pGpfParms->Notify )
  2349.   {
  2350.    case COMMAND:
  2351.     /**************************************************************/
  2352.     /* Send Message "Msg004".                      */
  2353.     /**************************************************************/
  2354.     GpfSendMsg(ID_MSG004);    
  2355.     return;
  2356.   }
  2357.   /* Take no action for any other selections                  */
  2358. }
  2359. /**********************************************************************/
  2360. /* End of Private Function                          */
  2361. /**********************************************************************/
  2362. /**********************************************************************/
  2363.  
  2364.  
  2365. /**********************************************************************/
  2366. /**********************************************************************/
  2367. /*                                      */
  2368. /*   STATIC PRIVATE FUNCTION: ActionMsg5                  */
  2369. /*                                      */
  2370. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2371. /*   received by the window procedure.                      */
  2372. /*   Window "MainWindow".                          */
  2373. /*                                      */
  2374. /**********************************************************************/
  2375.  
  2376. static VOID ActionMsg5( PGPFPARMS pGpfParms )    
  2377. {
  2378.   /* Switch according to Control chosen                   */
  2379.   switch( pGpfParms->Notify )
  2380.   {
  2381.    case COMMAND:
  2382.     /**************************************************************/
  2383.     /* Send Message "Msg005".                      */
  2384.     /**************************************************************/
  2385.     GpfSendMsg(ID_MSG005);    
  2386.     return;
  2387.   }
  2388.   /* Take no action for any other selections                  */
  2389. }
  2390. /**********************************************************************/
  2391. /* End of Private Function                          */
  2392. /**********************************************************************/
  2393. /**********************************************************************/
  2394.  
  2395.  
  2396. /**********************************************************************/
  2397. /**********************************************************************/
  2398. /*                                      */
  2399. /*   STATIC PRIVATE FUNCTION: ActionPullDownMark              */
  2400. /*                                      */
  2401. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2402. /*   received by the window procedure.                      */
  2403. /*   Window "MainWindow".                          */
  2404. /*                                      */
  2405. /**********************************************************************/
  2406.  
  2407. static VOID ActionPullDownMark( PGPFPARMS pGpfParms )
  2408. {
  2409.   /* Switch according to Control chosen                   */
  2410.   switch( pGpfParms->Notify )
  2411.   {
  2412.    case COMMAND:
  2413.     /**************************************************************/
  2414.     /* Mark Menu/Item "PullDownSwap".                  */
  2415.     /* Window "MainWindow".                       */
  2416.     /**************************************************************/
  2417.     GpfMenuTick(hwndFrameMainWindow,ID_PULLDOWNSWAP,TRUE);    
  2418.     return;
  2419.   }
  2420.   /* Take no action for any other selections                  */
  2421. }
  2422. /**********************************************************************/
  2423. /* End of Private Function                          */
  2424. /**********************************************************************/
  2425. /**********************************************************************/
  2426.  
  2427.  
  2428. /**********************************************************************/
  2429. /**********************************************************************/
  2430. /*                                      */
  2431. /*   STATIC PRIVATE FUNCTION: ActionPullDownUnMark              */
  2432. /*                                      */
  2433. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2434. /*   received by the window procedure.                      */
  2435. /*   Window "MainWindow".                          */
  2436. /*                                      */
  2437. /**********************************************************************/
  2438.  
  2439. static VOID ActionPullDownUnMark( PGPFPARMS pGpfParms )
  2440. {
  2441.   /* Switch according to Control chosen                   */
  2442.   switch( pGpfParms->Notify )
  2443.   {
  2444.    case COMMAND:
  2445.     /**************************************************************/
  2446.     /* UnMark Menu/Item "PullDownSwap".                  */
  2447.     /* Window "MainWindow".                       */
  2448.     /**************************************************************/
  2449.     GpfMenuTick(hwndFrameMainWindow,ID_PULLDOWNSWAP,FALSE);
  2450.     return;
  2451.   }
  2452.   /* Take no action for any other selections                  */
  2453. }
  2454. /**********************************************************************/
  2455. /* End of Private Function                          */
  2456. /**********************************************************************/
  2457. /**********************************************************************/
  2458.  
  2459.  
  2460. /**********************************************************************/
  2461. /**********************************************************************/
  2462. /*                                      */
  2463. /*   STATIC PRIVATE FUNCTION: ActionPullDownSwap              */
  2464. /*                                      */
  2465. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2466. /*   received by the window procedure.                      */
  2467. /*   Window "MainWindow".                          */
  2468. /*                                      */
  2469. /**********************************************************************/
  2470.  
  2471. static VOID ActionPullDownSwap( PGPFPARMS pGpfParms )
  2472. {
  2473.   /* Switch according to Control chosen                   */
  2474.   switch( pGpfParms->Notify )
  2475.   {
  2476.    case COMMAND:
  2477.     /**************************************************************/
  2478.     /* SwapMark Menu/Item "PullDownSwap".                  */
  2479.     /* Window "MainWindow".                       */
  2480.     /**************************************************************/
  2481.     GpfMenuSwapTick(hwndFrameMainWindow,ID_PULLDOWNSWAP);
  2482.     return;
  2483.   }
  2484.   /* Take no action for any other selections                  */
  2485. }
  2486. /**********************************************************************/
  2487. /* End of Private Function                          */
  2488. /**********************************************************************/
  2489. /**********************************************************************/
  2490.  
  2491.  
  2492. /**********************************************************************/
  2493. /**********************************************************************/
  2494. /*                                      */
  2495. /*   STATIC PRIVATE FUNCTION: ActionForHelp                  */
  2496. /*                                      */
  2497. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2498. /*   received by the window procedure.                      */
  2499. /*   Window "MainWindow".                          */
  2500. /*                                      */
  2501. /**********************************************************************/
  2502.  
  2503. static VOID ActionForHelp( PGPFPARMS pGpfParms )
  2504. {
  2505.   /* Switch according to Control chosen                   */
  2506.   switch( pGpfParms->Notify )
  2507.   {
  2508.    case COMMAND:
  2509.     /**************************************************************/
  2510.     /* Help For Help.                          */
  2511.     /**************************************************************/
  2512.     if (hwndHelp)
  2513.         WinSendMsg( hwndHelp, HM_DISPLAY_HELP,0L,0L);
  2514.     return;
  2515.   }
  2516.   /* Take no action for any other selections                  */
  2517. }
  2518. /**********************************************************************/
  2519. /* End of Private Function                          */
  2520. /**********************************************************************/
  2521. /**********************************************************************/
  2522.  
  2523.  
  2524. /**********************************************************************/
  2525. /**********************************************************************/
  2526. /*                                      */
  2527. /*   STATIC PRIVATE FUNCTION: ActionExHelp                  */
  2528. /*                                      */
  2529. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2530. /*   received by the window procedure.                      */
  2531. /*   Window "MainWindow".                          */
  2532. /*                                      */
  2533. /**********************************************************************/
  2534.  
  2535. static VOID ActionExHelp( PGPFPARMS pGpfParms )
  2536. {
  2537.   /* Switch according to Control chosen                   */
  2538.   switch( pGpfParms->Notify )
  2539.   {
  2540.    case COMMAND:
  2541.     /**************************************************************/
  2542.     /* Help Extended.                          */
  2543.     /**************************************************************/
  2544.     if (hwndHelp)
  2545.         WinSendMsg( hwndHelp, HM_DISPLAY_HELP,
  2546.             MPFROMSHORT( ID_SAMPLE ),
  2547.             0L );
  2548.     return;
  2549.   }
  2550.   /* Take no action for any other selections                  */
  2551. }
  2552. /**********************************************************************/
  2553. /* End of Private Function                          */
  2554. /**********************************************************************/
  2555. /**********************************************************************/
  2556.  
  2557.  
  2558. /**********************************************************************/
  2559. /**********************************************************************/
  2560. /*                                      */
  2561. /*   STATIC PRIVATE FUNCTION: ActionKeysHelp                  */
  2562. /*                                      */
  2563. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2564. /*   received by the window procedure.                      */
  2565. /*   Window "MainWindow".                          */
  2566. /*                                      */
  2567. /**********************************************************************/
  2568.  
  2569. static VOID ActionKeysHelp( PGPFPARMS pGpfParms )
  2570. {
  2571.   /* Switch according to Control chosen                   */
  2572.   switch( pGpfParms->Notify )
  2573.   {
  2574.    case COMMAND:
  2575.     /**************************************************************/
  2576.     /* Help Keys.                              */
  2577.     /**************************************************************/
  2578.     if (hwndHelp)
  2579.         WinSendMsg( hwndHelp, HM_KEYS_HELP,0l,0l);
  2580.     return;
  2581.   }
  2582.   /* Take no action for any other selections                  */
  2583. }
  2584. /**********************************************************************/
  2585. /* End of Private Function                          */
  2586. /**********************************************************************/
  2587. /**********************************************************************/
  2588.  
  2589.  
  2590. /**********************************************************************/
  2591. /**********************************************************************/
  2592. /*                                      */
  2593. /*   STATIC PRIVATE FUNCTION: ActionIndxHelp                  */
  2594. /*                                      */
  2595. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2596. /*   received by the window procedure.                      */
  2597. /*   Window "MainWindow".                          */
  2598. /*                                      */
  2599. /**********************************************************************/
  2600.  
  2601. static VOID ActionIndxHelp( PGPFPARMS pGpfParms )
  2602. {
  2603.   /* Switch according to Control chosen                   */
  2604.   switch( pGpfParms->Notify )
  2605.   {
  2606.    case COMMAND:
  2607.     /**************************************************************/
  2608.     /* Help Index.                              */
  2609.     /**************************************************************/
  2610.     if (hwndHelp)
  2611.         WinSendMsg( hwndHelp, HM_HELP_INDEX,0l,0l);
  2612.     return;
  2613.   }
  2614.   /* Take no action for any other selections                  */
  2615. }
  2616. /**********************************************************************/
  2617. /* End of Private Function                          */
  2618. /**********************************************************************/
  2619. /**********************************************************************/
  2620.  
  2621.  
  2622. /**********************************************************************/
  2623. /**********************************************************************/
  2624. /*                                      */
  2625. /*   STATIC PRIVATE FUNCTION: ActionContHelp                  */
  2626. /*                                      */
  2627. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2628. /*   received by the window procedure.                      */
  2629. /*   Window "MainWindow".                          */
  2630. /*                                      */
  2631. /**********************************************************************/
  2632.  
  2633. static VOID ActionContHelp( PGPFPARMS pGpfParms )
  2634. {
  2635.   /* Switch according to Control chosen                   */
  2636.   switch( pGpfParms->Notify )
  2637.   {
  2638.    case COMMAND:
  2639.     /**************************************************************/
  2640.     /* Help Contents.                          */
  2641.     /**************************************************************/
  2642.     if (hwndHelp)
  2643.         WinSendMsg( hwndHelp, HM_HELP_CONTENTS,0l,0l);
  2644.     return;
  2645.   }
  2646.   /* Take no action for any other selections                  */
  2647. }
  2648. /**********************************************************************/
  2649. /* End of Private Function                          */
  2650. /**********************************************************************/
  2651. /**********************************************************************/
  2652.  
  2653.  
  2654. /**********************************************************************/
  2655. /**********************************************************************/
  2656. /*                                      */
  2657. /*   STATIC PRIVATE FUNCTION: ActionAbout                  */
  2658. /*                                      */
  2659. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2660. /*   received by the window procedure.                      */
  2661. /*   Window "MainWindow".                          */
  2662. /*                                      */
  2663. /**********************************************************************/
  2664.  
  2665. static VOID ActionAbout( PGPFPARMS pGpfParms )    
  2666. {
  2667.   /* Switch according to Control chosen                   */
  2668.   switch( pGpfParms->Notify )
  2669.   {
  2670.    case COMMAND:
  2671.     /**************************************************************/
  2672.     /* Disable Control "UserButton".                  */
  2673.     /* Window "ListStaffWindow".                      */
  2674.     /**************************************************************/
  2675.     WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
  2676.             ID_USERBUTTON),
  2677.             FALSE);
  2678.     /**************************************************************/
  2679.     /* Disable Menu/Item "About".                      */
  2680.     /* Window "MainWindow".                       */
  2681.     /**************************************************************/
  2682.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT,TRUE);
  2683.     /**************************************************************/
  2684.     /* Disable Menu/Item "About1".                      */
  2685.     /* Window "MainWindow".                       */
  2686.     /**************************************************************/
  2687.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
  2688.     /**************************************************************/
  2689.     /* Show Window "AboutWindow".                      */
  2690.     /**************************************************************/
  2691.     ShowAboutWindow(NULL);
  2692.     return;
  2693.   }
  2694.   /* Take no action for any other selections                  */
  2695. }
  2696. /**********************************************************************/
  2697. /* End of Private Function                          */
  2698. /**********************************************************************/
  2699. /**********************************************************************/
  2700.  
  2701.  
  2702. /**********************************************************************/
  2703. /**********************************************************************/
  2704. /*                                      */
  2705. /*   STATIC PRIVATE FUNCTION: ActionExecExit                  */
  2706. /*                                      */
  2707. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2708. /*   received by the window procedure.                      */
  2709. /*   Window "MainWindow".                          */
  2710. /*                                      */
  2711. /**********************************************************************/
  2712.  
  2713. static VOID ActionExecExit( PGPFPARMS pGpfParms )
  2714. {
  2715.   /* Switch according to Control chosen                   */
  2716.   switch( pGpfParms->Notify )
  2717.   {
  2718.    case COMMAND:
  2719.     /**************************************************************/
  2720.     /* Exit selected                          */
  2721.     /**************************************************************/
  2722.     WinPostMsg( hwndMainWindow, WM_QUIT, 0L, 0L );    
  2723.     return;
  2724.   }
  2725.   /* Take no action for any other selections                  */
  2726. }
  2727. /**********************************************************************/
  2728. /* End of Private Function                          */
  2729. /**********************************************************************/
  2730. /**********************************************************************/
  2731.  
  2732.  
  2733. /**********************************************************************/
  2734. /**********************************************************************/
  2735. /*                                      */
  2736. /*   STATIC PRIVATE FUNCTION: ActionAbout3                  */
  2737. /*                                      */
  2738. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2739. /*   received by the window procedure.                      */
  2740. /*   Window "MainWindow".                          */
  2741. /*                                      */
  2742. /**********************************************************************/
  2743.  
  2744. static VOID ActionAbout3( PGPFPARMS pGpfParms )
  2745. {
  2746.   /* Switch according to Control chosen                   */
  2747.   switch( pGpfParms->Notify )
  2748.   {
  2749.    case COMMAND:
  2750.     /**************************************************************/
  2751.     /* Disable Control "UserButton".                  */
  2752.     /* Window "ListStaffWindow".                      */
  2753.     /**************************************************************/
  2754.     WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
  2755.             ID_USERBUTTON),
  2756.             FALSE);
  2757.     /**************************************************************/
  2758.     /* Disable Menu/Item "About".                      */
  2759.     /* Window "MainWindow".                       */
  2760.     /**************************************************************/
  2761.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT,TRUE);
  2762.     /**************************************************************/
  2763.     /* Disable Menu/Item "About1".                      */
  2764.     /* Window "MainWindow".                       */
  2765.     /**************************************************************/
  2766.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
  2767.     /**************************************************************/
  2768.     /* Show Window "AboutWindow".                      */
  2769.     /**************************************************************/
  2770.     ShowAboutWindow(NULL);
  2771.     return;
  2772.   }
  2773.   /* Take no action for any other selections                  */
  2774. }
  2775. /**********************************************************************/
  2776. /* End of Private Function                          */
  2777. /**********************************************************************/
  2778. /**********************************************************************/
  2779.  
  2780.  
  2781. /**********************************************************************/
  2782. /**********************************************************************/
  2783. /*                                      */
  2784. /*   STATIC PRIVATE FUNCTION: ActionAboutMenuBitMap              */
  2785. /*                                      */
  2786. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2787. /*   received by the window procedure.                      */
  2788. /*   Window "MainWindow".                          */
  2789. /*                                      */
  2790. /**********************************************************************/
  2791.  
  2792. static VOID ActionAboutMenuBitMap( PGPFPARMS pGpfParms )
  2793. {
  2794.   /* Switch according to Control chosen                   */
  2795.   switch( pGpfParms->Notify )
  2796.   {
  2797.    case COMMAND:
  2798.     /**************************************************************/
  2799.     /* Disable Control "UserButton".                  */
  2800.     /* Window "ListStaffWindow".                      */
  2801.     /**************************************************************/
  2802.     WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
  2803.             ID_USERBUTTON),
  2804.             FALSE);
  2805.     /**************************************************************/
  2806.     /* Disable Menu/Item "About".                      */
  2807.     /* Window "MainWindow".                       */
  2808.     /**************************************************************/
  2809.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT,TRUE);
  2810.     /**************************************************************/
  2811.     /* Disable Menu/Item "About1".                      */
  2812.     /* Window "MainWindow".                       */
  2813.     /**************************************************************/
  2814.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
  2815.     /**************************************************************/
  2816.     /* Show Window "AboutWindow".                      */
  2817.     /**************************************************************/
  2818.     ShowAboutWindow(NULL);
  2819.     return;
  2820.   }
  2821.   /* Take no action for any other selections                  */
  2822. }
  2823. /**********************************************************************/
  2824. /* End of Private Function                          */
  2825. /**********************************************************************/
  2826. /**********************************************************************/
  2827.  
  2828.  
  2829. /**********************************************************************/
  2830. /**********************************************************************/
  2831. /*                                      */
  2832. /*   PRIVATE FUNCTION: MoveMainWindowToData                  */
  2833. /*                                      */
  2834. /*   Move "MainWindow" To Assosiate Data.                  */
  2835. /*                                      */
  2836. /**********************************************************************/
  2837.  
  2838. BOOL  MoveMainWindowToData ( VOID )
  2839.  {
  2840.   UCHAR  String[32];
  2841.   PUCHAR Token;
  2842.  
  2843.   String[0] = 0;     /* Null, Delete Unreferenced Local variable */
  2844.   Token  = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  2845.  
  2846.  
  2847.       return (TRUE);
  2848.  }
  2849. /**********************************************************************/
  2850. /* End of Private Function: MoveMainWindowToData              */
  2851. /**********************************************************************/
  2852. /**********************************************************************/
  2853.  
  2854.  
  2855.  
  2856. /**********************************************************************/
  2857. /**********************************************************************/
  2858. /*                                      */
  2859. /*   PRIVATE FUNCTION: MoveDataToMainWindow                  */
  2860. /*                                      */
  2861. /*   Move Data To Window "MainWindow".                      */
  2862. /*                                      */
  2863. /**********************************************************************/
  2864.  
  2865. BOOL  MoveDataToMainWindow ( VOID )
  2866.  {
  2867.   UCHAR  String[32];
  2868.   PUCHAR Token;
  2869.  
  2870.   String[0] = 0;      /* Null, Delete Unreferenced Local variable */
  2871.   Token   = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  2872.  
  2873.  
  2874.       return (TRUE);
  2875.  }
  2876. /**********************************************************************/
  2877. /* End of Private Function: MoveDataToMainWindow              */
  2878. /**********************************************************************/
  2879. /**********************************************************************/
  2880.  
  2881.  
  2882.  
  2883. /**********************************************************************/
  2884. /**********************************************************************/
  2885. /*                                      */
  2886. /*   PRIVATE FUNCTION: WmInitWndMainWindow                  */
  2887. /*                                      */
  2888. /*   Wm Init Window "MainWindow".                      */
  2889. /*                                      */
  2890. /**********************************************************************/
  2891.  
  2892. static VOID WmInitWndMainWindow ( PGPFPARMS pGpfParms )
  2893.  {
  2894.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2895.     /**************************************************************/
  2896.     /* Center Window "MainWindow".                      */
  2897.     /* Positions Window in the center of the screen           */
  2898.     /**************************************************************/
  2899.     GpfSetCentreWindow(hwndFrameMainWindow);
  2900.  }
  2901. /**********************************************************************/
  2902. /* End of Private Function: WmInitWndMainWindow               */
  2903. /**********************************************************************/
  2904. /**********************************************************************/
  2905.  
  2906.  
  2907.  
  2908. /**********************************************************************/
  2909. /**********************************************************************/
  2910. /*                                      */
  2911. /*   PRIVATE FUNCTION: WmActiveMainWindow                  */
  2912. /*                                      */
  2913. /*   Wm Activate Window "MainWindow".                      */
  2914. /*                                      */
  2915. /**********************************************************************/
  2916.  
  2917. static VOID WmActiveMainWindow ( PGPFPARMS pGpfParms )    
  2918.  {
  2919.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  2920.  }
  2921. /**********************************************************************/
  2922. /* End of Private Function: WmActiveMainWindow                  */
  2923. /**********************************************************************/
  2924. /**********************************************************************/
  2925.  
  2926.  
  2927.  
  2928. /**********************************************************************/
  2929. /**********************************************************************/
  2930. /*                                      */
  2931. /*   PRIVATE FUNCTION: WmDeActiveMainWindow                  */
  2932. /*                                      */
  2933. /*   DeActivate Window "MainWindow".                      */
  2934. /*                                      */
  2935. /**********************************************************************/
  2936.  
  2937. static VOID WmDeActiveMainWindow ( PGPFPARMS pGpfParms )
  2938.  {
  2939.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  2940.  }
  2941. /**********************************************************************/
  2942. /* End of Private Function: WmDeActiveMainWindow              */
  2943. /**********************************************************************/
  2944. /**********************************************************************/
  2945.  
  2946.  
  2947.  
  2948. /**********************************************************************/
  2949. /**********************************************************************/
  2950. /*                                      */
  2951. /*   PRIVATE FUNCTION: WmCreateMainWindow                  */
  2952. /*                                      */
  2953. /*   Wm Create Window "MainWindow".                      */
  2954. /*                                      */
  2955. /**********************************************************************/
  2956.  
  2957. static VOID WmCreateMainWindow ( PGPFPARMS pGpfParms )    
  2958.  {
  2959.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2960.  }
  2961. /**********************************************************************/
  2962. /* End of Private Function: WmCreateMainWindow                  */
  2963. /**********************************************************************/
  2964. /**********************************************************************/
  2965.  
  2966.  
  2967.  
  2968. /**********************************************************************/
  2969. /**********************************************************************/
  2970. /*                                      */
  2971. /*   PRIVATE FUNCTION: WmDestroyMainWindow                  */
  2972. /*                                      */
  2973. /*   Wm Destroy Window "MainWindow".                      */
  2974. /*                                      */
  2975. /**********************************************************************/
  2976.  
  2977. static VOID WmDestroyMainWindow ( PGPFPARMS pGpfParms )
  2978.  {
  2979.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2980.  }
  2981. /**********************************************************************/
  2982. /* End of Private Function: WmDestroyMainWindow               */
  2983. /**********************************************************************/
  2984. /**********************************************************************/
  2985.  
  2986.  
  2987.  
  2988. /**********************************************************************/
  2989. /**********************************************************************/
  2990. /*                                      */
  2991. /*   PRIVATE FUNCTION: WmPaintMainWindow                  */
  2992. /*                                      */
  2993. /*   Wm Paint Window "MainWindow".                      */
  2994. /*                                      */
  2995. /**********************************************************************/
  2996.  
  2997. static VOID WmPaintMainWindow ( PGPFPARMS pGpfParms )
  2998.  {
  2999.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  3000.  }
  3001. /**********************************************************************/
  3002. /* End of Private Function: WmPaintMainWindow                  */
  3003. /**********************************************************************/
  3004. /**********************************************************************/
  3005.  
  3006.  
  3007.  
  3008. /**********************************************************************/
  3009. /**********************************************************************/
  3010. /*                                      */
  3011. /*   PRIVATE FUNCTION: WmShowMainWindow                   */
  3012. /*                                      */
  3013. /*   Wm Show Window "MainWindow".                      */
  3014. /*                                      */
  3015. /**********************************************************************/
  3016.  
  3017. static VOID WmShowMainWindow ( PGPFPARMS pGpfParms )
  3018.  {
  3019.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  3020.  }
  3021. /**********************************************************************/
  3022. /* End of Private Function: WmShowMainWindow                  */
  3023. /**********************************************************************/
  3024. /**********************************************************************/
  3025.  
  3026.  
  3027.  
  3028. /**********************************************************************/
  3029. /**********************************************************************/
  3030. /*                                      */
  3031. /*   PRIVATE FUNCTION: WmHideMainWindow                   */
  3032. /*                                      */
  3033. /*   Wm Hide Window "MainWindow".                      */
  3034. /*                                      */
  3035. /**********************************************************************/
  3036.  
  3037. static VOID WmHideMainWindow ( PGPFPARMS pGpfParms )
  3038.  {
  3039.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  3040.  }
  3041. /**********************************************************************/
  3042. /* End of Private Function: WmHideMainWindow                  */
  3043. /**********************************************************************/
  3044. /**********************************************************************/
  3045.  
  3046.  
  3047. /**********************************************************************/
  3048. /**********************************************************************/
  3049. /*                                      */
  3050. /*   PRIVATE FUNCTION: ShowListStaffWindow                  */
  3051. /*                                      */
  3052. /*   Show Window "ListStaffWindow".                      */
  3053. /*                                      */
  3054. /**********************************************************************/
  3055.  
  3056. BOOL  ShowListStaffWindow( PVOID pCrtParms )
  3057.  {
  3058.  SWP Swp;
  3059.  
  3060.               /* Make sure the window was not created. */
  3061.    if (!hwndFrameListStaffWindow)
  3062.     CreateListStaffWindow(pCrtParms);
  3063.    WinSetWindowPos( hwndFrameListStaffWindow,
  3064.             NULL,0,0,0,0,SWP_RESTORE);
  3065.    WinQueryWindowPos( hwndFrameListStaffWindow, &Swp );
  3066.    WinSetWindowPos( hwndFrameListStaffWindow,
  3067.             HWND_TOP,
  3068.             Swp.x,Swp.y,Swp.cx,Swp.cy,
  3069.             SWP_ZORDER | SWP_SIZE | SWP_MOVE |
  3070.             SWP_ACTIVATE | SWP_SHOW
  3071.           );
  3072.    return(FALSE);
  3073.  }
  3074.  
  3075. /**********************************************************************/
  3076. /**********************************************************************/
  3077. /*                                      */
  3078. /*   PRIVATE FUNCTION: DismissListStaffWindow                  */
  3079. /*                                      */
  3080. /*   Dismiss Window Hide - Window "ListStaffWindow".              */
  3081. /*                                      */
  3082. /**********************************************************************/
  3083.  
  3084. VOID  DismissListStaffWindow( BOOL Rcode )
  3085.  {
  3086.  
  3087.    Rcode = Rcode;  /* Null , For Delete Unreferenced Formal Parameter */
  3088.                                /* Hide Window */
  3089.    WinShowWindow(hwndFrameListStaffWindow, FALSE);
  3090.  
  3091.  }
  3092.  
  3093. /**********************************************************************/
  3094. /**********************************************************************/
  3095. /*                                      */
  3096. /*   PRIVATE FUNCTION: CreateListStaffWindow                  */
  3097. /*                                      */
  3098. /*   Create the window "ListStaffWindow" And Controls.              */
  3099. /*                                      */
  3100. /**********************************************************************/
  3101.  
  3102. VOID CreateListStaffWindow( PVOID pCrtParms)
  3103.  {
  3104.   /********************************************************************/
  3105.   /*   Register the window class "ListStaffWindow".              */
  3106.   /********************************************************************/
  3107.   WinRegisterClass(              /* Register window class    */
  3108.       habMainTask,              /* Anchor block handle      */
  3109.       "ListStaffWindow",          /* Window class name          */
  3110.       fnwpListStaffWindow,          /* Address window procedure */
  3111.       CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style          */
  3112.       CS_MOVENOTIFY |          /* Class style          */
  3113.       CS_SIZEREDRAW | CS_SYNCPAINT,   /* Class style          */
  3114.       EXTRAWORDS              /* Extra window words       */
  3115.       );
  3116.  
  3117.   /********************************************************************/
  3118.   /*   Create the window "ListStaffWindow".                  */
  3119.   /********************************************************************/
  3120.   hwndFrameListStaffWindow =                  /* Save Hwnd    */
  3121.   GpfCreateTemplate( ID_LISTSTAFFWINDOW,          /* Ressource Id */
  3122.              hmodSample,              /* Ressource Md */
  3123.              hwndMainWindow,              /* Hwnd Parent  */
  3124.              hwndMainWindow,              /* Hwnd Owner   */
  3125.              pCrtParms);              /* User Parms   */
  3126.  }
  3127. /**********************************************************************/
  3128. /* End of Private Function - CreateListStaffWindow              */
  3129. /**********************************************************************/
  3130. /**********************************************************************/
  3131.  
  3132.  
  3133.  
  3134. /**********************************************************************/
  3135. /**********************************************************************/
  3136. /*                                      */
  3137. /*  WinProc: fnwpListStaffWindow                      */
  3138. /*                                      */
  3139. /*  Controls the "ListStaffWindow" Area.                  */
  3140. /*                                      */
  3141. /*                                      */
  3142. /**********************************************************************/
  3143.  
  3144. MRESULT  EXPENTRY fnwpListStaffWindow(
  3145.           HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  3146. {
  3147.   HPS        hps;          /* Presentation space handle         */
  3148.   RECTL     rcl;          /* Window rectangle             */
  3149.   PGPFPARMS pGpfParms;          /* Far Pointer             */
  3150.   SEL        Selector;          /* Seloctor                 */
  3151.  
  3152.   /*******************************************************************/
  3153.   /* Initialize Gpf Parameters                         */
  3154.   /*******************************************************************/
  3155.   pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
  3156.   if (pGpfParms)
  3157.      {
  3158.       pGpfParms->hwnd     = hwnd;      /* window handle             */
  3159.       pGpfParms->msg     = msg;       /* message number          */
  3160.       pGpfParms->mp1     = mp1;       /* 1st (packed) parms         */
  3161.       pGpfParms->mp2     = mp2;       /* 2nd (packed) parms         */
  3162.       pGpfParms->mresult = (MRESULT) FALSE; /* Mresult             */
  3163.       pGpfParms->Command = 0;          /* Command From mp1 (SHORT 1)  */
  3164.       pGpfParms->Notify  = 0;          /* Notify  From mp1 (SHORT 2)  */
  3165.      }
  3166.  
  3167.   switch(msg)
  3168.   {
  3169.     /**************************************************************/
  3170.     /* Things to do when the Window is first initalized          */
  3171.     /**************************************************************/
  3172.    case WM_INITDLG:
  3173.     /**************************************************************/
  3174.     /*  Initialize Window 'ListStaffWindow'               */
  3175.     /**************************************************************/
  3176.     GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  3177.     WmInitWndListStaffWindow(pGpfParms); /* Init Dialog          */
  3178.     /**************************************************************/
  3179.     /*  Return pGpfParms Mresult                      */
  3180.     /**************************************************************/
  3181.     return (pGpfParms->mresult);
  3182.  
  3183.     /**************************************************************/
  3184.     /* Things to do when the Window is Activated/Deactivated      */
  3185.     /**************************************************************/
  3186.    case WM_ACTIVATE:
  3187.     if (SHORT1FROMMP(mp1))
  3188.         WmActiveListStaffWindow(pGpfParms);  /* Activate Window   */
  3189.     else
  3190.         WmDeActiveListStaffWindow(pGpfParms); /* DeActivate Window */
  3191.     return (pGpfParms->mresult);
  3192.  
  3193.     /**************************************************************/
  3194.     /* Things to do when the Window is "Show/Hide"              */
  3195.     /**************************************************************/
  3196.    case WM_SHOW:
  3197.     if (SHORT1FROMMP(mp1))
  3198.         WmShowListStaffWindow(pGpfParms);           /* Show Window */
  3199.     else
  3200.         WmHideListStaffWindow(pGpfParms);           /* Hide Window */
  3201.     return (pGpfParms->mresult);
  3202.  
  3203.     /**************************************************************/
  3204.     /* The application has asked for the window to be created.    */
  3205.     /**************************************************************/
  3206.    case WM_CREATE:
  3207.     DosAllocSeg(sizeof(GPFPARMS),&Selector,0);    /* Getmain    */
  3208.     pGpfParms = MAKEP(Selector, 0);         /* Set Pointer*/
  3209.     WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
  3210.     memset(pGpfParms,0,sizeof(GPFPARMS));        /* Clear Area */
  3211.     pGpfParms->Options |= GPF_OP_MSGINFO;     /* Set Msg Info      */
  3212.     pGpfParms->Options |= GPF_OP_ADJUSTSIZE; /* Set AdjustSize    */
  3213.     hwndListStaffWindow = hwnd;             /* Save Hwnd */
  3214.     hwndFrameListStaffWindow = GpfGetHwndFrame(hwnd);
  3215.     pGpfParms->hwnd = hwnd;            /* window handle       */
  3216.     pGpfParms->msg    = msg;               /* message number      */
  3217.     pGpfParms->mp1    = mp1;               /* 1st (packed) parms  */
  3218.     pGpfParms->mp2    = mp2;               /* 2nd (packed) parms  */
  3219.     pGpfParms->hmod = hmodSample;    
  3220.     pGpfParms->hab    = habMainTask;           /* Anchor block handle */
  3221.     WmCreateListStaffWindow(pGpfParms);    /* Create  Window      */
  3222.     break;
  3223.  
  3224.     /**************************************************************/
  3225.     /* The application has asked for the window to be destroyed.  */
  3226.     /**************************************************************/
  3227.    case WM_DESTROY:
  3228.     WmDestroyListStaffWindow(pGpfParms);        /* Destroy Window */
  3229.     hwndFrameListStaffWindow = (HWND)NULL;        /* Reset HwndFrm  */
  3230.     hwndListStaffWindow = (HWND)NULL;        /* Reset Hwnd     */
  3231.     /* Destroy Template , Help Instance and GpfParms          */
  3232.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  3233.  
  3234.     /**************************************************************/
  3235.     /* The window needs painting.                      */
  3236.     /**************************************************************/
  3237.    case WM_PAINT:
  3238.     /**************************************************************/
  3239.     /* Obtain a cache PS                          */
  3240.     /**************************************************************/
  3241.     hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
  3242.     WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect          */
  3243.     pGpfParms->hps = hps;            /* Pass Hps ( Paint ) */
  3244.     WmPaintListStaffWindow(pGpfParms);    /* Paint Window       */
  3245.     WinEndPaint( hps );            /* Release cache PS   */
  3246.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  3247.  
  3248.     /**************************************************************/
  3249.     /* Process ScrollBar received from the user              */
  3250.     /**************************************************************/
  3251.     case WM_VSCROLL:
  3252.     case WM_HSCROLL:
  3253.     /* Set Command From mp1 */
  3254.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  3255.     /* Set Notify From mp2    */
  3256.     pGpfParms->Notify = SHORT2FROMMP( mp2 );
  3257.     CommandListStaffWindow( pGpfParms );  /* Process the command  */
  3258.     return (pGpfParms->mresult);
  3259.  
  3260.     /**************************************************************/
  3261.     /* Process Controls received from the user              */
  3262.     /**************************************************************/
  3263.    case WM_CONTROL:
  3264.     /* Set Command From mp1 */
  3265.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  3266.     /* Set Notify From mp1    */
  3267.     pGpfParms->Notify = SHORT2FROMMP( mp1 );
  3268.     CommandListStaffWindow( pGpfParms );  /* Process the command  */
  3269.     return (pGpfParms->mresult);
  3270.  
  3271.     /**************************************************************/
  3272.     /* Process commands received from the user              */
  3273.     /**************************************************************/
  3274.    case WM_SYSCOMMAND:
  3275.    case WM_HELP:
  3276.    case WM_COMMAND:
  3277.     /* Set Command From mp1 */
  3278.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  3279.     pGpfParms->Notify = COMMAND;          /* Set Notify From mp1  */
  3280.     CommandListStaffWindow( pGpfParms );  /* Process the command  */
  3281.     if (pGpfParms->mresult)
  3282.         return (pGpfParms->mresult);
  3283.     /* If DID_CANCEL Dismiss Window */
  3284.     if (pGpfParms->Command == DID_CANCEL)
  3285.         DismissListStaffWindow(FALSE);
  3286.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  3287.  
  3288.     /**************************************************************/
  3289.     /* All other messages are passed to the default procedure.    */
  3290.     /**************************************************************/
  3291.    default:
  3292.     /* Pass all other messages to the default window procedure    */
  3293.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  3294.   }
  3295.   return ((MRESULT) FALSE);
  3296. }
  3297. /**********************************************************************/
  3298. /* End of window procedure - WinProc: fnwpListStaffWindow          */
  3299. /**********************************************************************/
  3300. /**********************************************************************/
  3301.  
  3302.  
  3303.  
  3304. /**********************************************************************/
  3305. /**********************************************************************/
  3306. /*                                      */
  3307. /*   PRIVATE FUNCTION: CommandListStaffWindow                  */
  3308. /*                                      */
  3309. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3310. /*   received by the window procedure.                      */
  3311. /*   Window "ListStaffWindow".                          */
  3312. /*                                      */
  3313. /**********************************************************************/
  3314.  
  3315. static VOID CommandListStaffWindow ( PGPFPARMS pGpfParms )
  3316. {
  3317.   pGpfParms->mresult = (MRESULT) TRUE;        /* Set Return Code    */
  3318.   /* Switch according to Control chosen                   */
  3319.   switch( pGpfParms->Command )
  3320.   {
  3321.     /******************************************************************/
  3322.     /* Name  "ListBox".                           */
  3323.     /* Text  "Text".                              */
  3324.     /******************************************************************/
  3325.     case ID_LISTBOX:
  3326.      ActionListBox(pGpfParms);
  3327.      return;
  3328.     /******************************************************************/
  3329.     /* Name  "Italic".                              */
  3330.     /* Text  "~Italic".                           */
  3331.     /******************************************************************/
  3332.     case ID_ITALIC:
  3333.      ActionItalic(pGpfParms);
  3334.      return;
  3335.     /******************************************************************/
  3336.     /* Name  "Bold".                              */
  3337.     /* Text  "~Bold".                              */
  3338.     /******************************************************************/
  3339.     case ID_BOLD:
  3340.      ActionBold(pGpfParms);
  3341.      return;
  3342.     /******************************************************************/
  3343.     /* Name  "UserButton".                          */
  3344.     /* Text  "About".                              */
  3345.     /******************************************************************/
  3346.     case ID_USERBUTTON:
  3347.      ActionUserButton(pGpfParms);
  3348.      return;
  3349.     /******************************************************************/
  3350.     /* Name  "ButtonStaff".                          */
  3351.     /* Text  " ".                              */
  3352.     /******************************************************************/
  3353.     case ID_BUTTONSTAFF:
  3354.      ActionButtonStaff(pGpfParms);
  3355.      return;
  3356.     /******************************************************************/
  3357.     /* Name  "ShowStaf".                          */
  3358.     /* Alias "DID_OK".                              */
  3359.     /* Text  "~Show Staff".                          */
  3360.     /******************************************************************/
  3361.     case ID_SHOWSTAF:
  3362.     case DID_OK:
  3363.      ActionShowStaf(pGpfParms);
  3364.      return;
  3365.     /******************************************************************/
  3366.     /* Name  "Cancel".                              */
  3367.     /* Alias "DID_CANCEL".                          */
  3368.     /* Text  "Cancel".                              */
  3369.     /******************************************************************/
  3370.     case ID_CANCEL:
  3371.     case DID_CANCEL:
  3372.      ActionCancel(pGpfParms);
  3373.      return;
  3374.     /******************************************************************/
  3375.     /* Name  "ButtonHelp".                          */
  3376.     /* Text  "~Help".                              */
  3377.     /******************************************************************/
  3378.     case ID_BUTTONHELP:
  3379.      ActionButtonHelp(pGpfParms);
  3380.      return;
  3381.   }
  3382.   /* Take no action for any other selections                  */
  3383.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  3384. }
  3385. /**********************************************************************/
  3386. /* End of Private Function: CommandListStaffWindow              */
  3387. /**********************************************************************/
  3388. /**********************************************************************/
  3389.  
  3390.  
  3391. /**********************************************************************/
  3392. /**********************************************************************/
  3393. /*                                      */
  3394. /*   STATIC PRIVATE FUNCTION: ActionItalic                  */
  3395. /*                                      */
  3396. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3397. /*   received by the window procedure.                      */
  3398. /*   Window "ListStaffWindow".                          */
  3399. /*                                      */
  3400. /**********************************************************************/
  3401.  
  3402. static VOID ActionItalic( PGPFPARMS pGpfParms )
  3403. {
  3404.   /* Switch according to Control chosen                   */
  3405.   switch( pGpfParms->Notify )
  3406.   {
  3407.    case BN_CLICKED:
  3408.    case BN_DBLCLICKED:
  3409.    case COMMAND:
  3410.     /************************************************************/    
  3411.     /* User Function ChangeFont                    */    
  3412.     /************************************************************/
  3413.     {
  3414.     FONTMETRICS  Metrics; /* Font metrics data structure     */
  3415.     LONG NoOfFonts = 1;
  3416.     FATTRS SelectedFont;
  3417.     HPS  hps;
  3418.     MRESULT mresult;
  3419.     /************************************************************/
  3420.     /* Query "System Font"                        */
  3421.     /************************************************************/
  3422.     hps = WinGetPS(pGpfParms->hwnd);
  3423.     GpiQueryFonts(hps,
  3424.             QF_PUBLIC,
  3425.             NULL,
  3426.             &NoOfFonts,
  3427.             (LONG)sizeof(FONTMETRICS),
  3428.             &Metrics);
  3429.  
  3430.     SelectedFont.usRecordLength   = sizeof(FATTRS);
  3431.     SelectedFont.fsSelection      = Metrics.fsSelection;
  3432.     SelectedFont.lMatch          = Metrics.lMatch;
  3433.     strcpy(SelectedFont.szFacename, Metrics.szFacename);
  3434.     SelectedFont.idRegistry       = Metrics.idRegistry;
  3435.     SelectedFont.usCodePage       = Metrics.usCodePage;
  3436.     SelectedFont.lMaxBaselineExt  = Metrics.lMaxBaselineExt;
  3437.     SelectedFont.lAveCharWidth    = Metrics.lAveCharWidth;
  3438.     SelectedFont.fsType          = 0;
  3439.     SelectedFont.fsFontUse          = FATTR_FONTUSE_NOMIX;
  3440.     mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
  3441.                    ID_BOLD,BM_QUERYCHECK,NULL,NULL);
  3442.     if (!SHORT1FROMMR(mresult))
  3443.         SelectedFont.fsSelection &=  ~FATTR_SEL_BOLD;
  3444.     else
  3445.         SelectedFont.fsSelection |=  FATTR_SEL_BOLD;
  3446.     mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
  3447.                    ID_ITALIC,BM_QUERYCHECK,NULL,NULL);
  3448.     if (!SHORT1FROMMR(mresult))
  3449.         SelectedFont.fsSelection &=  ~FATTR_SEL_ITALIC;
  3450.     else
  3451.         SelectedFont.fsSelection |=  FATTR_SEL_ITALIC;
  3452.     WinReleasePS(hps);
  3453.     WinSendDlgItemMsg(pGpfParms->hwnd,
  3454.              ID_MLE,
  3455.              MLM_SETFONT,
  3456.              MPFROMP( &SelectedFont ),
  3457.              MPFROMSHORT( NULL ) );
  3458.     }
  3459.     return;
  3460.   }
  3461.   /* Take no action for any other selections                  */
  3462. }
  3463. /**********************************************************************/
  3464. /* End of Private Function                          */
  3465. /**********************************************************************/
  3466. /**********************************************************************/
  3467.  
  3468.  
  3469. /**********************************************************************/
  3470. /**********************************************************************/
  3471. /*                                      */
  3472. /*   STATIC PRIVATE FUNCTION: ActionBold                  */
  3473. /*                                      */
  3474. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3475. /*   received by the window procedure.                      */
  3476. /*   Window "ListStaffWindow".                          */
  3477. /*                                      */
  3478. /**********************************************************************/
  3479.  
  3480. static VOID ActionBold( PGPFPARMS pGpfParms )    
  3481. {
  3482.   /* Switch according to Control chosen                   */
  3483.   switch( pGpfParms->Notify )
  3484.   {
  3485.    case BN_CLICKED:
  3486.    case BN_DBLCLICKED:
  3487.    case COMMAND:
  3488.     /************************************************************/    
  3489.     /* User Function ChangeFont                    */    
  3490.     /************************************************************/
  3491.     {
  3492.     FONTMETRICS  Metrics; /* Font metrics data structure     */
  3493.     LONG NoOfFonts = 1;
  3494.     FATTRS SelectedFont;
  3495.     HPS  hps;
  3496.     MRESULT mresult;
  3497.     /************************************************************/
  3498.     /* Query "System Font"                        */
  3499.     /************************************************************/
  3500.     hps = WinGetPS(pGpfParms->hwnd);
  3501.     GpiQueryFonts(hps,
  3502.             QF_PUBLIC,
  3503.             NULL,
  3504.             &NoOfFonts,
  3505.             (LONG)sizeof(FONTMETRICS),
  3506.             &Metrics);
  3507.  
  3508.     SelectedFont.usRecordLength   = sizeof(FATTRS);
  3509.     SelectedFont.fsSelection      = Metrics.fsSelection;
  3510.     SelectedFont.lMatch          = Metrics.lMatch;
  3511.     strcpy(SelectedFont.szFacename, Metrics.szFacename);
  3512.     SelectedFont.idRegistry       = Metrics.idRegistry;
  3513.     SelectedFont.usCodePage       = Metrics.usCodePage;
  3514.     SelectedFont.lMaxBaselineExt  = Metrics.lMaxBaselineExt;
  3515.     SelectedFont.lAveCharWidth    = Metrics.lAveCharWidth;
  3516.     SelectedFont.fsType          = 0;
  3517.     SelectedFont.fsFontUse          = FATTR_FONTUSE_NOMIX;
  3518.     mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
  3519.                    ID_BOLD,BM_QUERYCHECK,NULL,NULL);
  3520.     if (!SHORT1FROMMR(mresult))
  3521.         SelectedFont.fsSelection &=  ~FATTR_SEL_BOLD;
  3522.     else
  3523.         SelectedFont.fsSelection |=  FATTR_SEL_BOLD;
  3524.     mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
  3525.                    ID_ITALIC,BM_QUERYCHECK,NULL,NULL);
  3526.     if (!SHORT1FROMMR(mresult))
  3527.         SelectedFont.fsSelection &=  ~FATTR_SEL_ITALIC;
  3528.     else
  3529.         SelectedFont.fsSelection |=  FATTR_SEL_ITALIC;
  3530.     WinReleasePS(hps);
  3531.     WinSendDlgItemMsg(pGpfParms->hwnd,
  3532.              ID_MLE,
  3533.              MLM_SETFONT,
  3534.              MPFROMP( &SelectedFont ),
  3535.              MPFROMSHORT( NULL ) );
  3536.     }
  3537.     return;
  3538.   }
  3539.   /* Take no action for any other selections                  */
  3540. }
  3541. /**********************************************************************/
  3542. /* End of Private Function                          */
  3543. /**********************************************************************/
  3544. /**********************************************************************/
  3545.  
  3546.  
  3547. /**********************************************************************/
  3548. /**********************************************************************/
  3549. /*                                      */
  3550. /*   STATIC PRIVATE FUNCTION: ActionUserButton                  */
  3551. /*                                      */
  3552. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3553. /*   received by the window procedure.                      */
  3554. /*   Window "ListStaffWindow".                          */
  3555. /*                                      */
  3556. /**********************************************************************/
  3557.  
  3558. static VOID ActionUserButton( PGPFPARMS pGpfParms )
  3559. {
  3560.   /* Switch according to Control chosen                   */
  3561.   switch( pGpfParms->Notify )
  3562.   {
  3563.    case BN_PAINT:
  3564.     {
  3565.      /*************************************************************/
  3566.      /* Paint UserButton.                          */
  3567.      /*************************************************************/
  3568.       PUSERBUTTON UsrBtn;            /* UserButton Pointer */
  3569.       SWP          Swp;            /* Size Cx Cy Button  */
  3570.       UCHAR       String[64];        /* Work Button Text   */
  3571.       POINTL      PointL;            /* Start BitMap       */
  3572.       RECTL       rcl;            /* Rect Button          */
  3573.       HBITMAP     Hbm;            /* Work Hbitmap       */
  3574.       USHORT      BitMapId;         /* Work BitMap Id     */
  3575.       USHORT      fsCmd;            /* DrawText Option    */
  3576.  
  3577.  
  3578.          UsrBtn = (PUSERBUTTON) PVOIDFROMMP(pGpfParms->mp2);
  3579.          WinQueryWindowPos( UsrBtn->hwnd, &Swp );
  3580.          WinQueryWindowRect(UsrBtn->hwnd,&rcl);
  3581.          if ((UsrBtn->fsState) & BDS_HILITED)
  3582.          BitMapId = ID_SAMPLE2_BMP;
  3583.          else
  3584.          BitMapId = ID_SAMPLE1_BMP;
  3585.          Hbm = GpiLoadBitmap(UsrBtn->hps,
  3586.                  hmodSample,    
  3587.                  BitMapId,
  3588.                  MAKELONG(Swp.cx,0),
  3589.                  MAKELONG(Swp.cy,0));
  3590.          PointL.x = (LONG)NULL;
  3591.          PointL.y = (LONG)NULL;
  3592.          WinDrawBitmap(UsrBtn->hps,Hbm,(PRECTL)NULL,&PointL,
  3593.                (LONG)NULL,(LONG)NULL,DBM_IMAGEATTRS);
  3594.          GpiDeleteBitmap(Hbm);
  3595.          if ((UsrBtn->fsState) & BDS_DEFAULT)
  3596.          WinDrawBorder( UsrBtn->hps,&rcl,1,1,
  3597.                 CLR_BLACK,CLR_BLACK,DB_STANDARD );
  3598.  
  3599.          WinQueryWindowText(UsrBtn->hwnd,sizeof(String),String);
  3600.          if (strlen(String)) /* String TEXT Found .... */
  3601.         {         /* Yes Draw the String    */
  3602.          fsCmd = DT_CENTER | DT_VCENTER;
  3603.          if ((UsrBtn->fsState) & BDS_DISABLED)
  3604.               fsCmd = fsCmd | DT_HALFTONE;
  3605.          WinDrawText(UsrBtn->hps,strlen(String),String,
  3606.                  &rcl,SYSCLR_WINDOWTEXT,SYSCLR_WINDOW,
  3607.                  fsCmd);
  3608.         }
  3609.     }
  3610.     return;
  3611.    case COMMAND:
  3612.     /**************************************************************/
  3613.     /* Disable Control "UserButton".                  */
  3614.     /* Window "ListStaffWindow".                      */
  3615.     /**************************************************************/
  3616.     WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
  3617.             ID_USERBUTTON),
  3618.             FALSE);
  3619.     /**************************************************************/
  3620.     /* Disable Menu/Item "About1".                      */
  3621.     /* Window "MainWindow".                       */
  3622.     /**************************************************************/
  3623.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
  3624.     /**************************************************************/
  3625.     /* Show Window "AboutWindow".                      */
  3626.     /**************************************************************/
  3627.     ShowAboutWindow(NULL);
  3628.     return;
  3629.   }
  3630.   /* Take no action for any other selections                  */
  3631. }
  3632. /**********************************************************************/
  3633. /* End of Private Function                          */
  3634. /**********************************************************************/
  3635. /**********************************************************************/
  3636.  
  3637.  
  3638. /**********************************************************************/
  3639. /**********************************************************************/
  3640. /*                                      */
  3641. /*   STATIC PRIVATE FUNCTION: ActionButtonStaff               */
  3642. /*                                      */
  3643. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3644. /*   received by the window procedure.                      */
  3645. /*   Window "ListStaffWindow".                          */
  3646. /*                                      */
  3647. /**********************************************************************/
  3648.  
  3649. static VOID ActionButtonStaff( PGPFPARMS pGpfParms )
  3650. {
  3651.   /* Switch according to Control chosen                   */
  3652.   switch( pGpfParms->Notify )
  3653.   {
  3654.    case BN_PAINT:
  3655.     {
  3656.      /*************************************************************/
  3657.      /* Paint UserButton.                          */
  3658.      /*************************************************************/
  3659.       PUSERBUTTON UsrBtn;            /* UserButton Pointer */
  3660.       SWP          Swp;            /* Size Cx Cy Button  */
  3661.       UCHAR       String[64];        /* Work Button Text   */
  3662.       POINTL      PointL;            /* Start BitMap       */
  3663.       RECTL       rcl;            /* Rect Button          */
  3664.       HBITMAP     Hbm;            /* Work Hbitmap       */
  3665.       USHORT      BitMapId;         /* Work BitMap Id     */
  3666.       USHORT      fsCmd;            /* DrawText Option    */
  3667.  
  3668.  
  3669.          UsrBtn = (PUSERBUTTON) PVOIDFROMMP(pGpfParms->mp2);
  3670.          WinQueryWindowPos( UsrBtn->hwnd, &Swp );
  3671.          WinQueryWindowRect(UsrBtn->hwnd,&rcl);
  3672.          if ((UsrBtn->fsState) & BDS_HILITED)
  3673.          BitMapId = ID_SAMPLE5_BMP;
  3674.          else
  3675.          BitMapId = ID_SAMPLE4_BMP;
  3676.          Hbm = GpiLoadBitmap(UsrBtn->hps,
  3677.                  hmodSample,    
  3678.                  BitMapId,
  3679.                  MAKELONG(Swp.cx,0),
  3680.                  MAKELONG(Swp.cy,0));
  3681.          PointL.x = (LONG)NULL;
  3682.          PointL.y = (LONG)NULL;
  3683.          WinDrawBitmap(UsrBtn->hps,Hbm,(PRECTL)NULL,&PointL,
  3684.                (LONG)NULL,(LONG)NULL,DBM_IMAGEATTRS);
  3685.          GpiDeleteBitmap(Hbm);
  3686.          if ((UsrBtn->fsState) & BDS_DEFAULT)
  3687.          WinDrawBorder( UsrBtn->hps,&rcl,1,1,
  3688.                 CLR_BLACK,CLR_BLACK,DB_STANDARD );
  3689.  
  3690.          WinQueryWindowText(UsrBtn->hwnd,sizeof(String),String);
  3691.          if (strlen(String)) /* String TEXT Found .... */
  3692.         {         /* Yes Draw the String    */
  3693.          fsCmd = DT_CENTER | DT_VCENTER;
  3694.          if ((UsrBtn->fsState) & BDS_DISABLED)
  3695.               fsCmd = fsCmd | DT_HALFTONE;
  3696.          WinDrawText(UsrBtn->hps,strlen(String),String,
  3697.                  &rcl,SYSCLR_WINDOWTEXT,SYSCLR_WINDOW,
  3698.                  fsCmd);
  3699.         }
  3700.     }
  3701.     return;
  3702.    case COMMAND:
  3703.     /**************************************************************/
  3704.     /* Show Window "DialogStaff".                      */
  3705.     /**************************************************************/
  3706.     ShowDialogStaff(NULL);
  3707.     return;
  3708.   }
  3709.   /* Take no action for any other selections                  */
  3710. }
  3711. /**********************************************************************/
  3712. /* End of Private Function                          */
  3713. /**********************************************************************/
  3714. /**********************************************************************/
  3715.  
  3716.  
  3717. /**********************************************************************/
  3718. /**********************************************************************/
  3719. /*                                      */
  3720. /*   STATIC PRIVATE FUNCTION: ActionShowStaf                  */
  3721. /*                                      */
  3722. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3723. /*   received by the window procedure.                      */
  3724. /*   Window "ListStaffWindow".                          */
  3725. /*                                      */
  3726. /**********************************************************************/
  3727.  
  3728. static VOID ActionShowStaf( PGPFPARMS pGpfParms )
  3729. {
  3730.   /* Switch according to Control chosen                   */
  3731.   switch( pGpfParms->Notify )
  3732.   {
  3733.    case BN_CLICKED:
  3734.    case BN_DBLCLICKED:
  3735.    case COMMAND:
  3736.     /**************************************************************/
  3737.     /* Reset Default Button Window "ListStaffWindow".          */
  3738.     /**************************************************************/
  3739.     GpfResetDefaultButton(hwndListStaffWindow);
  3740.     /**************************************************************/
  3741.     /* Get Selection "ListBox".                      */
  3742.     /* Window "ListStaffWindow".                      */
  3743.     /**************************************************************/
  3744.     GetSelBoxListBox();
  3745.     /**************************************************************/
  3746.     /* Show Window "DialogStaff".                      */
  3747.     /**************************************************************/
  3748.     ShowDialogStaff(NULL);
  3749.     return;
  3750.   }
  3751.   /* Take no action for any other selections                  */
  3752. }
  3753. /**********************************************************************/
  3754. /* End of Private Function                          */
  3755. /**********************************************************************/
  3756. /**********************************************************************/
  3757.  
  3758.  
  3759. /**********************************************************************/
  3760. /**********************************************************************/
  3761. /*                                      */
  3762. /*   STATIC PRIVATE FUNCTION: ActionCancel                  */
  3763. /*                                      */
  3764. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3765. /*   received by the window procedure.                      */
  3766. /*   Window "ListStaffWindow".                          */
  3767. /*                                      */
  3768. /**********************************************************************/
  3769.  
  3770. static VOID ActionCancel( PGPFPARMS pGpfParms )
  3771. {
  3772.   /* Switch according to Control chosen                   */
  3773.   switch( pGpfParms->Notify )
  3774.   {
  3775.    case BN_CLICKED:
  3776.    case BN_DBLCLICKED:
  3777.    case COMMAND:
  3778.     /**************************************************************/
  3779.     /* Dismiss Window Hide Window "ListStaffWindow".          */
  3780.     /**************************************************************/
  3781.     DismissListStaffWindow(FALSE);
  3782.     return;
  3783.   }
  3784.   /* Take no action for any other selections                  */
  3785. }
  3786. /**********************************************************************/
  3787. /* End of Private Function                          */
  3788. /**********************************************************************/
  3789. /**********************************************************************/
  3790.  
  3791.  
  3792. /**********************************************************************/
  3793. /**********************************************************************/
  3794. /*                                      */
  3795. /*   STATIC PRIVATE FUNCTION: ActionButtonHelp                  */
  3796. /*                                      */
  3797. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3798. /*   received by the window procedure.                      */
  3799. /*   Window "ListStaffWindow".                          */
  3800. /*                                      */
  3801. /**********************************************************************/
  3802.  
  3803. static VOID ActionButtonHelp( PGPFPARMS pGpfParms )
  3804. {
  3805.   /* Switch according to Control chosen                   */
  3806.   switch( pGpfParms->Notify )
  3807.   {
  3808.    case BN_CLICKED:
  3809.    case BN_DBLCLICKED:
  3810.    case COMMAND:
  3811.     /**************************************************************/
  3812.     /* Help Extended for Window "ListStaffWindow".              */
  3813.     /**************************************************************/
  3814.     if (hwndHelp)
  3815.         WinSendMsg( hwndHelp, HM_DISPLAY_HELP,
  3816.             MPFROMSHORT( ID_LISTSTAFFWINDOW ),
  3817.             0L );
  3818.     return;
  3819.   }
  3820.   /* Take no action for any other selections                  */
  3821. }
  3822. /**********************************************************************/
  3823. /* End of Private Function                          */
  3824. /**********************************************************************/
  3825. /**********************************************************************/
  3826.  
  3827.  
  3828. /**********************************************************************/
  3829. /**********************************************************************/
  3830. /*                                      */
  3831. /*   STATIC PRIVATE FUNCTION: ActionListBox                  */
  3832. /*                                      */
  3833. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  3834. /*   received by the window procedure.                      */
  3835. /*   Window "ListStaffWindow".                          */
  3836. /*                                      */
  3837. /**********************************************************************/
  3838.  
  3839. static VOID ActionListBox( PGPFPARMS pGpfParms )
  3840. {
  3841.   /* Switch according to Control chosen                   */
  3842.   switch( pGpfParms->Notify )
  3843.   {
  3844.    case LN_ENTER:      /* Catch double click on */
  3845.     /**************************************************************/
  3846.     /* Reset Default Button Window "ListStaffWindow".          */
  3847.     /**************************************************************/
  3848.     GpfResetDefaultButton(hwndListStaffWindow);
  3849.     /**************************************************************/
  3850.     /* Simulate OK - Send Did OK to Window                  */
  3851.     /* "ListStaffWindow".                          */
  3852.     /*************************************************************/
  3853.     WinSendMsg( hwndListStaffWindow,
  3854.             WM_COMMAND,         /* simulate OK          */
  3855.             MPFROM2SHORT( DID_OK       , 0 ),
  3856.             MPFROM2SHORT( CMDSRC_OTHER , 0 )
  3857.           );
  3858.     return;
  3859.    case LN_SELECT:     /* Catch click on */
  3860.     /**************************************************************/
  3861.     /* Get Selection "ListBox".                      */
  3862.     /* Window "ListStaffWindow".                      */
  3863.     /**************************************************************/
  3864.     GetSelBoxListBox();
  3865.     /**************************************************************/
  3866.     /* Move Data To Window "ListStaffWindow".              */
  3867.     /**************************************************************/
  3868.     MoveDataToListStaffWindow();
  3869.     return;
  3870.    case LN_KILLFOCUS:  /* Kill Focus */
  3871.     return;
  3872.    case LN_SETFOCUS:   /* Set Focus */
  3873.     return;
  3874.    case LN_SCROLL:     /* Scroll    */
  3875.     return;
  3876.   }
  3877.   /* Take no action for any other selections                  */
  3878. }
  3879. /**********************************************************************/
  3880. /* End of Private Function                          */
  3881. /**********************************************************************/
  3882. /**********************************************************************/
  3883.  
  3884.  
  3885. /**********************************************************************/
  3886. /**********************************************************************/
  3887. /*                                      */
  3888. /*   PRIVATE FUNCTION: MoveListStaffWindowToData              */
  3889. /*                                      */
  3890. /*   Move "ListStaffWindow" To Assosiate Data.                  */
  3891. /*                                      */
  3892. /**********************************************************************/
  3893.  
  3894. BOOL  MoveListStaffWindowToData ( VOID )
  3895.  {
  3896.   UCHAR  String[32];
  3897.   PUCHAR Token;
  3898.  
  3899.   String[0] = 0;     /* Null, Delete Unreferenced Local variable */
  3900.   Token  = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  3901.  
  3902. /**********************************************************************/
  3903. /*   Move "ID_CLICKNAME" To "STAFF_NAME". (VARCHAR)              */
  3904. /**********************************************************************/
  3905.  
  3906.  
  3907.       WinQueryWindowText( WinWindowFromID( hwndListStaffWindow,
  3908.                        ID_CLICKNAME),
  3909.               sizeof(STAFF_NAME),
  3910.               STAFF_NAME);    
  3911.       if (!STAFF_NAME[0])            /* If Null Data          */
  3912.       STAFF_NAME_N = -1;            /* Set Sql Null Indicator */
  3913.  
  3914. /**********************************************************************/
  3915. /*   Move "ID_MLE" To "STAFF_NAME".    (VARCHAR)              */
  3916. /**********************************************************************/
  3917.  
  3918.  
  3919.       WinQueryWindowText( WinWindowFromID( hwndListStaffWindow,
  3920.                        ID_MLE),    
  3921.               sizeof(STAFF_NAME),
  3922.               STAFF_NAME);    
  3923.       if (!STAFF_NAME[0])            /* If Null Data          */
  3924.       STAFF_NAME_N = -1;            /* Set Sql Null Indicator */
  3925.  
  3926.  
  3927.       return (TRUE);
  3928.  }
  3929. /**********************************************************************/
  3930. /* End of Private Function: MoveListStaffWindowToData              */
  3931. /**********************************************************************/
  3932. /**********************************************************************/
  3933.  
  3934.  
  3935.  
  3936. /**********************************************************************/
  3937. /**********************************************************************/
  3938. /*                                      */
  3939. /*   PRIVATE FUNCTION: MoveDataToListStaffWindow              */
  3940. /*                                      */
  3941. /*   Move Data To Window "ListStaffWindow".                  */
  3942. /*                                      */
  3943. /**********************************************************************/
  3944.  
  3945. BOOL  MoveDataToListStaffWindow ( VOID )
  3946.  {
  3947.   UCHAR  String[32];
  3948.   PUCHAR Token;
  3949.  
  3950.   String[0] = 0;      /* Null, Delete Unreferenced Local variable */
  3951.   Token   = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  3952.  
  3953. /**********************************************************************/
  3954. /*   Move "STAFF_NAME" To "ID_CLICKNAME". (VARCHAR)              */
  3955. /**********************************************************************/
  3956.  
  3957.       WinSendDlgItemMsg(hwndListStaffWindow,
  3958.             ID_CLICKNAME,
  3959.             EM_SETTEXTLIMIT,
  3960.             MPFROMSHORT( sizeof(STAFF_NAME) -1 ),
  3961.             MPFROMSHORT( NULL ) );
  3962.       if (STAFF_NAME_N < 0)             /* If Null Indicator */
  3963.       STAFF_NAME[0] = 0;             /* Set Null Data     */
  3964.       WinSetWindowText( WinWindowFromID( hwndListStaffWindow,
  3965.             ID_CLICKNAME),
  3966.             STAFF_NAME);
  3967.  
  3968. /**********************************************************************/
  3969. /*   Move "STAFF_NAME" To "ID_MLE".    (VARCHAR)              */
  3970. /**********************************************************************/
  3971.  
  3972.       WinSendDlgItemMsg(hwndListStaffWindow,
  3973.             ID_MLE,
  3974.             EM_SETTEXTLIMIT,
  3975.             MPFROMSHORT( sizeof(STAFF_NAME) -1 ),
  3976.             MPFROMSHORT( NULL ) );
  3977.       if (STAFF_NAME_N < 0)             /* If Null Indicator */
  3978.       STAFF_NAME[0] = 0;             /* Set Null Data     */
  3979.       WinSetWindowText( WinWindowFromID( hwndListStaffWindow,
  3980.             ID_MLE),
  3981.             STAFF_NAME);
  3982.  
  3983.  
  3984.       return (TRUE);
  3985.  }
  3986. /**********************************************************************/
  3987. /* End of Private Function: MoveDataToListStaffWindow              */
  3988. /**********************************************************************/
  3989. /**********************************************************************/
  3990.  
  3991.  
  3992.  
  3993. /**********************************************************************/
  3994. /**********************************************************************/
  3995. /*                                      */
  3996. /*   PRIVATE FUNCTION: WmInitWndListStaffWindow               */
  3997. /*                                      */
  3998. /*   Wm Init Window "ListStaffWindow".                      */
  3999. /*                                      */
  4000. /**********************************************************************/
  4001.  
  4002. static VOID WmInitWndListStaffWindow ( PGPFPARMS pGpfParms )
  4003.  {
  4004.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  4005.     /**************************************************************/
  4006.     /* Load ListBox / ComboBox "ListBox".                  */
  4007.     /* Window "ListStaffWindow".                      */
  4008.     /**************************************************************/
  4009.     /* Send Msg for Execute LoadBoxListBox();              */
  4010.     GpfExecuteSql(LoadBoxListBox,hwndListStaffWindow);
  4011.     /* Wait Async Execute LoadBoxListBox();               */
  4012.     GpfSqlWait(hwndListStaffWindow);
  4013.     /**************************************************************/
  4014.     /* Get Selection "ListBox".                      */
  4015.     /* Window "ListStaffWindow".                      */
  4016.     /**************************************************************/
  4017.     GetSelBoxListBox();
  4018.     /**************************************************************/
  4019.     /* Move Data To Window "ListStaffWindow".              */
  4020.     /**************************************************************/
  4021.     MoveDataToListStaffWindow();
  4022.  }
  4023. /**********************************************************************/
  4024. /* End of Private Function: WmInitWndListStaffWindow              */
  4025. /**********************************************************************/
  4026. /**********************************************************************/
  4027.  
  4028.  
  4029.  
  4030. /**********************************************************************/
  4031. /**********************************************************************/
  4032. /*                                      */
  4033. /*   PRIVATE FUNCTION: WmActiveListStaffWindow                  */
  4034. /*                                      */
  4035. /*   Wm Activate Window "ListStaffWindow".                  */
  4036. /*                                      */
  4037. /**********************************************************************/
  4038.  
  4039. static VOID WmActiveListStaffWindow ( PGPFPARMS pGpfParms )
  4040.  {
  4041.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  4042.  }
  4043. /**********************************************************************/
  4044. /* End of Private Function: WmActiveListStaffWindow              */
  4045. /**********************************************************************/
  4046. /**********************************************************************/
  4047.  
  4048.  
  4049.  
  4050. /**********************************************************************/
  4051. /**********************************************************************/
  4052. /*                                      */
  4053. /*   PRIVATE FUNCTION: WmDeActiveListStaffWindow              */
  4054. /*                                      */
  4055. /*   DeActivate Window "ListStaffWindow".                  */
  4056. /*                                      */
  4057. /**********************************************************************/
  4058.  
  4059. static VOID WmDeActiveListStaffWindow ( PGPFPARMS pGpfParms )
  4060.  {
  4061.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  4062.  }
  4063. /**********************************************************************/
  4064. /* End of Private Function: WmDeActiveListStaffWindow              */
  4065. /**********************************************************************/
  4066. /**********************************************************************/
  4067.  
  4068.  
  4069.  
  4070. /**********************************************************************/
  4071. /**********************************************************************/
  4072. /*                                      */
  4073. /*   PRIVATE FUNCTION: WmCreateListStaffWindow                  */
  4074. /*                                      */
  4075. /*   Wm Create Window "ListStaffWindow".                  */
  4076. /*                                      */
  4077. /**********************************************************************/
  4078.  
  4079. static VOID WmCreateListStaffWindow ( PGPFPARMS pGpfParms )
  4080.  {
  4081.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  4082.  }
  4083. /**********************************************************************/
  4084. /* End of Private Function: WmCreateListStaffWindow              */
  4085. /**********************************************************************/
  4086. /**********************************************************************/
  4087.  
  4088.  
  4089.  
  4090. /**********************************************************************/
  4091. /**********************************************************************/
  4092. /*                                      */
  4093. /*   PRIVATE FUNCTION: WmDestroyListStaffWindow               */
  4094. /*                                      */
  4095. /*   Wm Destroy Window "ListStaffWindow".                  */
  4096. /*                                      */
  4097. /**********************************************************************/
  4098.  
  4099. static VOID WmDestroyListStaffWindow ( PGPFPARMS pGpfParms )
  4100.  {
  4101.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  4102.  }
  4103. /**********************************************************************/
  4104. /* End of Private Function: WmDestroyListStaffWindow              */
  4105. /**********************************************************************/
  4106. /**********************************************************************/
  4107.  
  4108.  
  4109.  
  4110. /**********************************************************************/
  4111. /**********************************************************************/
  4112. /*                                      */
  4113. /*   PRIVATE FUNCTION: WmPaintListStaffWindow                  */
  4114. /*                                      */
  4115. /*   Wm Paint Window "ListStaffWindow".                   */
  4116. /*                                      */
  4117. /**********************************************************************/
  4118.  
  4119. static VOID WmPaintListStaffWindow ( PGPFPARMS pGpfParms )
  4120.  {
  4121.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  4122.  }
  4123. /**********************************************************************/
  4124. /* End of Private Function: WmPaintListStaffWindow              */
  4125. /**********************************************************************/
  4126. /**********************************************************************/
  4127.  
  4128.  
  4129.  
  4130. /**********************************************************************/
  4131. /**********************************************************************/
  4132. /*                                      */
  4133. /*   PRIVATE FUNCTION: WmShowListStaffWindow                  */
  4134. /*                                      */
  4135. /*   Wm Show Window "ListStaffWindow".                      */
  4136. /*                                      */
  4137. /**********************************************************************/
  4138.  
  4139. static VOID WmShowListStaffWindow ( PGPFPARMS pGpfParms )
  4140.  {
  4141.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  4142.  }
  4143. /**********************************************************************/
  4144. /* End of Private Function: WmShowListStaffWindow              */
  4145. /**********************************************************************/
  4146. /**********************************************************************/
  4147.  
  4148.  
  4149.  
  4150. /**********************************************************************/
  4151. /**********************************************************************/
  4152. /*                                      */
  4153. /*   PRIVATE FUNCTION: WmHideListStaffWindow                  */
  4154. /*                                      */
  4155. /*   Wm Hide Window "ListStaffWindow".                      */
  4156. /*                                      */
  4157. /**********************************************************************/
  4158.  
  4159. static VOID WmHideListStaffWindow ( PGPFPARMS pGpfParms )
  4160.  {
  4161.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  4162.  }
  4163. /**********************************************************************/
  4164. /* End of Private Function: WmHideListStaffWindow              */
  4165. /**********************************************************************/
  4166. /**********************************************************************/
  4167.  
  4168.  
  4169. /**********************************************************************/
  4170. /**********************************************************************/
  4171. /*                                      */
  4172. /*   PRIVATE FUNCTION: LoadBoxListBox                      */
  4173. /*                                      */
  4174. /*   Load Box To ID_LISTBOX                          */
  4175. /*                                      */
  4176. /**********************************************************************/
  4177. LONG LoadBoxListBox( VOID )
  4178.  {
  4179.   UCHAR String[256];
  4180.   PUCHAR Token = NULL;
  4181.   SHORT i;
  4182.  
  4183.                             
  4184.       /***************************************************/
  4185.       /* clear out both list boxes in preperation for a  */
  4186.       /* refresh given the new environment         */
  4187.       /***************************************************/
  4188.                             
  4189.       WinSendDlgItemMsg(hwndListStaffWindow,
  4190.             ID_LISTBOX,
  4191.             LM_DELETEALL,            
  4192.             MPFROMSHORT( NULL ),        
  4193.             MPFROMSHORT( NULL ) );        
  4194.                             
  4195.       /********************************/
  4196.       /* Declare Sql Cursor          */
  4197.       /********************************/
  4198.       EXEC SQL DECLARE CURSOR_10055 CURSOR FOR SELECT
  4199.                   ID,
  4200.                   NAME,
  4201.                   DEPT,
  4202.                   JOB,
  4203.                   SALARY,
  4204.                   COMM
  4205.                FROM STAFF ;
  4206.  
  4207.       /********************************/
  4208.       /* Open  Sql Cursor          */
  4209.       /********************************/
  4210.  
  4211.       /* Position cursor at first record */
  4212.  
  4213.       EXEC SQL OPEN CURSOR_10055;
  4214.       GpfDisplaySqlError(&sqlca);
  4215.  
  4216.       while (!sqlca.sqlcode)
  4217.     {
  4218.       STAFF_ID = 0;
  4219.       STAFF_NAME[0] = 0;
  4220.       STAFF_DEPT = 0;
  4221.       STAFF_JOB[0] = 0;
  4222.       STAFF_SALARY = 0.0;
  4223.       STAFF_COMM = 0.0;
  4224.  
  4225.       /******************************************************/
  4226.       /* Fetch next row inorder to properly position cursor */
  4227.       /******************************************************/
  4228.  
  4229.       EXEC SQL FETCH CURSOR_10055 INTO
  4230.              :STAFF_ID,
  4231.              :STAFF_NAME :STAFF_NAME_N,
  4232.              :STAFF_DEPT :STAFF_DEPT_N,
  4233.              :STAFF_JOB :STAFF_JOB_N,
  4234.              :STAFF_SALARY :STAFF_SALARY_N,
  4235.              :STAFF_COMM :STAFF_COMM_N;
  4236.       GpfDisplaySqlError(&sqlca);
  4237.  
  4238.       if (!sqlca.sqlcode)
  4239.          {
  4240.           /********************************/
  4241.           /* Add Item to ListBox/ComboBox */
  4242.           /********************************/
  4243.           i = 0;
  4244.           i += sprintf(&String[i]," %6d\xFF",STAFF_ID);
  4245.           i += sprintf(&String[i],"%-9s\xFF",STAFF_NAME);
  4246.           i += sprintf(&String[i]," %6d\xFF",STAFF_DEPT);
  4247.           i += sprintf(&String[i],"%-5s\xFF",STAFF_JOB);
  4248.           i += sprintf(&String[i]," %7.2f\xFF",STAFF_SALARY);
  4249.           Token = strrchr(String,'.'); /* Search US Decimal       */
  4250.           if (Token)        /* If Found              */
  4251.         *(Token) = sDecimal[0]; /* Change to National Decimal */
  4252.           i += sprintf(&String[i]," %7.2f\xFF",STAFF_COMM);
  4253.           Token = strrchr(String,'.'); /* Search US Decimal       */
  4254.           if (Token)        /* If Found              */
  4255.         *(Token) = sDecimal[0]; /* Change to National Decimal */
  4256.           WinSendDlgItemMsg ( hwndListStaffWindow,
  4257.                   ID_LISTBOX,
  4258.                   LM_INSERTITEM,
  4259.                   MPFROM2SHORT(LIT_END,0),
  4260.                   MPFROMP( String ));
  4261.          }
  4262.     }
  4263.       /********************************/
  4264.       /* Close Sql Cursor          */
  4265.       /********************************/
  4266.       EXEC SQL CLOSE CURSOR_10055;
  4267.       GpfDisplaySqlError(&sqlca);
  4268.  
  4269.       /********************************/
  4270.       /* Commit and Drop Lock          */
  4271.       /********************************/
  4272.       EXEC SQL COMMIT WORK;        /* Drop Table any table locks */
  4273.       GpfDisplaySqlError(&sqlca);
  4274.  
  4275.       /***************************************************/
  4276.       /* Make the first list item initially-selected.     */
  4277.       /***************************************************/
  4278.                             
  4279.       WinSendDlgItemMsg(hwndListStaffWindow,
  4280.             ID_LISTBOX,
  4281.             LM_SELECTITEM,            
  4282.             MPFROMSHORT(0), /* First item index value */
  4283.             MPFROMSHORT( TRUE ) );        
  4284.  
  4285.       return (LONG)NULL;
  4286.  }
  4287. /**********************************************************************/
  4288. /* End of Private Function - LoadBoxListBox                  */
  4289. /**********************************************************************/
  4290. /**********************************************************************/
  4291.  
  4292.  
  4293.  
  4294. /**********************************************************************/
  4295. /**********************************************************************/
  4296. /*                                      */
  4297. /*   PRIVATE FUNCTION: GetSelBoxListBox                   */
  4298. /*                                      */
  4299. /*   GetSelection Box To ID_LISTBOX                      */
  4300. /*                                      */
  4301. /**********************************************************************/
  4302. BOOL GetSelBoxListBox( VOID )
  4303.  {
  4304.   UCHAR String[256];
  4305.   SHORT Position;
  4306.   PUCHAR Token = (PUCHAR)NULL;
  4307.   PUCHAR Token1 = (PUCHAR)NULL;
  4308.   PUCHAR EndToken = (PUCHAR)NULL;
  4309.   MRESULT mresult;
  4310.  
  4311.  
  4312. /*********************************************************************/
  4313. /*  Get the first selection item.                     */
  4314. /*********************************************************************/
  4315.       mresult = WinSendDlgItemMsg(
  4316.             hwndListStaffWindow,
  4317.             ID_LISTBOX,
  4318.             LM_QUERYSELECTION,
  4319.             MPFROM2SHORT( LIT_END, 0 ),    
  4320.             MPFROMSHORT( NULL ) );        
  4321.       Position = SHORT1FROMMR(mresult);
  4322.  
  4323. /*********************************************************************/
  4324. /*  When nothing was selected by the user.                 */
  4325. /*********************************************************************/
  4326.       if ((Position == LIT_NONE) || (Position == LIT_ERROR))    
  4327.     return FALSE;                        
  4328.  
  4329. /*********************************************************************/
  4330. /*  When something was selected by the user.                 */
  4331. /*********************************************************************/
  4332.       WinSendDlgItemMsg(hwndListStaffWindow,
  4333.             ID_LISTBOX,
  4334.             LM_QUERYITEMTEXT,
  4335.             MPFROM2SHORT(Position,sizeof(String)-1),
  4336.             MPFROMP( String ) );        
  4337.  
  4338.       Token = String;
  4339.  
  4340. /**********************************************************************/
  4341. /*  Move selected Item by the user.                      */
  4342. /**********************************************************************/
  4343.       EndToken = strchr(Token,'\xFF');
  4344.       if(!EndToken)
  4345.     return FALSE;
  4346.       *EndToken = 0;                /* Set Null Separator */
  4347.       STAFF_ID = atoi(Token);
  4348.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  4349.  
  4350. /**********************************************************************/
  4351. /*  Move selected Item by the user.                      */
  4352. /**********************************************************************/
  4353.       EndToken = strchr(Token,'\xFF');
  4354.       if(!EndToken)
  4355.     return FALSE;
  4356.       *EndToken = 0;                /* Set Null Separator */
  4357.       strcpy(STAFF_NAME,Token);
  4358.       if (!strlen(Token))
  4359.       STAFF_NAME_N = -1;
  4360.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  4361.  
  4362. /**********************************************************************/
  4363. /*  Move selected Item by the user.                      */
  4364. /**********************************************************************/
  4365.       EndToken = strchr(Token,'\xFF');
  4366.       if(!EndToken)
  4367.     return FALSE;
  4368.       *EndToken = 0;                /* Set Null Separator */
  4369.       STAFF_DEPT = atoi(Token);
  4370.       if (!strlen(Token))
  4371.       STAFF_DEPT_N = -1;
  4372.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  4373.  
  4374. /**********************************************************************/
  4375. /*  Move selected Item by the user.                      */
  4376. /**********************************************************************/
  4377.       EndToken = strchr(Token,'\xFF');
  4378.       if(!EndToken)
  4379.     return FALSE;
  4380.       *EndToken = 0;                /* Set Null Separator */
  4381.       strcpy(STAFF_JOB,Token);
  4382.       if (!strlen(Token))
  4383.       STAFF_JOB_N = -1;
  4384.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  4385.  
  4386. /**********************************************************************/
  4387. /*  Move selected Item by the user.                      */
  4388. /**********************************************************************/
  4389.       EndToken = strchr(Token,'\xFF');
  4390.       if(!EndToken)
  4391.     return FALSE;
  4392.       *EndToken = 0;                /* Set Null Separator */
  4393.       Token1 = strrchr(Token,sDecimal[0]); /* Search National Decimal */
  4394.       if (Token1)               /* If Found              */
  4395.      *(Token1) = '.';           /* Change To US Decimal    */
  4396.       STAFF_SALARY = atof(Token);
  4397.       if (!strlen(Token))
  4398.       STAFF_SALARY_N = -1;
  4399.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  4400.  
  4401. /**********************************************************************/
  4402. /*  Move selected Item by the user.                      */
  4403. /**********************************************************************/
  4404.       EndToken = strchr(Token,'\xFF');
  4405.       if(!EndToken)
  4406.     return FALSE;
  4407.       *EndToken = 0;                /* Set Null Separator */
  4408.       Token1 = strrchr(Token,sDecimal[0]); /* Search National Decimal */
  4409.       if (Token1)               /* If Found              */
  4410.      *(Token1) = '.';           /* Change To US Decimal    */
  4411.       STAFF_COMM = atof(Token);
  4412.       if (!strlen(Token))
  4413.       STAFF_COMM_N = -1;
  4414.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  4415.  
  4416.       return TRUE;
  4417.  }
  4418. /**********************************************************************/
  4419. /* End of Private Function - GetSelBoxListBox                  */
  4420. /**********************************************************************/
  4421. /**********************************************************************/
  4422.  
  4423.  
  4424.  
  4425.  
  4426. /**********************************************************************/
  4427. /* CreateAboutTask:                              */
  4428. /* Allocate a stack for the Window thread, and set it running.          */
  4429. /**********************************************************************/
  4430. VOID CreateAboutTask( VOID )
  4431. {
  4432.  SEL SelAboutTaskStack;
  4433.  
  4434.   DosAllocSeg( STACKSIZE, &SelAboutTaskStack, 0 );
  4435.   _beginthread ( AboutTaskEntryPoint,
  4436.          MAKEP( SelAboutTaskStack, 0),
  4437.          STACKSIZE ,NULL);
  4438. }
  4439.  
  4440. /**********************************************************************/
  4441. /* AboutTaskEntryPoint:                           */
  4442. /* Thread "AboutTask"                              */
  4443. /**********************************************************************/
  4444. VOID  cdecl AboutTaskEntryPoint ( PVOID Arg )
  4445. {
  4446.   QMSG    qmsgAboutTask;
  4447.  
  4448.    Arg = Arg;
  4449.  
  4450.    habAboutTask = WinInitialize( (USHORT)NULL );
  4451.    hmqAboutTask = WinCreateMsgQueue( habAboutTask, (SHORT)1024 );
  4452.  
  4453.   /********************************************************************/
  4454.   /* Main message-processing loop - get and dispatch messages until   */
  4455.   /* WM_QUIT received                              */
  4456.   /********************************************************************/
  4457.  
  4458.   while( WinGetMsg( habAboutTask, &qmsgAboutTask, (HWND)NULL, 0, 0 ) )
  4459.     WinDispatchMsg( habAboutTask, &qmsgAboutTask );
  4460.  
  4461.   /********************************************************************/
  4462.   /* Close Thread                              */
  4463.   /********************************************************************/
  4464.   WinDestroyMsgQueue( hmqAboutTask );
  4465.   WinTerminate( habAboutTask );
  4466.   DosExit( EXIT_THREAD, 0 );
  4467. }
  4468.  
  4469.