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

  1. /********    Sample1 C Program Source Code File (.Sqc)      ********/
  2. /*                                      */
  3. /* PROGRAM NAME: Sample1      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. /*    Sample1.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      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 ActionAboutOk( PGPFPARMS pGpfParms );
  225. static VOID WmInitWndAboutWindow( PGPFPARMS pGpfParms );
  226. static VOID WmActiveAboutWindow( PGPFPARMS pGpfParms );
  227. static VOID WmDeActiveAboutWindow( PGPFPARMS pGpfParms );
  228. static VOID WmCreateAboutWindow( PGPFPARMS pGpfParms );
  229. static VOID WmDestroyAboutWindow( PGPFPARMS pGpfParms );
  230. static VOID WmPaintAboutWindow( PGPFPARMS pGpfParms );
  231. static VOID WmShowAboutWindow( PGPFPARMS pGpfParms );
  232. static VOID WmHideAboutWindow( PGPFPARMS pGpfParms );
  233. static VOID CommandAboutWindow( PGPFPARMS pGpfParms );
  234. static VOID ActionOk( PGPFPARMS pGpfParms );
  235. static VOID WmInitWndDialogStaff( PGPFPARMS pGpfParms );
  236. static VOID WmActiveDialogStaff( PGPFPARMS pGpfParms );
  237. static VOID WmDeActiveDialogStaff( PGPFPARMS pGpfParms );
  238. static VOID WmCreateDialogStaff( PGPFPARMS pGpfParms );
  239. static VOID WmDestroyDialogStaff( PGPFPARMS pGpfParms );
  240. static VOID WmPaintDialogStaff( PGPFPARMS pGpfParms );
  241. static VOID WmShowDialogStaff( PGPFPARMS pGpfParms );
  242. static VOID WmHideDialogStaff( PGPFPARMS pGpfParms );
  243. static VOID CommandDialogStaff( PGPFPARMS pGpfParms );
  244. static VOID ActionListBoxOrg( PGPFPARMS pGpfParms );
  245. static VOID ActionShowOrg( PGPFPARMS pGpfParms );
  246. static VOID ActionCancel1( PGPFPARMS pGpfParms );
  247. static VOID ActionButtonHelp1( PGPFPARMS pGpfParms );
  248. static VOID WmInitWndListOrgWindow( PGPFPARMS pGpfParms );
  249. static VOID WmActiveListOrgWindow( PGPFPARMS pGpfParms );
  250. static VOID WmDeActiveListOrgWindow( PGPFPARMS pGpfParms );
  251. static VOID WmCreateListOrgWindow( PGPFPARMS pGpfParms );
  252. static VOID WmDestroyListOrgWindow( PGPFPARMS pGpfParms );
  253. static VOID WmPaintListOrgWindow( PGPFPARMS pGpfParms );
  254. static VOID WmShowListOrgWindow( PGPFPARMS pGpfParms );
  255. static VOID WmHideListOrgWindow( PGPFPARMS pGpfParms );
  256. static VOID CommandListOrgWindow( PGPFPARMS pGpfParms );
  257. static VOID ActionOK2( PGPFPARMS pGpfParms );
  258. static VOID WmInitWndDialogOrg( PGPFPARMS pGpfParms );
  259. static VOID WmActiveDialogOrg( PGPFPARMS pGpfParms );
  260. static VOID WmDeActiveDialogOrg( PGPFPARMS pGpfParms );
  261. static VOID WmCreateDialogOrg( PGPFPARMS pGpfParms );
  262. static VOID WmDestroyDialogOrg( PGPFPARMS pGpfParms );
  263. static VOID WmPaintDialogOrg( PGPFPARMS pGpfParms );
  264. static VOID WmShowDialogOrg( PGPFPARMS pGpfParms );
  265. static VOID WmHideDialogOrg( PGPFPARMS pGpfParms );
  266. static VOID CommandDialogOrg( PGPFPARMS pGpfParms );
  267.  
  268.  
  269. /*********************************************************************/
  270. /*                                     */
  271. /* SQL constants                             */
  272. /*                                     */
  273. /*********************************************************************/
  274.  
  275. struct sqlca sqlca;
  276.  
  277. EXEC SQL INCLUDE SQLCA;
  278. EXEC SQL INCLUDE SQLDA;
  279.  
  280. EXEC SQL BEGIN DECLARE SECTION;
  281.  
  282.  
  283. /*
  284.    Table   : ORG
  285.    Creator : USERID
  286. */
  287.  
  288. extern char     ORG_DEPTNAME [15];
  289. extern short     ORG_DEPTNAME_N;
  290. extern short     ORG_DEPTNUMB;
  291. extern char     ORG_DIVISION [11];
  292. extern short     ORG_DIVISION_N;
  293. extern char     ORG_LOCATION [14];
  294. extern short     ORG_LOCATION_N;
  295. extern short     ORG_MANAGER;
  296. extern short     ORG_MANAGER_N;
  297.  
  298.  
  299. /*
  300.    Table   : STAFF
  301.    Creator : USERID
  302. */
  303.  
  304. extern double     STAFF_COMM;
  305. extern short     STAFF_COMM_N;
  306. extern short     STAFF_DEPT;
  307. extern short     STAFF_DEPT_N;
  308. extern short     STAFF_ID;
  309. extern char     STAFF_JOB [6];
  310. extern short     STAFF_JOB_N;
  311. extern char     STAFF_NAME [10];
  312. extern short     STAFF_NAME_N;
  313. extern double     STAFF_SALARY;
  314. extern short     STAFF_SALARY_N;
  315. extern short     STAFF_YEARS;
  316. extern short     STAFF_YEARS_N;
  317.  
  318.  
  319. EXEC SQL END DECLARE SECTION;
  320.  
  321. /**********************************************************************/
  322. /**********************************************************************/
  323. /*                                      */
  324. /*   PRIVATE FUNCTION: ShowAboutWindow                      */
  325. /*                                      */
  326. /*   Show Window "AboutWindow".                       */
  327. /*                                      */
  328. /**********************************************************************/
  329.  
  330. BOOL  ShowAboutWindow( PVOID pCrtParms )
  331.  {
  332.  SWP Swp;
  333.  HWND hwndPrevious;
  334.  HWND hwndFramePrevious;
  335.  BOOL Rc;
  336.  
  337.                         /* Save Old Hwnd (Recur). */
  338.    hwndFramePrevious = hwndFrameAboutWindow;
  339.    hwndPrevious      = hwndAboutWindow;
  340.    CreateAboutWindow(pCrtParms);        /* Create New Window      */
  341.    WinSetWindowPos( hwndFrameAboutWindow,
  342.             NULL,0,0,0,0,SWP_RESTORE);
  343.    WinQueryWindowPos( hwndFrameAboutWindow, &Swp );
  344.    WinSetWindowPos( hwndFrameAboutWindow,
  345.             HWND_TOP,
  346.             Swp.x,Swp.y,Swp.cx,Swp.cy,
  347.             SWP_ZORDER | SWP_SIZE | SWP_MOVE |
  348.             SWP_ACTIVATE | SWP_SHOW
  349.           );
  350.    Rc = GpfProcessWnd( hwndFrameAboutWindow );
  351.                           /* Destroy Window   */
  352.    WinDestroyWindow( hwndFrameAboutWindow );
  353.                           /* Restore Old Hwnd */
  354.    hwndFrameAboutWindow = hwndFramePrevious;
  355.    hwndAboutWindow = hwndPrevious;
  356.    return(Rc);
  357.  }
  358.  
  359. /**********************************************************************/
  360. /**********************************************************************/
  361. /*                                      */
  362. /*   PRIVATE FUNCTION: DismissAboutWindow                  */
  363. /*                                      */
  364. /*   Dismiss Window Hide - Window "AboutWindow".              */
  365. /*                                      */
  366. /**********************************************************************/
  367.  
  368. VOID  DismissAboutWindow( BOOL Rcode )
  369.  {
  370.                             /* Dismiss Window */
  371.    GpfDismissWnd(hwndFrameAboutWindow,Rcode);
  372.  
  373.  }
  374.  
  375. /**********************************************************************/
  376. /**********************************************************************/
  377. /*                                      */
  378. /*   PRIVATE FUNCTION: CreateAboutWindow                  */
  379. /*                                      */
  380. /*   Create the window "AboutWindow" And Controls.              */
  381. /*                                      */
  382. /**********************************************************************/
  383.  
  384. VOID CreateAboutWindow( PVOID pCrtParms)
  385.  {
  386.   /********************************************************************/
  387.   /*   Register the window class "AboutWindow".               */
  388.   /********************************************************************/
  389.   WinRegisterClass(              /* Register window class    */
  390.       habAboutTask,           /* Anchor block handle      */
  391.       "AboutWindow",          /* Window class name          */
  392.       fnwpAboutWindow,          /* Address window procedure */
  393.       CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style          */
  394.       CS_MOVENOTIFY |          /* Class style          */
  395.       CS_SIZEREDRAW | CS_SYNCPAINT,   /* Class style          */
  396.       EXTRAWORDS              /* Extra window words       */
  397.       );
  398.  
  399.   /********************************************************************/
  400.   /*   Create the window "AboutWindow".                   */
  401.   /********************************************************************/
  402.   hwndFrameAboutWindow =                  /* Save Hwnd    */
  403.   GpfCreateTemplate( ID_ABOUTWINDOW,              /* Ressource Id */
  404.              hmodSample,              /* Ressource Md */
  405.              HWND_DESKTOP,              /* Hwnd Parent  */
  406.              HWND_DESKTOP,              /* Hwnd Owner   */
  407.              pCrtParms);              /* User Parms   */
  408.  }
  409. /**********************************************************************/
  410. /* End of Private Function - CreateAboutWindow                  */
  411. /**********************************************************************/
  412. /**********************************************************************/
  413.  
  414.  
  415.  
  416. /**********************************************************************/
  417. /**********************************************************************/
  418. /*                                      */
  419. /*  WinProc: fnwpAboutWindow                          */
  420. /*                                      */
  421. /*  Controls the "AboutWindow" Area.                      */
  422. /*                                      */
  423. /*                                      */
  424. /**********************************************************************/
  425.  
  426. MRESULT  EXPENTRY fnwpAboutWindow(
  427.           HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  428. {
  429.   HPS        hps;          /* Presentation space handle         */
  430.   RECTL     rcl;          /* Window rectangle             */
  431.   PGPFPARMS pGpfParms;          /* Far Pointer             */
  432.   SEL        Selector;          /* Seloctor                 */
  433.  
  434.   /*******************************************************************/
  435.   /* Initialize Gpf Parameters                         */
  436.   /*******************************************************************/
  437.   pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
  438.   if (pGpfParms)
  439.      {
  440.       pGpfParms->hwnd     = hwnd;      /* window handle             */
  441.       pGpfParms->msg     = msg;       /* message number          */
  442.       pGpfParms->mp1     = mp1;       /* 1st (packed) parms         */
  443.       pGpfParms->mp2     = mp2;       /* 2nd (packed) parms         */
  444.       pGpfParms->mresult = (MRESULT) FALSE; /* Mresult             */
  445.       pGpfParms->Command = 0;          /* Command From mp1 (SHORT 1)  */
  446.       pGpfParms->Notify  = 0;          /* Notify  From mp1 (SHORT 2)  */
  447.      }
  448.  
  449.   switch(msg)
  450.   {
  451.     /**************************************************************/
  452.     /* Things to do when the Window is first initalized          */
  453.     /**************************************************************/
  454.    case WM_INITDLG:
  455.     /**************************************************************/
  456.     /*  Initialize Window 'AboutWindow'                  */
  457.     /**************************************************************/
  458.     GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  459.     WmInitWndAboutWindow(pGpfParms); /* Init Dialog           */
  460.     /**************************************************************/
  461.     /*  Return pGpfParms Mresult                      */
  462.     /**************************************************************/
  463.     return (pGpfParms->mresult);
  464.  
  465.     /**************************************************************/
  466.     /* Things to do when the Window is End LogoTimer          */
  467.     /**************************************************************/
  468.    case WM_TIMER:
  469.     WinStopTimer(WinQueryAnchorBlock(hwnd),
  470.              hwnd,TID_USERMAX);     /* Stop LogoTimer     */
  471.     /**************************************************************/
  472.     /* Simulate CANCEL - Post Did CANCEL to Window              */
  473.     /**************************************************************/
  474.     WinPostMsg( hwnd,
  475.             WM_COMMAND,         /* simulate CANCEL          */
  476.             MPFROM2SHORT( DID_CANCEL   , 0 ),
  477.             MPFROM2SHORT( CMDSRC_OTHER , 0 )
  478.           );
  479.     break;
  480.  
  481.     /**************************************************************/
  482.     /* Things to do when the Window is Activated/Deactivated      */
  483.     /**************************************************************/
  484.    case WM_ACTIVATE:
  485.     if (SHORT1FROMMP(mp1))
  486.         WmActiveAboutWindow(pGpfParms);     /* Activate Window   */
  487.     else
  488.         WmDeActiveAboutWindow(pGpfParms);     /* DeActivate Window */
  489.     return (pGpfParms->mresult);
  490.  
  491.     /**************************************************************/
  492.     /* Things to do when the Window is "Show/Hide"              */
  493.     /**************************************************************/
  494.    case WM_SHOW:
  495.     if (SHORT1FROMMP(mp1))
  496.         WmShowAboutWindow(pGpfParms);           /* Show Window */
  497.     else
  498.         WmHideAboutWindow(pGpfParms);           /* Hide Window */
  499.     return (pGpfParms->mresult);
  500.  
  501.     /**************************************************************/
  502.     /* The application has asked for the window to be created.    */
  503.     /**************************************************************/
  504.    case WM_CREATE:
  505.     DosAllocSeg(sizeof(GPFPARMS),&Selector,0);    /* Getmain    */
  506.     pGpfParms = MAKEP(Selector, 0);         /* Set Pointer*/
  507.     WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
  508.     memset(pGpfParms,0,sizeof(GPFPARMS));        /* Clear Area */
  509.     hwndAboutWindow = hwnd;              /* Save Hwnd */
  510.     hwndFrameAboutWindow = GpfGetHwndFrame(hwnd);
  511.     pGpfParms->hwnd = hwnd;            /* window handle       */
  512.     pGpfParms->msg    = msg;               /* message number      */
  513.     pGpfParms->mp1    = mp1;               /* 1st (packed) parms  */
  514.     pGpfParms->mp2    = mp2;               /* 2nd (packed) parms  */
  515.     pGpfParms->hmod = hmodSample;    
  516.     pGpfParms->hab    = habAboutTask;        /* Anchor block handle */
  517.     WmCreateAboutWindow(pGpfParms);        /* Create  Window      */
  518.     break;
  519.  
  520.     /**************************************************************/
  521.     /* The application has asked for the window to be destroyed.  */
  522.     /**************************************************************/
  523.    case WM_DESTROY:
  524.     WinStopTimer(WinQueryAnchorBlock(hwnd),
  525.              hwnd,TID_USERMAX);         /* Stop LogoTimer */
  526.     WmDestroyAboutWindow(pGpfParms);        /* Destroy Window */
  527.     hwndFrameAboutWindow = (HWND)NULL;        /* Reset HwndFrm  */
  528.     hwndAboutWindow = (HWND)NULL;            /* Reset Hwnd     */
  529.     /* Destroy Template , Help Instance and GpfParms          */
  530.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  531.  
  532.     /**************************************************************/
  533.     /* The window needs painting.                      */
  534.     /**************************************************************/
  535.    case WM_PAINT:
  536.     /**************************************************************/
  537.     /* Obtain a cache PS                          */
  538.     /**************************************************************/
  539.     hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
  540.     WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect          */
  541.     pGpfParms->hps = hps;            /* Pass Hps ( Paint ) */
  542.     WmPaintAboutWindow(pGpfParms);        /* Paint Window       */
  543.     WinEndPaint( hps );            /* Release cache PS   */
  544.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  545.  
  546.     /**************************************************************/
  547.     /* Process ScrollBar received from the user              */
  548.     /**************************************************************/
  549.     case WM_VSCROLL:
  550.     case WM_HSCROLL:
  551.     /* Set Command From mp1 */
  552.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  553.     /* Set Notify From mp2    */
  554.     pGpfParms->Notify = SHORT2FROMMP( mp2 );
  555.     CommandAboutWindow( pGpfParms );      /* Process the command  */
  556.     return (pGpfParms->mresult);
  557.  
  558.     /**************************************************************/
  559.     /* Process Controls received from the user              */
  560.     /**************************************************************/
  561.    case WM_CONTROL:
  562.     /* Set Command From mp1 */
  563.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  564.     /* Set Notify From mp1    */
  565.     pGpfParms->Notify = SHORT2FROMMP( mp1 );
  566.     CommandAboutWindow( pGpfParms );      /* Process the command  */
  567.     return (pGpfParms->mresult);
  568.  
  569.     /**************************************************************/
  570.     /* Process commands received from the user              */
  571.     /**************************************************************/
  572.    case WM_SYSCOMMAND:
  573.    case WM_HELP:
  574.    case WM_COMMAND:
  575.     /* Set Command From mp1 */
  576.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  577.     pGpfParms->Notify = COMMAND;          /* Set Notify From mp1  */
  578.     CommandAboutWindow( pGpfParms );      /* Process the command  */
  579.     if (pGpfParms->mresult)
  580.         return (pGpfParms->mresult);
  581.     /* If DID_CANCEL Dismiss Window */
  582.     if (pGpfParms->Command == DID_CANCEL)
  583.         DismissAboutWindow(FALSE);
  584.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  585.  
  586.     /**************************************************************/
  587.     /* All other messages are passed to the default procedure.    */
  588.     /**************************************************************/
  589.    default:
  590.     /* Pass all other messages to the default window procedure    */
  591.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  592.   }
  593.   return ((MRESULT) FALSE);
  594. }
  595. /**********************************************************************/
  596. /* End of window procedure - WinProc: fnwpAboutWindow              */
  597. /**********************************************************************/
  598. /**********************************************************************/
  599.  
  600.  
  601.  
  602. /**********************************************************************/
  603. /**********************************************************************/
  604. /*                                      */
  605. /*   PRIVATE FUNCTION: CommandAboutWindow                  */
  606. /*                                      */
  607. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  608. /*   received by the window procedure.                      */
  609. /*   Window "AboutWindow".                          */
  610. /*                                      */
  611. /**********************************************************************/
  612.  
  613. static VOID CommandAboutWindow ( PGPFPARMS pGpfParms )
  614. {
  615.   pGpfParms->mresult = (MRESULT) TRUE;        /* Set Return Code    */
  616.   /* Switch according to Control chosen                   */
  617.   switch( pGpfParms->Command )
  618.   {
  619.     /******************************************************************/
  620.     /* Name  "AboutOk".                           */
  621.     /* Alias "DID_CANCEL".                          */
  622.     /* Text  "~Ok".                              */
  623.     /******************************************************************/
  624.     case ID_ABOUTOK:
  625.     case DID_CANCEL:
  626.      ActionAboutOk(pGpfParms);
  627.      return;
  628.   }
  629.   /* Take no action for any other selections                  */
  630.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  631. }
  632. /**********************************************************************/
  633. /* End of Private Function: CommandAboutWindow                  */
  634. /**********************************************************************/
  635. /**********************************************************************/
  636.  
  637.  
  638. /**********************************************************************/
  639. /**********************************************************************/
  640. /*                                      */
  641. /*   STATIC PRIVATE FUNCTION: ActionAboutOk                  */
  642. /*                                      */
  643. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  644. /*   received by the window procedure.                      */
  645. /*   Window "AboutWindow".                          */
  646. /*                                      */
  647. /**********************************************************************/
  648.  
  649. static VOID ActionAboutOk( PGPFPARMS pGpfParms )
  650. {
  651.   /* Switch according to Control chosen                   */
  652.   switch( pGpfParms->Notify )
  653.   {
  654.    case BN_CLICKED:
  655.    case BN_DBLCLICKED:
  656.    case COMMAND:
  657.     /**************************************************************/
  658.     /* Dismiss Window Hide Window "AboutWindow".              */
  659.     /**************************************************************/
  660.     DismissAboutWindow(FALSE);
  661.     /**************************************************************/
  662.     /* Enable Menu/Item "About".                      */
  663.     /* Window "MainWindow".                       */
  664.     /**************************************************************/
  665.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT,FALSE);
  666.     /**************************************************************/
  667.     /* Enable Menu/Item "About1".                      */
  668.     /* Window "MainWindow".                       */
  669.     /**************************************************************/
  670.     GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,FALSE);
  671.     /**************************************************************/
  672.     /* Enable Control  "UserButton".                  */
  673.     /* Window "ListStaffWindow".                      */
  674.     /**************************************************************/
  675.     WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
  676.             ID_USERBUTTON),
  677.             TRUE);
  678.     return;
  679.   }
  680.   /* Take no action for any other selections                  */
  681. }
  682. /**********************************************************************/
  683. /* End of Private Function                          */
  684. /**********************************************************************/
  685. /**********************************************************************/
  686.  
  687.  
  688. /**********************************************************************/
  689. /**********************************************************************/
  690. /*                                      */
  691. /*   PRIVATE FUNCTION: MoveAboutWindowToData                  */
  692. /*                                      */
  693. /*   Move "AboutWindow" To Assosiate Data.                  */
  694. /*                                      */
  695. /**********************************************************************/
  696.  
  697. BOOL  MoveAboutWindowToData ( VOID )
  698.  {
  699.   UCHAR  String[32];
  700.   PUCHAR Token;
  701.  
  702.   String[0] = 0;     /* Null, Delete Unreferenced Local variable */
  703.   Token  = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  704.  
  705.  
  706.       return (TRUE);
  707.  }
  708. /**********************************************************************/
  709. /* End of Private Function: MoveAboutWindowToData              */
  710. /**********************************************************************/
  711. /**********************************************************************/
  712.  
  713.  
  714.  
  715. /**********************************************************************/
  716. /**********************************************************************/
  717. /*                                      */
  718. /*   PRIVATE FUNCTION: MoveDataToAboutWindow                  */
  719. /*                                      */
  720. /*   Move Data To Window "AboutWindow".                   */
  721. /*                                      */
  722. /**********************************************************************/
  723.  
  724. BOOL  MoveDataToAboutWindow ( VOID )
  725.  {
  726.   UCHAR  String[32];
  727.   PUCHAR Token;
  728.  
  729.   String[0] = 0;      /* Null, Delete Unreferenced Local variable */
  730.   Token   = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  731.  
  732.  
  733.       return (TRUE);
  734.  }
  735. /**********************************************************************/
  736. /* End of Private Function: MoveDataToAboutWindow              */
  737. /**********************************************************************/
  738. /**********************************************************************/
  739.  
  740.  
  741.  
  742. /**********************************************************************/
  743. /**********************************************************************/
  744. /*                                      */
  745. /*   PRIVATE FUNCTION: WmInitWndAboutWindow                  */
  746. /*                                      */
  747. /*   Wm Init Window "AboutWindow".                      */
  748. /*                                      */
  749. /**********************************************************************/
  750.  
  751. static VOID WmInitWndAboutWindow ( PGPFPARMS pGpfParms )
  752.  {
  753.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  754.     /**************************************************************/
  755.     /* Center Window "AboutWindow".                   */
  756.     /* Positions Window in the center of the screen           */
  757.     /**************************************************************/
  758.     GpfSetCentreWindow(hwndFrameAboutWindow);
  759.  }
  760. /**********************************************************************/
  761. /* End of Private Function: WmInitWndAboutWindow              */
  762. /**********************************************************************/
  763. /**********************************************************************/
  764.  
  765.  
  766.  
  767. /**********************************************************************/
  768. /**********************************************************************/
  769. /*                                      */
  770. /*   PRIVATE FUNCTION: WmActiveAboutWindow                  */
  771. /*                                      */
  772. /*   Wm Activate Window "AboutWindow".                      */
  773. /*                                      */
  774. /**********************************************************************/
  775.  
  776. static VOID WmActiveAboutWindow ( PGPFPARMS pGpfParms )
  777.  {
  778.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  779.   WinStartTimer(WinQueryAnchorBlock(pGpfParms->hwnd),
  780.         pGpfParms->hwnd,TID_USERMAX,LogoTimer);
  781.   LogoTimer = -1;              /* Set Indefinite LogoTimer */
  782.  }
  783. /**********************************************************************/
  784. /* End of Private Function: WmActiveAboutWindow               */
  785. /**********************************************************************/
  786. /**********************************************************************/
  787.  
  788.  
  789.  
  790. /**********************************************************************/
  791. /**********************************************************************/
  792. /*                                      */
  793. /*   PRIVATE FUNCTION: WmDeActiveAboutWindow                  */
  794. /*                                      */
  795. /*   DeActivate Window "AboutWindow".                      */
  796. /*                                      */
  797. /**********************************************************************/
  798.  
  799. static VOID WmDeActiveAboutWindow ( PGPFPARMS pGpfParms )
  800.  {
  801.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  802.  }
  803. /**********************************************************************/
  804. /* End of Private Function: WmDeActiveAboutWindow              */
  805. /**********************************************************************/
  806. /**********************************************************************/
  807.  
  808.  
  809.  
  810. /**********************************************************************/
  811. /**********************************************************************/
  812. /*                                      */
  813. /*   PRIVATE FUNCTION: WmCreateAboutWindow                  */
  814. /*                                      */
  815. /*   Wm Create Window "AboutWindow".                      */
  816. /*                                      */
  817. /**********************************************************************/
  818.  
  819. static VOID WmCreateAboutWindow ( PGPFPARMS pGpfParms )
  820.  {
  821.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  822.  }
  823. /**********************************************************************/
  824. /* End of Private Function: WmCreateAboutWindow               */
  825. /**********************************************************************/
  826. /**********************************************************************/
  827.  
  828.  
  829.  
  830. /**********************************************************************/
  831. /**********************************************************************/
  832. /*                                      */
  833. /*   PRIVATE FUNCTION: WmDestroyAboutWindow                  */
  834. /*                                      */
  835. /*   Wm Destroy Window "AboutWindow".                      */
  836. /*                                      */
  837. /**********************************************************************/
  838.  
  839. static VOID WmDestroyAboutWindow ( PGPFPARMS pGpfParms )
  840.  {
  841.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  842.  }
  843. /**********************************************************************/
  844. /* End of Private Function: WmDestroyAboutWindow              */
  845. /**********************************************************************/
  846. /**********************************************************************/
  847.  
  848.  
  849.  
  850. /**********************************************************************/
  851. /**********************************************************************/
  852. /*                                      */
  853. /*   PRIVATE FUNCTION: WmPaintAboutWindow                  */
  854. /*                                      */
  855. /*   Wm Paint Window "AboutWindow".                      */
  856. /*                                      */
  857. /**********************************************************************/
  858.  
  859. static VOID WmPaintAboutWindow ( PGPFPARMS pGpfParms )
  860.  {
  861.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  862.  }
  863. /**********************************************************************/
  864. /* End of Private Function: WmPaintAboutWindow                  */
  865. /**********************************************************************/
  866. /**********************************************************************/
  867.  
  868.  
  869.  
  870. /**********************************************************************/
  871. /**********************************************************************/
  872. /*                                      */
  873. /*   PRIVATE FUNCTION: WmShowAboutWindow                  */
  874. /*                                      */
  875. /*   Wm Show Window "AboutWindow".                      */
  876. /*                                      */
  877. /**********************************************************************/
  878.  
  879. static VOID WmShowAboutWindow ( PGPFPARMS pGpfParms )
  880.  {
  881.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  882.  }
  883. /**********************************************************************/
  884. /* End of Private Function: WmShowAboutWindow                  */
  885. /**********************************************************************/
  886. /**********************************************************************/
  887.  
  888.  
  889.  
  890. /**********************************************************************/
  891. /**********************************************************************/
  892. /*                                      */
  893. /*   PRIVATE FUNCTION: WmHideAboutWindow                  */
  894. /*                                      */
  895. /*   Wm Hide Window "AboutWindow".                      */
  896. /*                                      */
  897. /**********************************************************************/
  898.  
  899. static VOID WmHideAboutWindow ( PGPFPARMS pGpfParms )
  900.  {
  901.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  902.  }
  903. /**********************************************************************/
  904. /* End of Private Function: WmHideAboutWindow                  */
  905. /**********************************************************************/
  906. /**********************************************************************/
  907.  
  908.  
  909. /**********************************************************************/
  910. /**********************************************************************/
  911. /*                                      */
  912. /*   PRIVATE FUNCTION: ShowDialogStaff                      */
  913. /*                                      */
  914. /*   Show Window "DialogStaff".                       */
  915. /*                                      */
  916. /**********************************************************************/
  917.  
  918. BOOL  ShowDialogStaff( PVOID pCrtParms )
  919.  {
  920.  SWP Swp;
  921.  HWND hwndPrevious;
  922.  HWND hwndFramePrevious;
  923.  BOOL Rc;
  924.  
  925.                         /* Save Old Hwnd (Recur). */
  926.    hwndFramePrevious = hwndFrameDialogStaff;
  927.    hwndPrevious      = hwndDialogStaff;
  928.    CreateDialogStaff(pCrtParms);        /* Create New Window      */
  929.    WinSetWindowPos( hwndFrameDialogStaff,
  930.             NULL,0,0,0,0,SWP_RESTORE);
  931.    WinQueryWindowPos( hwndFrameDialogStaff, &Swp );
  932.    WinSetWindowPos( hwndFrameDialogStaff,
  933.             HWND_TOP,
  934.             Swp.x,Swp.y,Swp.cx,Swp.cy,
  935.             SWP_ZORDER | SWP_SIZE | SWP_MOVE |
  936.             SWP_ACTIVATE | SWP_SHOW
  937.           );
  938.    Rc = GpfProcessWnd( hwndFrameDialogStaff );
  939.                           /* Destroy Window   */
  940.    WinDestroyWindow( hwndFrameDialogStaff );
  941.                           /* Restore Old Hwnd */
  942.    hwndFrameDialogStaff = hwndFramePrevious;
  943.    hwndDialogStaff = hwndPrevious;
  944.    return(Rc);
  945.  }
  946.  
  947. /**********************************************************************/
  948. /**********************************************************************/
  949. /*                                      */
  950. /*   PRIVATE FUNCTION: DismissDialogStaff                  */
  951. /*                                      */
  952. /*   Dismiss Window Hide - Window "DialogStaff".              */
  953. /*                                      */
  954. /**********************************************************************/
  955.  
  956. VOID  DismissDialogStaff( BOOL Rcode )
  957.  {
  958.                             /* Dismiss Window */
  959.    GpfDismissWnd(hwndFrameDialogStaff,Rcode);
  960.  
  961.  }
  962.  
  963. /**********************************************************************/
  964. /**********************************************************************/
  965. /*                                      */
  966. /*   PRIVATE FUNCTION: CreateDialogStaff                  */
  967. /*                                      */
  968. /*   Create the window "DialogStaff" And Controls.              */
  969. /*                                      */
  970. /**********************************************************************/
  971.  
  972. VOID CreateDialogStaff( PVOID pCrtParms)
  973.  {
  974.   /********************************************************************/
  975.   /*   Register the window class "DialogStaff".               */
  976.   /********************************************************************/
  977.   WinRegisterClass(              /* Register window class    */
  978.       habMainTask,              /* Anchor block handle      */
  979.       "DialogStaff",          /* Window class name          */
  980.       fnwpDialogStaff,          /* Address window procedure */
  981.       CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style          */
  982.       CS_MOVENOTIFY |          /* Class style          */
  983.       CS_SIZEREDRAW | CS_SYNCPAINT,   /* Class style          */
  984.       EXTRAWORDS              /* Extra window words       */
  985.       );
  986.  
  987.   /********************************************************************/
  988.   /*   Create the window "DialogStaff".                   */
  989.   /********************************************************************/
  990.   hwndFrameDialogStaff =                  /* Save Hwnd    */
  991.   GpfCreateTemplate( ID_DIALOGSTAFF,              /* Ressource Id */
  992.              hmodSample,              /* Ressource Md */
  993.              HWND_DESKTOP,              /* Hwnd Parent  */
  994.              HWND_DESKTOP,              /* Hwnd Owner   */
  995.              pCrtParms);              /* User Parms   */
  996.  }
  997. /**********************************************************************/
  998. /* End of Private Function - CreateDialogStaff                  */
  999. /**********************************************************************/
  1000. /**********************************************************************/
  1001.  
  1002.  
  1003.  
  1004. /**********************************************************************/
  1005. /**********************************************************************/
  1006. /*                                      */
  1007. /*  WinProc: fnwpDialogStaff                          */
  1008. /*                                      */
  1009. /*  Controls the "DialogStaff" Area.                      */
  1010. /*                                      */
  1011. /*                                      */
  1012. /**********************************************************************/
  1013.  
  1014. MRESULT  EXPENTRY fnwpDialogStaff(
  1015.           HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  1016. {
  1017.   HPS        hps;          /* Presentation space handle         */
  1018.   RECTL     rcl;          /* Window rectangle             */
  1019.   PGPFPARMS pGpfParms;          /* Far Pointer             */
  1020.   SEL        Selector;          /* Seloctor                 */
  1021.  
  1022.   /*******************************************************************/
  1023.   /* Initialize Gpf Parameters                         */
  1024.   /*******************************************************************/
  1025.   pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
  1026.   if (pGpfParms)
  1027.      {
  1028.       pGpfParms->hwnd     = hwnd;      /* window handle             */
  1029.       pGpfParms->msg     = msg;       /* message number          */
  1030.       pGpfParms->mp1     = mp1;       /* 1st (packed) parms         */
  1031.       pGpfParms->mp2     = mp2;       /* 2nd (packed) parms         */
  1032.       pGpfParms->mresult = (MRESULT) FALSE; /* Mresult             */
  1033.       pGpfParms->Command = 0;          /* Command From mp1 (SHORT 1)  */
  1034.       pGpfParms->Notify  = 0;          /* Notify  From mp1 (SHORT 2)  */
  1035.      }
  1036.  
  1037.   switch(msg)
  1038.   {
  1039.     /**************************************************************/
  1040.     /* Things to do when the Window is first initalized          */
  1041.     /**************************************************************/
  1042.    case WM_INITDLG:
  1043.     /**************************************************************/
  1044.     /*  Initialize Window 'DialogStaff'                  */
  1045.     /**************************************************************/
  1046.     GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1047.     WmInitWndDialogStaff(pGpfParms); /* Init Dialog           */
  1048.     /**************************************************************/
  1049.     /*  Return pGpfParms Mresult                      */
  1050.     /**************************************************************/
  1051.     return (pGpfParms->mresult);
  1052.  
  1053.     /**************************************************************/
  1054.     /* Things to do when the Window is Activated/Deactivated      */
  1055.     /**************************************************************/
  1056.    case WM_ACTIVATE:
  1057.     if (SHORT1FROMMP(mp1))
  1058.         WmActiveDialogStaff(pGpfParms);     /* Activate Window   */
  1059.     else
  1060.         WmDeActiveDialogStaff(pGpfParms);     /* DeActivate Window */
  1061.     return (pGpfParms->mresult);
  1062.  
  1063.     /**************************************************************/
  1064.     /* Things to do when the Window is "Show/Hide"              */
  1065.     /**************************************************************/
  1066.    case WM_SHOW:
  1067.     if (SHORT1FROMMP(mp1))
  1068.         WmShowDialogStaff(pGpfParms);           /* Show Window */
  1069.     else
  1070.         WmHideDialogStaff(pGpfParms);           /* Hide Window */
  1071.     return (pGpfParms->mresult);
  1072.  
  1073.     /**************************************************************/
  1074.     /* The application has asked for the window to be created.    */
  1075.     /**************************************************************/
  1076.    case WM_CREATE:
  1077.     DosAllocSeg(sizeof(GPFPARMS),&Selector,0);    /* Getmain    */
  1078.     pGpfParms = MAKEP(Selector, 0);         /* Set Pointer*/
  1079.     WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
  1080.     memset(pGpfParms,0,sizeof(GPFPARMS));        /* Clear Area */
  1081.     pGpfParms->Options |= GPF_OP_MSGINFO;     /* Set Msg Info      */
  1082.     pGpfParms->Options |= GPF_OP_ADJUSTSIZE; /* Set AdjustSize    */
  1083.     hwndDialogStaff = hwnd;              /* Save Hwnd */
  1084.     hwndFrameDialogStaff = GpfGetHwndFrame(hwnd);
  1085.     pGpfParms->hwnd = hwnd;            /* window handle       */
  1086.     pGpfParms->msg    = msg;               /* message number      */
  1087.     pGpfParms->mp1    = mp1;               /* 1st (packed) parms  */
  1088.     pGpfParms->mp2    = mp2;               /* 2nd (packed) parms  */
  1089.     pGpfParms->hmod = hmodSample;    
  1090.     pGpfParms->hab    = habMainTask;           /* Anchor block handle */
  1091.     WmCreateDialogStaff(pGpfParms);        /* Create  Window      */
  1092.     break;
  1093.  
  1094.     /**************************************************************/
  1095.     /* The application has asked for the window to be destroyed.  */
  1096.     /**************************************************************/
  1097.    case WM_DESTROY:
  1098.     WmDestroyDialogStaff(pGpfParms);        /* Destroy Window */
  1099.     hwndFrameDialogStaff = (HWND)NULL;        /* Reset HwndFrm  */
  1100.     hwndDialogStaff = (HWND)NULL;            /* Reset Hwnd     */
  1101.     /* Destroy Template , Help Instance and GpfParms          */
  1102.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1103.  
  1104.     /**************************************************************/
  1105.     /* The window needs painting.                      */
  1106.     /**************************************************************/
  1107.    case WM_PAINT:
  1108.     /**************************************************************/
  1109.     /* Obtain a cache PS                          */
  1110.     /**************************************************************/
  1111.     hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
  1112.     WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect          */
  1113.     pGpfParms->hps = hps;            /* Pass Hps ( Paint ) */
  1114.     WmPaintDialogStaff(pGpfParms);        /* Paint Window       */
  1115.     WinEndPaint( hps );            /* Release cache PS   */
  1116.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1117.  
  1118.     /**************************************************************/
  1119.     /* Process ScrollBar received from the user              */
  1120.     /**************************************************************/
  1121.     case WM_VSCROLL:
  1122.     case WM_HSCROLL:
  1123.     /* Set Command From mp1 */
  1124.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1125.     /* Set Notify From mp2    */
  1126.     pGpfParms->Notify = SHORT2FROMMP( mp2 );
  1127.     CommandDialogStaff( pGpfParms );      /* Process the command  */
  1128.     return (pGpfParms->mresult);
  1129.  
  1130.     /**************************************************************/
  1131.     /* Process Controls received from the user              */
  1132.     /**************************************************************/
  1133.    case WM_CONTROL:
  1134.     /* Set Command From mp1 */
  1135.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1136.     /* Set Notify From mp1    */
  1137.     pGpfParms->Notify = SHORT2FROMMP( mp1 );
  1138.     CommandDialogStaff( pGpfParms );      /* Process the command  */
  1139.     return (pGpfParms->mresult);
  1140.  
  1141.     /**************************************************************/
  1142.     /* Process commands received from the user              */
  1143.     /**************************************************************/
  1144.    case WM_SYSCOMMAND:
  1145.    case WM_HELP:
  1146.    case WM_COMMAND:
  1147.     /* Set Command From mp1 */
  1148.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1149.     pGpfParms->Notify = COMMAND;          /* Set Notify From mp1  */
  1150.     CommandDialogStaff( pGpfParms );      /* Process the command  */
  1151.     if (pGpfParms->mresult)
  1152.         return (pGpfParms->mresult);
  1153.     /* If DID_CANCEL Dismiss Window */
  1154.     if (pGpfParms->Command == DID_CANCEL)
  1155.         DismissDialogStaff(FALSE);
  1156.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1157.  
  1158.     /**************************************************************/
  1159.     /* All other messages are passed to the default procedure.    */
  1160.     /**************************************************************/
  1161.    default:
  1162.     /* Pass all other messages to the default window procedure    */
  1163.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1164.   }
  1165.   return ((MRESULT) FALSE);
  1166. }
  1167. /**********************************************************************/
  1168. /* End of window procedure - WinProc: fnwpDialogStaff              */
  1169. /**********************************************************************/
  1170. /**********************************************************************/
  1171.  
  1172.  
  1173.  
  1174. /**********************************************************************/
  1175. /**********************************************************************/
  1176. /*                                      */
  1177. /*   PRIVATE FUNCTION: CommandDialogStaff                  */
  1178. /*                                      */
  1179. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  1180. /*   received by the window procedure.                      */
  1181. /*   Window "DialogStaff".                          */
  1182. /*                                      */
  1183. /**********************************************************************/
  1184.  
  1185. static VOID CommandDialogStaff ( PGPFPARMS pGpfParms )
  1186. {
  1187.   pGpfParms->mresult = (MRESULT) TRUE;        /* Set Return Code    */
  1188.   /* Switch according to Control chosen                   */
  1189.   switch( pGpfParms->Command )
  1190.   {
  1191.     /******************************************************************/
  1192.     /* Name  "Ok".                              */
  1193.     /* Alias "DID_CANCEL".                          */
  1194.     /* Text  "~OK".                              */
  1195.     /******************************************************************/
  1196.     case ID_OK:
  1197.     case DID_CANCEL:
  1198.      ActionOk(pGpfParms);    
  1199.      return;
  1200.   }
  1201.   /* Take no action for any other selections                  */
  1202.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  1203. }
  1204. /**********************************************************************/
  1205. /* End of Private Function: CommandDialogStaff                  */
  1206. /**********************************************************************/
  1207. /**********************************************************************/
  1208.  
  1209.  
  1210. /**********************************************************************/
  1211. /**********************************************************************/
  1212. /*                                      */
  1213. /*   STATIC PRIVATE FUNCTION: ActionOk                      */
  1214. /*                                      */
  1215. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  1216. /*   received by the window procedure.                      */
  1217. /*   Window "DialogStaff".                          */
  1218. /*                                      */
  1219. /**********************************************************************/
  1220.  
  1221. static VOID ActionOk( PGPFPARMS pGpfParms )    
  1222. {
  1223.   /* Switch according to Control chosen                   */
  1224.   switch( pGpfParms->Notify )
  1225.   {
  1226.    case BN_CLICKED:
  1227.    case BN_DBLCLICKED:
  1228.    case COMMAND:
  1229.     /**************************************************************/
  1230.     /* Dismiss Window Hide Window "DialogStaff".              */
  1231.     /**************************************************************/
  1232.     DismissDialogStaff(FALSE);
  1233.     return;
  1234.   }
  1235.   /* Take no action for any other selections                  */
  1236. }
  1237. /**********************************************************************/
  1238. /* End of Private Function                          */
  1239. /**********************************************************************/
  1240. /**********************************************************************/
  1241.  
  1242.  
  1243. /**********************************************************************/
  1244. /**********************************************************************/
  1245. /*                                      */
  1246. /*   PRIVATE FUNCTION: MoveDialogStaffToData                  */
  1247. /*                                      */
  1248. /*   Move "DialogStaff" To Assosiate Data.                  */
  1249. /*                                      */
  1250. /**********************************************************************/
  1251.  
  1252. BOOL  MoveDialogStaffToData ( VOID )
  1253.  {
  1254.   UCHAR  String[32];
  1255.   PUCHAR Token;
  1256.  
  1257.   String[0] = 0;     /* Null, Delete Unreferenced Local variable */
  1258.   Token  = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  1259.  
  1260. /**********************************************************************/
  1261. /*   Move "ID_ID" To "STAFF_ID".    (SMALLINT)              */
  1262. /**********************************************************************/
  1263.  
  1264.  
  1265.       WinQueryWindowText( WinWindowFromID( hwndDialogStaff,
  1266.                        ID_ID),    
  1267.               sizeof(String),
  1268.               String);
  1269.       if (!GpfStringIsNumeric(String))
  1270.      {
  1271.       WinSetFocus( HWND_DESKTOP,
  1272.                WinWindowFromID(hwndDialogStaff,ID_ID));
  1273.       return FALSE;
  1274.      }
  1275.       STAFF_ID = atoi(String);           /* Convert String to Short */
  1276.  
  1277. /**********************************************************************/
  1278. /*   Move "ID_NAME" To "STAFF_NAME".    (VARCHAR)              */
  1279. /**********************************************************************/
  1280.  
  1281.  
  1282.       WinQueryWindowText( WinWindowFromID( hwndDialogStaff,
  1283.                        ID_NAME),    
  1284.               sizeof(STAFF_NAME),
  1285.               STAFF_NAME);    
  1286.       if (!STAFF_NAME[0])            /* If Null Data          */
  1287.       STAFF_NAME_N = -1;            /* Set Sql Null Indicator */
  1288.  
  1289. /**********************************************************************/
  1290. /*   Move "ID_JOB" To "STAFF_JOB".    (CHAR)                  */
  1291. /**********************************************************************/
  1292.  
  1293.  
  1294.       WinQueryWindowText( WinWindowFromID( hwndDialogStaff,
  1295.                        ID_JOB),    
  1296.               sizeof(STAFF_JOB),
  1297.               STAFF_JOB);
  1298.       if (!STAFF_JOB[0])            /* If Null Data          */
  1299.       STAFF_JOB_N = -1;            /* Set Sql Null Indicator */
  1300.  
  1301. /**********************************************************************/
  1302. /*   Move "ID_DEPT" To "STAFF_DEPT".    (SMALLINT)              */
  1303. /**********************************************************************/
  1304.  
  1305.  
  1306.       WinQueryWindowText( WinWindowFromID( hwndDialogStaff,
  1307.                        ID_DEPT),    
  1308.               sizeof(String),
  1309.               String);
  1310.       if (!GpfStringIsNumeric(String))
  1311.      {
  1312.       WinSetFocus( HWND_DESKTOP,
  1313.                WinWindowFromID(hwndDialogStaff,ID_DEPT));
  1314.       return FALSE;
  1315.      }
  1316.       STAFF_DEPT = atoi(String);       /* Convert String to Short */
  1317.       STAFF_DEPT_N = 0;            /* Reset Sql Null Indicator*/
  1318.  
  1319. /**********************************************************************/
  1320. /*   Move "ID_SALARY" To "STAFF_SALARY". (DECIMAL)              */
  1321. /**********************************************************************/
  1322.  
  1323.  
  1324.       WinQueryWindowText( WinWindowFromID( hwndDialogStaff,
  1325.                        ID_SALARY),    
  1326.               sizeof(String),
  1327.               String);
  1328.       Token = strrchr(String,sDecimal[0]); /* Search National Decimal */
  1329.       if (Token)               /* If Found              */
  1330.      *(Token) = '.';           /*     Change to US Decimal */
  1331.       sscanf(String,"%lf",&STAFF_SALARY);  /* Convert String to Float */
  1332.       STAFF_SALARY_N = 0;           /* Reset Sql Null Indicator*/
  1333.  
  1334. /**********************************************************************/
  1335. /*   Move "ID_COMM" To "STAFF_COMM".    (DECIMAL)              */
  1336. /**********************************************************************/
  1337.  
  1338.  
  1339.       WinQueryWindowText( WinWindowFromID( hwndDialogStaff,
  1340.                        ID_COMM),    
  1341.               sizeof(String),
  1342.               String);
  1343.       Token = strrchr(String,sDecimal[0]); /* Search National Decimal */
  1344.       if (Token)               /* If Found              */
  1345.      *(Token) = '.';           /*     Change to US Decimal */
  1346.       sscanf(String,"%lf",&STAFF_COMM);    /* Convert String to Float */
  1347.       STAFF_COMM_N = 0;            /* Reset Sql Null Indicator*/
  1348.  
  1349.  
  1350.       return (TRUE);
  1351.  }
  1352. /**********************************************************************/
  1353. /* End of Private Function: MoveDialogStaffToData              */
  1354. /**********************************************************************/
  1355. /**********************************************************************/
  1356.  
  1357.  
  1358.  
  1359. /**********************************************************************/
  1360. /**********************************************************************/
  1361. /*                                      */
  1362. /*   PRIVATE FUNCTION: MoveDataToDialogStaff                  */
  1363. /*                                      */
  1364. /*   Move Data To Window "DialogStaff".                   */
  1365. /*                                      */
  1366. /**********************************************************************/
  1367.  
  1368. BOOL  MoveDataToDialogStaff ( VOID )
  1369.  {
  1370.   UCHAR  String[32];
  1371.   PUCHAR Token;
  1372.  
  1373.   String[0] = 0;      /* Null, Delete Unreferenced Local variable */
  1374.   Token   = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  1375.  
  1376. /**********************************************************************/
  1377. /*   Move "STAFF_ID" To "ID_ID".    (SMALLINT)              */
  1378. /**********************************************************************/
  1379.  
  1380.       WinSendDlgItemMsg(hwndDialogStaff,
  1381.             ID_ID,    
  1382.             EM_SETTEXTLIMIT,
  1383.             MPFROMSHORT( 5 ),
  1384.             MPFROMSHORT( NULL ) );
  1385.       itoa(STAFF_ID,String,10);          /* Convert to string */
  1386.       WinSetWindowText( WinWindowFromID( hwndDialogStaff,
  1387.             ID_ID),
  1388.             String);
  1389.  
  1390. /**********************************************************************/
  1391. /*   Move "STAFF_NAME" To "ID_NAME".    (VARCHAR)              */
  1392. /**********************************************************************/
  1393.  
  1394.       WinSendDlgItemMsg(hwndDialogStaff,
  1395.             ID_NAME,
  1396.             EM_SETTEXTLIMIT,
  1397.             MPFROMSHORT( sizeof(STAFF_NAME) -1 ),
  1398.             MPFROMSHORT( NULL ) );
  1399.       if (STAFF_NAME_N < 0)             /* If Null Indicator */
  1400.       STAFF_NAME[0] = 0;             /* Set Null Data     */
  1401.       WinSetWindowText( WinWindowFromID( hwndDialogStaff,
  1402.             ID_NAME),
  1403.             STAFF_NAME);
  1404.  
  1405. /**********************************************************************/
  1406. /*   Move "STAFF_JOB" To "ID_JOB".    (CHAR)                  */
  1407. /**********************************************************************/
  1408.  
  1409.       WinSendDlgItemMsg(hwndDialogStaff,
  1410.             ID_JOB,
  1411.             EM_SETTEXTLIMIT,
  1412.             MPFROMSHORT( sizeof(STAFF_JOB) -1 ),
  1413.             MPFROMSHORT( NULL ) );
  1414.       if (STAFF_JOB_N < 0)             /* If Null Indicator */
  1415.       STAFF_JOB[0] = 0;             /* Set Null Data     */
  1416.       WinSetWindowText( WinWindowFromID( hwndDialogStaff,
  1417.             ID_JOB),
  1418.             STAFF_JOB);
  1419.  
  1420. /**********************************************************************/
  1421. /*   Move "STAFF_DEPT" To "ID_DEPT".    (SMALLINT)              */
  1422. /**********************************************************************/
  1423.  
  1424.       WinSendDlgItemMsg(hwndDialogStaff,
  1425.             ID_DEPT,
  1426.             EM_SETTEXTLIMIT,
  1427.             MPFROMSHORT( 5 ),
  1428.             MPFROMSHORT( NULL ) );
  1429.       if (STAFF_DEPT_N < 0)             /* If Null Indicator */
  1430.       String[0] = 0;             /* Set Null Data     */
  1431.       else
  1432.       itoa(STAFF_DEPT,String,10);         /* Convert to string */
  1433.       WinSetWindowText( WinWindowFromID( hwndDialogStaff,
  1434.             ID_DEPT),
  1435.             String);
  1436.  
  1437. /**********************************************************************/
  1438. /*   Move "STAFF_SALARY" To "ID_SALARY". (DECIMAL)              */
  1439. /**********************************************************************/
  1440.  
  1441.       WinSendDlgItemMsg(hwndDialogStaff,
  1442.             ID_SALARY,
  1443.             EM_SETTEXTLIMIT,
  1444.             MPFROMSHORT( 8 ),    
  1445.             MPFROMSHORT( NULL ) );
  1446.       if (STAFF_SALARY_N < 0)             /* If Null Indicator */
  1447.       String[0] = 0;             /* Set Null Data     */
  1448.       else
  1449.       sprintf(String,"%.2f",STAFF_SALARY); /* Convert to string */    
  1450.       Token = strrchr(String,'.');    /* Search US Decimal          */
  1451.       if (Token)            /* If Found              */
  1452.      *(Token) = sDecimal[0];    /* Change to National Decimal */
  1453.       WinSetWindowText( WinWindowFromID( hwndDialogStaff,
  1454.             ID_SALARY),
  1455.             String);
  1456.  
  1457. /**********************************************************************/
  1458. /*   Move "STAFF_COMM" To "ID_COMM".    (DECIMAL)              */
  1459. /**********************************************************************/
  1460.  
  1461.       WinSendDlgItemMsg(hwndDialogStaff,
  1462.             ID_COMM,
  1463.             EM_SETTEXTLIMIT,
  1464.             MPFROMSHORT( 8 ),    
  1465.             MPFROMSHORT( NULL ) );
  1466.       if (STAFF_COMM_N < 0)             /* If Null Indicator */
  1467.       String[0] = 0;             /* Set Null Data     */
  1468.       else
  1469.       sprintf(String,"%.2f",STAFF_COMM); /* Convert to string */    
  1470.       Token = strrchr(String,'.');    /* Search US Decimal          */
  1471.       if (Token)            /* If Found              */
  1472.      *(Token) = sDecimal[0];    /* Change to National Decimal */
  1473.       WinSetWindowText( WinWindowFromID( hwndDialogStaff,
  1474.             ID_COMM),
  1475.             String);
  1476.  
  1477.  
  1478.       return (TRUE);
  1479.  }
  1480. /**********************************************************************/
  1481. /* End of Private Function: MoveDataToDialogStaff              */
  1482. /**********************************************************************/
  1483. /**********************************************************************/
  1484.  
  1485.  
  1486.  
  1487. /**********************************************************************/
  1488. /**********************************************************************/
  1489. /*                                      */
  1490. /*   PRIVATE FUNCTION: WmInitWndDialogStaff                  */
  1491. /*                                      */
  1492. /*   Wm Init Window "DialogStaff".                      */
  1493. /*                                      */
  1494. /**********************************************************************/
  1495.  
  1496. static VOID WmInitWndDialogStaff ( PGPFPARMS pGpfParms )
  1497.  {
  1498.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  1499.     /**************************************************************/
  1500.     /* Center Window "DialogStaff".                   */
  1501.     /* Positions Window in the center of the screen           */
  1502.     /**************************************************************/
  1503.     GpfSetCentreWindow(hwndFrameDialogStaff);
  1504.     /**************************************************************/
  1505.     /* Move Data To Window "DialogStaff".                  */
  1506.     /**************************************************************/
  1507.     MoveDataToDialogStaff();
  1508.  }
  1509. /**********************************************************************/
  1510. /* End of Private Function: WmInitWndDialogStaff              */
  1511. /**********************************************************************/
  1512. /**********************************************************************/
  1513.  
  1514.  
  1515.  
  1516. /**********************************************************************/
  1517. /**********************************************************************/
  1518. /*                                      */
  1519. /*   PRIVATE FUNCTION: WmActiveDialogStaff                  */
  1520. /*                                      */
  1521. /*   Wm Activate Window "DialogStaff".                      */
  1522. /*                                      */
  1523. /**********************************************************************/
  1524.  
  1525. static VOID WmActiveDialogStaff ( PGPFPARMS pGpfParms )
  1526.  {
  1527.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  1528.  }
  1529. /**********************************************************************/
  1530. /* End of Private Function: WmActiveDialogStaff               */
  1531. /**********************************************************************/
  1532. /**********************************************************************/
  1533.  
  1534.  
  1535.  
  1536. /**********************************************************************/
  1537. /**********************************************************************/
  1538. /*                                      */
  1539. /*   PRIVATE FUNCTION: WmDeActiveDialogStaff                  */
  1540. /*                                      */
  1541. /*   DeActivate Window "DialogStaff".                      */
  1542. /*                                      */
  1543. /**********************************************************************/
  1544.  
  1545. static VOID WmDeActiveDialogStaff ( PGPFPARMS pGpfParms )
  1546.  {
  1547.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  1548.  }
  1549. /**********************************************************************/
  1550. /* End of Private Function: WmDeActiveDialogStaff              */
  1551. /**********************************************************************/
  1552. /**********************************************************************/
  1553.  
  1554.  
  1555.  
  1556. /**********************************************************************/
  1557. /**********************************************************************/
  1558. /*                                      */
  1559. /*   PRIVATE FUNCTION: WmCreateDialogStaff                  */
  1560. /*                                      */
  1561. /*   Wm Create Window "DialogStaff".                      */
  1562. /*                                      */
  1563. /**********************************************************************/
  1564.  
  1565. static VOID WmCreateDialogStaff ( PGPFPARMS pGpfParms )
  1566.  {
  1567.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  1568.  }
  1569. /**********************************************************************/
  1570. /* End of Private Function: WmCreateDialogStaff               */
  1571. /**********************************************************************/
  1572. /**********************************************************************/
  1573.  
  1574.  
  1575.  
  1576. /**********************************************************************/
  1577. /**********************************************************************/
  1578. /*                                      */
  1579. /*   PRIVATE FUNCTION: WmDestroyDialogStaff                  */
  1580. /*                                      */
  1581. /*   Wm Destroy Window "DialogStaff".                      */
  1582. /*                                      */
  1583. /**********************************************************************/
  1584.  
  1585. static VOID WmDestroyDialogStaff ( PGPFPARMS pGpfParms )
  1586.  {
  1587.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  1588.  }
  1589. /**********************************************************************/
  1590. /* End of Private Function: WmDestroyDialogStaff              */
  1591. /**********************************************************************/
  1592. /**********************************************************************/
  1593.  
  1594.  
  1595.  
  1596. /**********************************************************************/
  1597. /**********************************************************************/
  1598. /*                                      */
  1599. /*   PRIVATE FUNCTION: WmPaintDialogStaff                  */
  1600. /*                                      */
  1601. /*   Wm Paint Window "DialogStaff".                      */
  1602. /*                                      */
  1603. /**********************************************************************/
  1604.  
  1605. static VOID WmPaintDialogStaff ( PGPFPARMS pGpfParms )
  1606.  {
  1607.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  1608.  }
  1609. /**********************************************************************/
  1610. /* End of Private Function: WmPaintDialogStaff                  */
  1611. /**********************************************************************/
  1612. /**********************************************************************/
  1613.  
  1614.  
  1615.  
  1616. /**********************************************************************/
  1617. /**********************************************************************/
  1618. /*                                      */
  1619. /*   PRIVATE FUNCTION: WmShowDialogStaff                  */
  1620. /*                                      */
  1621. /*   Wm Show Window "DialogStaff".                      */
  1622. /*                                      */
  1623. /**********************************************************************/
  1624.  
  1625. static VOID WmShowDialogStaff ( PGPFPARMS pGpfParms )
  1626.  {
  1627.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  1628.  }
  1629. /**********************************************************************/
  1630. /* End of Private Function: WmShowDialogStaff                  */
  1631. /**********************************************************************/
  1632. /**********************************************************************/
  1633.  
  1634.  
  1635.  
  1636. /**********************************************************************/
  1637. /**********************************************************************/
  1638. /*                                      */
  1639. /*   PRIVATE FUNCTION: WmHideDialogStaff                  */
  1640. /*                                      */
  1641. /*   Wm Hide Window "DialogStaff".                      */
  1642. /*                                      */
  1643. /**********************************************************************/
  1644.  
  1645. static VOID WmHideDialogStaff ( PGPFPARMS pGpfParms )
  1646.  {
  1647.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  1648.  }
  1649. /**********************************************************************/
  1650. /* End of Private Function: WmHideDialogStaff                  */
  1651. /**********************************************************************/
  1652. /**********************************************************************/
  1653.  
  1654.  
  1655. /**********************************************************************/
  1656. /**********************************************************************/
  1657. /*                                      */
  1658. /*   PRIVATE FUNCTION: ShowListOrgWindow                  */
  1659. /*                                      */
  1660. /*   Show Window "ListOrgWindow".                      */
  1661. /*                                      */
  1662. /**********************************************************************/
  1663.  
  1664. BOOL  ShowListOrgWindow( PVOID pCrtParms )
  1665.  {
  1666.  SWP Swp;
  1667.  
  1668.               /* Make sure the window was not created. */
  1669.    if (!hwndFrameListOrgWindow)
  1670.     CreateListOrgWindow(pCrtParms);
  1671.    WinSetWindowPos( hwndFrameListOrgWindow,
  1672.             NULL,0,0,0,0,SWP_RESTORE);
  1673.    WinQueryWindowPos( hwndFrameListOrgWindow, &Swp );
  1674.    WinSetWindowPos( hwndFrameListOrgWindow,
  1675.             HWND_TOP,
  1676.             Swp.x,Swp.y,Swp.cx,Swp.cy,
  1677.             SWP_ZORDER | SWP_SIZE | SWP_MOVE |
  1678.             SWP_ACTIVATE | SWP_SHOW
  1679.           );
  1680.    return(FALSE);
  1681.  }
  1682.  
  1683. /**********************************************************************/
  1684. /**********************************************************************/
  1685. /*                                      */
  1686. /*   PRIVATE FUNCTION: DismissListOrgWindow                  */
  1687. /*                                      */
  1688. /*   Dismiss Window Hide - Window "ListOrgWindow".              */
  1689. /*                                      */
  1690. /**********************************************************************/
  1691.  
  1692. VOID  DismissListOrgWindow( BOOL Rcode )
  1693.  {
  1694.  
  1695.    Rcode = Rcode;  /* Null , For Delete Unreferenced Formal Parameter */
  1696.                                /* Hide Window */
  1697.    WinShowWindow(hwndFrameListOrgWindow, FALSE);
  1698.  
  1699.  }
  1700.  
  1701. /**********************************************************************/
  1702. /**********************************************************************/
  1703. /*                                      */
  1704. /*   PRIVATE FUNCTION: CreateListOrgWindow                  */
  1705. /*                                      */
  1706. /*   Create the window "ListOrgWindow" And Controls.              */
  1707. /*                                      */
  1708. /**********************************************************************/
  1709.  
  1710. VOID CreateListOrgWindow( PVOID pCrtParms)
  1711.  {
  1712.   /********************************************************************/
  1713.   /*   Register the window class "ListOrgWindow".              */
  1714.   /********************************************************************/
  1715.   WinRegisterClass(              /* Register window class    */
  1716.       habMainTask,              /* Anchor block handle      */
  1717.       "ListOrgWindow",          /* Window class name          */
  1718.       fnwpListOrgWindow,          /* Address window procedure */
  1719.       CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style          */
  1720.       CS_MOVENOTIFY |          /* Class style          */
  1721.       CS_SIZEREDRAW | CS_SYNCPAINT,   /* Class style          */
  1722.       EXTRAWORDS              /* Extra window words       */
  1723.       );
  1724.  
  1725.   /********************************************************************/
  1726.   /*   Create the window "ListOrgWindow".                  */
  1727.   /********************************************************************/
  1728.   hwndFrameListOrgWindow =                  /* Save Hwnd    */
  1729.   GpfCreateTemplate( ID_LISTORGWINDOW,              /* Ressource Id */
  1730.              hmodSample,              /* Ressource Md */
  1731.              hwndMainWindow,              /* Hwnd Parent  */
  1732.              hwndMainWindow,              /* Hwnd Owner   */
  1733.              pCrtParms);              /* User Parms   */
  1734.  }
  1735. /**********************************************************************/
  1736. /* End of Private Function - CreateListOrgWindow              */
  1737. /**********************************************************************/
  1738. /**********************************************************************/
  1739.  
  1740.  
  1741.  
  1742. /**********************************************************************/
  1743. /**********************************************************************/
  1744. /*                                      */
  1745. /*  WinProc: fnwpListOrgWindow                          */
  1746. /*                                      */
  1747. /*  Controls the "ListOrgWindow" Area.                      */
  1748. /*                                      */
  1749. /*                                      */
  1750. /**********************************************************************/
  1751.  
  1752. MRESULT  EXPENTRY fnwpListOrgWindow(
  1753.           HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  1754. {
  1755.   HPS        hps;          /* Presentation space handle         */
  1756.   RECTL     rcl;          /* Window rectangle             */
  1757.   PGPFPARMS pGpfParms;          /* Far Pointer             */
  1758.   SEL        Selector;          /* Seloctor                 */
  1759.  
  1760.   /*******************************************************************/
  1761.   /* Initialize Gpf Parameters                         */
  1762.   /*******************************************************************/
  1763.   pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
  1764.   if (pGpfParms)
  1765.      {
  1766.       pGpfParms->hwnd     = hwnd;      /* window handle             */
  1767.       pGpfParms->msg     = msg;       /* message number          */
  1768.       pGpfParms->mp1     = mp1;       /* 1st (packed) parms         */
  1769.       pGpfParms->mp2     = mp2;       /* 2nd (packed) parms         */
  1770.       pGpfParms->mresult = (MRESULT) FALSE; /* Mresult             */
  1771.       pGpfParms->Command = 0;          /* Command From mp1 (SHORT 1)  */
  1772.       pGpfParms->Notify  = 0;          /* Notify  From mp1 (SHORT 2)  */
  1773.      }
  1774.  
  1775.   switch(msg)
  1776.   {
  1777.     /**************************************************************/
  1778.     /* Things to do when the Window is first initalized          */
  1779.     /**************************************************************/
  1780.    case WM_INITDLG:
  1781.     /**************************************************************/
  1782.     /*  Initialize Window 'ListOrgWindow'                  */
  1783.     /**************************************************************/
  1784.     GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1785.     WmInitWndListOrgWindow(pGpfParms); /* Init Dialog          */
  1786.     /**************************************************************/
  1787.     /*  Return pGpfParms Mresult                      */
  1788.     /**************************************************************/
  1789.     return (pGpfParms->mresult);
  1790.  
  1791.     /**************************************************************/
  1792.     /* Things to do when the Window is Activated/Deactivated      */
  1793.     /**************************************************************/
  1794.    case WM_ACTIVATE:
  1795.     if (SHORT1FROMMP(mp1))
  1796.         WmActiveListOrgWindow(pGpfParms);     /* Activate Window   */
  1797.     else
  1798.         WmDeActiveListOrgWindow(pGpfParms);  /* DeActivate Window */
  1799.     return (pGpfParms->mresult);
  1800.  
  1801.     /**************************************************************/
  1802.     /* Things to do when the Window is "Show/Hide"              */
  1803.     /**************************************************************/
  1804.    case WM_SHOW:
  1805.     if (SHORT1FROMMP(mp1))
  1806.         WmShowListOrgWindow(pGpfParms);           /* Show Window */
  1807.     else
  1808.         WmHideListOrgWindow(pGpfParms);           /* Hide Window */
  1809.     return (pGpfParms->mresult);
  1810.  
  1811.     /**************************************************************/
  1812.     /* The application has asked for the window to be created.    */
  1813.     /**************************************************************/
  1814.    case WM_CREATE:
  1815.     DosAllocSeg(sizeof(GPFPARMS),&Selector,0);    /* Getmain    */
  1816.     pGpfParms = MAKEP(Selector, 0);         /* Set Pointer*/
  1817.     WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
  1818.     memset(pGpfParms,0,sizeof(GPFPARMS));        /* Clear Area */
  1819.     pGpfParms->Options |= GPF_OP_ADJUSTSIZE; /* Set AdjustSize    */
  1820.     hwndListOrgWindow = hwnd;             /* Save Hwnd */
  1821.     hwndFrameListOrgWindow = GpfGetHwndFrame(hwnd);
  1822.     pGpfParms->hwnd = hwnd;            /* window handle       */
  1823.     pGpfParms->msg    = msg;               /* message number      */
  1824.     pGpfParms->mp1    = mp1;               /* 1st (packed) parms  */
  1825.     pGpfParms->mp2    = mp2;               /* 2nd (packed) parms  */
  1826.     pGpfParms->hmod = hmodSample;    
  1827.     pGpfParms->hab    = habMainTask;           /* Anchor block handle */
  1828.     WmCreateListOrgWindow(pGpfParms);      /* Create  Window      */
  1829.     break;
  1830.  
  1831.     /**************************************************************/
  1832.     /* The application has asked for the window to be destroyed.  */
  1833.     /**************************************************************/
  1834.    case WM_DESTROY:
  1835.     WmDestroyListOrgWindow(pGpfParms);        /* Destroy Window */
  1836.     hwndFrameListOrgWindow = (HWND)NULL;        /* Reset HwndFrm  */
  1837.     hwndListOrgWindow = (HWND)NULL;         /* Reset Hwnd     */
  1838.     /* Destroy Template , Help Instance and GpfParms          */
  1839.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1840.  
  1841.     /**************************************************************/
  1842.     /* The window needs painting.                      */
  1843.     /**************************************************************/
  1844.    case WM_PAINT:
  1845.     /**************************************************************/
  1846.     /* Obtain a cache PS                          */
  1847.     /**************************************************************/
  1848.     hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
  1849.     WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect          */
  1850.     pGpfParms->hps = hps;            /* Pass Hps ( Paint ) */
  1851.     WmPaintListOrgWindow(pGpfParms);    /* Paint Window       */
  1852.     WinEndPaint( hps );            /* Release cache PS   */
  1853.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1854.  
  1855.     /**************************************************************/
  1856.     /* Process ScrollBar received from the user              */
  1857.     /**************************************************************/
  1858.     case WM_VSCROLL:
  1859.     case WM_HSCROLL:
  1860.     /* Set Command From mp1 */
  1861.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1862.     /* Set Notify From mp2    */
  1863.     pGpfParms->Notify = SHORT2FROMMP( mp2 );
  1864.     CommandListOrgWindow( pGpfParms );    /* Process the command  */
  1865.     return (pGpfParms->mresult);
  1866.  
  1867.     /**************************************************************/
  1868.     /* Process Controls received from the user              */
  1869.     /**************************************************************/
  1870.    case WM_CONTROL:
  1871.     /* Set Command From mp1 */
  1872.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1873.     /* Set Notify From mp1    */
  1874.     pGpfParms->Notify = SHORT2FROMMP( mp1 );
  1875.     CommandListOrgWindow( pGpfParms );    /* Process the command  */
  1876.     return (pGpfParms->mresult);
  1877.  
  1878.     /**************************************************************/
  1879.     /* Process commands received from the user              */
  1880.     /**************************************************************/
  1881.    case WM_SYSCOMMAND:
  1882.    case WM_HELP:
  1883.    case WM_COMMAND:
  1884.     /* Set Command From mp1 */
  1885.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  1886.     pGpfParms->Notify = COMMAND;          /* Set Notify From mp1  */
  1887.     CommandListOrgWindow( pGpfParms );    /* Process the command  */
  1888.     if (pGpfParms->mresult)
  1889.         return (pGpfParms->mresult);
  1890.     /* If DID_CANCEL Dismiss Window */
  1891.     if (pGpfParms->Command == DID_CANCEL)
  1892.         DismissListOrgWindow(FALSE);
  1893.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1894.  
  1895.     /**************************************************************/
  1896.     /* All other messages are passed to the default procedure.    */
  1897.     /**************************************************************/
  1898.    default:
  1899.     /* Pass all other messages to the default window procedure    */
  1900.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  1901.   }
  1902.   return ((MRESULT) FALSE);
  1903. }
  1904. /**********************************************************************/
  1905. /* End of window procedure - WinProc: fnwpListOrgWindow           */
  1906. /**********************************************************************/
  1907. /**********************************************************************/
  1908.  
  1909.  
  1910.  
  1911. /**********************************************************************/
  1912. /**********************************************************************/
  1913. /*                                      */
  1914. /*   PRIVATE FUNCTION: CommandListOrgWindow                  */
  1915. /*                                      */
  1916. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  1917. /*   received by the window procedure.                      */
  1918. /*   Window "ListOrgWindow".                          */
  1919. /*                                      */
  1920. /**********************************************************************/
  1921.  
  1922. static VOID CommandListOrgWindow ( PGPFPARMS pGpfParms )
  1923. {
  1924.   pGpfParms->mresult = (MRESULT) TRUE;        /* Set Return Code    */
  1925.   /* Switch according to Control chosen                   */
  1926.   switch( pGpfParms->Command )
  1927.   {
  1928.     /******************************************************************/
  1929.     /* Name  "ListBoxOrg".                          */
  1930.     /* Text  "Text".                              */
  1931.     /******************************************************************/
  1932.     case ID_LISTBOXORG:
  1933.      ActionListBoxOrg(pGpfParms);
  1934.      return;
  1935.     /******************************************************************/
  1936.     /* Name  "ShowOrg".                           */
  1937.     /* Alias "DID_OK".                              */
  1938.     /* Text  "~Show Org".                          */
  1939.     /******************************************************************/
  1940.     case ID_SHOWORG:
  1941.     case DID_OK:
  1942.      ActionShowOrg(pGpfParms);
  1943.      return;
  1944.     /******************************************************************/
  1945.     /* Name  "Cancel1".                           */
  1946.     /* Alias "DID_CANCEL".                          */
  1947.     /* Text  "Cancel".                              */
  1948.     /******************************************************************/
  1949.     case ID_CANCEL1:
  1950.     case DID_CANCEL:
  1951.      ActionCancel1(pGpfParms);
  1952.      return;
  1953.     /******************************************************************/
  1954.     /* Name  "ButtonHelp1".                          */
  1955.     /* Text  "~Help".                              */
  1956.     /******************************************************************/
  1957.     case ID_BUTTONHELP1:
  1958.      ActionButtonHelp1(pGpfParms);
  1959.      return;
  1960.   }
  1961.   /* Take no action for any other selections                  */
  1962.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  1963. }
  1964. /**********************************************************************/
  1965. /* End of Private Function: CommandListOrgWindow              */
  1966. /**********************************************************************/
  1967. /**********************************************************************/
  1968.  
  1969.  
  1970. /**********************************************************************/
  1971. /**********************************************************************/
  1972. /*                                      */
  1973. /*   STATIC PRIVATE FUNCTION: ActionShowOrg                  */
  1974. /*                                      */
  1975. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  1976. /*   received by the window procedure.                      */
  1977. /*   Window "ListOrgWindow".                          */
  1978. /*                                      */
  1979. /**********************************************************************/
  1980.  
  1981. static VOID ActionShowOrg( PGPFPARMS pGpfParms )
  1982. {
  1983.   /* Switch according to Control chosen                   */
  1984.   switch( pGpfParms->Notify )
  1985.   {
  1986.    case BN_CLICKED:
  1987.    case BN_DBLCLICKED:
  1988.    case COMMAND:
  1989.     /**************************************************************/
  1990.     /* Reset Default Button Window "ListOrgWindow".           */
  1991.     /**************************************************************/
  1992.     GpfResetDefaultButton(hwndListOrgWindow);
  1993.     /**************************************************************/
  1994.     /* Get Selection "ListBoxOrg".                      */
  1995.     /* Window "ListOrgWindow".                      */
  1996.     /**************************************************************/
  1997.     GetSelBoxListBoxOrg();    
  1998.     /**************************************************************/
  1999.     /* Show Window "DialogOrg".                      */
  2000.     /**************************************************************/
  2001.     ShowDialogOrg(NULL);
  2002.     return;
  2003.   }
  2004.   /* Take no action for any other selections                  */
  2005. }
  2006. /**********************************************************************/
  2007. /* End of Private Function                          */
  2008. /**********************************************************************/
  2009. /**********************************************************************/
  2010.  
  2011.  
  2012. /**********************************************************************/
  2013. /**********************************************************************/
  2014. /*                                      */
  2015. /*   STATIC PRIVATE FUNCTION: ActionCancel1                  */
  2016. /*                                      */
  2017. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2018. /*   received by the window procedure.                      */
  2019. /*   Window "ListOrgWindow".                          */
  2020. /*                                      */
  2021. /**********************************************************************/
  2022.  
  2023. static VOID ActionCancel1( PGPFPARMS pGpfParms )
  2024. {
  2025.   /* Switch according to Control chosen                   */
  2026.   switch( pGpfParms->Notify )
  2027.   {
  2028.    case BN_CLICKED:
  2029.    case BN_DBLCLICKED:
  2030.    case COMMAND:
  2031.     /**************************************************************/
  2032.     /* Dismiss Window Hide Window "ListOrgWindow".              */
  2033.     /**************************************************************/
  2034.     DismissListOrgWindow(FALSE);
  2035.     return;
  2036.   }
  2037.   /* Take no action for any other selections                  */
  2038. }
  2039. /**********************************************************************/
  2040. /* End of Private Function                          */
  2041. /**********************************************************************/
  2042. /**********************************************************************/
  2043.  
  2044.  
  2045. /**********************************************************************/
  2046. /**********************************************************************/
  2047. /*                                      */
  2048. /*   STATIC PRIVATE FUNCTION: ActionButtonHelp1               */
  2049. /*                                      */
  2050. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2051. /*   received by the window procedure.                      */
  2052. /*   Window "ListOrgWindow".                          */
  2053. /*                                      */
  2054. /**********************************************************************/
  2055.  
  2056. static VOID ActionButtonHelp1( PGPFPARMS pGpfParms )
  2057. {
  2058.   /* Switch according to Control chosen                   */
  2059.   switch( pGpfParms->Notify )
  2060.   {
  2061.    case BN_CLICKED:
  2062.    case BN_DBLCLICKED:
  2063.    case COMMAND:
  2064.     /**************************************************************/
  2065.     /* Help Extended for Window "ListOrgWindow".              */
  2066.     /**************************************************************/
  2067.     if (hwndHelp)
  2068.         WinSendMsg( hwndHelp, HM_DISPLAY_HELP,
  2069.             MPFROMSHORT( ID_LISTORGWINDOW ),
  2070.             0L );
  2071.     return;
  2072.   }
  2073.   /* Take no action for any other selections                  */
  2074. }
  2075. /**********************************************************************/
  2076. /* End of Private Function                          */
  2077. /**********************************************************************/
  2078. /**********************************************************************/
  2079.  
  2080.  
  2081. /**********************************************************************/
  2082. /**********************************************************************/
  2083. /*                                      */
  2084. /*   STATIC PRIVATE FUNCTION: ActionListBoxOrg                  */
  2085. /*                                      */
  2086. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2087. /*   received by the window procedure.                      */
  2088. /*   Window "ListOrgWindow".                          */
  2089. /*                                      */
  2090. /**********************************************************************/
  2091.  
  2092. static VOID ActionListBoxOrg( PGPFPARMS pGpfParms )
  2093. {
  2094.   /* Switch according to Control chosen                   */
  2095.   switch( pGpfParms->Notify )
  2096.   {
  2097.    case LN_ENTER:      /* Catch double click on */
  2098.     /**************************************************************/
  2099.     /* Reset Default Button Window "ListOrgWindow".           */
  2100.     /**************************************************************/
  2101.     GpfResetDefaultButton(hwndListOrgWindow);
  2102.     /**************************************************************/
  2103.     /* Simulate OK - Send Did OK to Window                  */
  2104.     /* "ListOrgWindow".                          */
  2105.     /*************************************************************/
  2106.     WinSendMsg( hwndListOrgWindow,
  2107.             WM_COMMAND,         /* simulate OK          */
  2108.             MPFROM2SHORT( DID_OK       , 0 ),
  2109.             MPFROM2SHORT( CMDSRC_OTHER , 0 )
  2110.           );
  2111.     return;
  2112.    case LN_SELECT:     /* Catch click on */
  2113.     return;
  2114.    case LN_KILLFOCUS:  /* Kill Focus */
  2115.     return;
  2116.    case LN_SETFOCUS:   /* Set Focus */
  2117.     return;
  2118.    case LN_SCROLL:     /* Scroll    */
  2119.     return;
  2120.   }
  2121.   /* Take no action for any other selections                  */
  2122. }
  2123. /**********************************************************************/
  2124. /* End of Private Function                          */
  2125. /**********************************************************************/
  2126. /**********************************************************************/
  2127.  
  2128.  
  2129. /**********************************************************************/
  2130. /**********************************************************************/
  2131. /*                                      */
  2132. /*   PRIVATE FUNCTION: MoveListOrgWindowToData                  */
  2133. /*                                      */
  2134. /*   Move "ListOrgWindow" To Assosiate Data.                  */
  2135. /*                                      */
  2136. /**********************************************************************/
  2137.  
  2138. BOOL  MoveListOrgWindowToData ( VOID )
  2139.  {
  2140.   UCHAR  String[32];
  2141.   PUCHAR Token;
  2142.  
  2143.   String[0] = 0;     /* Null, Delete Unreferenced Local variable */
  2144.   Token  = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  2145.  
  2146.  
  2147.       return (TRUE);
  2148.  }
  2149. /**********************************************************************/
  2150. /* End of Private Function: MoveListOrgWindowToData              */
  2151. /**********************************************************************/
  2152. /**********************************************************************/
  2153.  
  2154.  
  2155.  
  2156. /**********************************************************************/
  2157. /**********************************************************************/
  2158. /*                                      */
  2159. /*   PRIVATE FUNCTION: MoveDataToListOrgWindow                  */
  2160. /*                                      */
  2161. /*   Move Data To Window "ListOrgWindow".                  */
  2162. /*                                      */
  2163. /**********************************************************************/
  2164.  
  2165. BOOL  MoveDataToListOrgWindow ( VOID )
  2166.  {
  2167.   UCHAR  String[32];
  2168.   PUCHAR Token;
  2169.  
  2170.   String[0] = 0;      /* Null, Delete Unreferenced Local variable */
  2171.   Token   = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  2172.  
  2173.  
  2174.       return (TRUE);
  2175.  }
  2176. /**********************************************************************/
  2177. /* End of Private Function: MoveDataToListOrgWindow              */
  2178. /**********************************************************************/
  2179. /**********************************************************************/
  2180.  
  2181.  
  2182.  
  2183. /**********************************************************************/
  2184. /**********************************************************************/
  2185. /*                                      */
  2186. /*   PRIVATE FUNCTION: WmInitWndListOrgWindow                  */
  2187. /*                                      */
  2188. /*   Wm Init Window "ListOrgWindow".                      */
  2189. /*                                      */
  2190. /**********************************************************************/
  2191.  
  2192. static VOID WmInitWndListOrgWindow ( PGPFPARMS pGpfParms )
  2193.  {
  2194.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2195.     /**************************************************************/
  2196.     /* Load ListBox / ComboBox "ListBoxOrg".              */
  2197.     /* Window "ListOrgWindow".                      */
  2198.     /**************************************************************/
  2199.     /* Send Msg for Execute LoadBoxListBoxOrg();              */
  2200.     GpfExecuteSql(LoadBoxListBoxOrg,hwndListOrgWindow);
  2201.     /* Wait Async Execute LoadBoxListBoxOrg();              */
  2202.     GpfSqlWait(hwndListOrgWindow);    
  2203.  }
  2204. /**********************************************************************/
  2205. /* End of Private Function: WmInitWndListOrgWindow              */
  2206. /**********************************************************************/
  2207. /**********************************************************************/
  2208.  
  2209.  
  2210.  
  2211. /**********************************************************************/
  2212. /**********************************************************************/
  2213. /*                                      */
  2214. /*   PRIVATE FUNCTION: WmActiveListOrgWindow                  */
  2215. /*                                      */
  2216. /*   Wm Activate Window "ListOrgWindow".                  */
  2217. /*                                      */
  2218. /**********************************************************************/
  2219.  
  2220. static VOID WmActiveListOrgWindow ( PGPFPARMS pGpfParms )
  2221.  {
  2222.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  2223.  }
  2224. /**********************************************************************/
  2225. /* End of Private Function: WmActiveListOrgWindow              */
  2226. /**********************************************************************/
  2227. /**********************************************************************/
  2228.  
  2229.  
  2230.  
  2231. /**********************************************************************/
  2232. /**********************************************************************/
  2233. /*                                      */
  2234. /*   PRIVATE FUNCTION: WmDeActiveListOrgWindow                  */
  2235. /*                                      */
  2236. /*   DeActivate Window "ListOrgWindow".                   */
  2237. /*                                      */
  2238. /**********************************************************************/
  2239.  
  2240. static VOID WmDeActiveListOrgWindow ( PGPFPARMS pGpfParms )
  2241.  {
  2242.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  2243.  }
  2244. /**********************************************************************/
  2245. /* End of Private Function: WmDeActiveListOrgWindow              */
  2246. /**********************************************************************/
  2247. /**********************************************************************/
  2248.  
  2249.  
  2250.  
  2251. /**********************************************************************/
  2252. /**********************************************************************/
  2253. /*                                      */
  2254. /*   PRIVATE FUNCTION: WmCreateListOrgWindow                  */
  2255. /*                                      */
  2256. /*   Wm Create Window "ListOrgWindow".                      */
  2257. /*                                      */
  2258. /**********************************************************************/
  2259.  
  2260. static VOID WmCreateListOrgWindow ( PGPFPARMS pGpfParms )
  2261.  {
  2262.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2263.  }
  2264. /**********************************************************************/
  2265. /* End of Private Function: WmCreateListOrgWindow              */
  2266. /**********************************************************************/
  2267. /**********************************************************************/
  2268.  
  2269.  
  2270.  
  2271. /**********************************************************************/
  2272. /**********************************************************************/
  2273. /*                                      */
  2274. /*   PRIVATE FUNCTION: WmDestroyListOrgWindow                  */
  2275. /*                                      */
  2276. /*   Wm Destroy Window "ListOrgWindow".                   */
  2277. /*                                      */
  2278. /**********************************************************************/
  2279.  
  2280. static VOID WmDestroyListOrgWindow ( PGPFPARMS pGpfParms )
  2281.  {
  2282.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2283.  }
  2284. /**********************************************************************/
  2285. /* End of Private Function: WmDestroyListOrgWindow              */
  2286. /**********************************************************************/
  2287. /**********************************************************************/
  2288.  
  2289.  
  2290.  
  2291. /**********************************************************************/
  2292. /**********************************************************************/
  2293. /*                                      */
  2294. /*   PRIVATE FUNCTION: WmPaintListOrgWindow                  */
  2295. /*                                      */
  2296. /*   Wm Paint Window "ListOrgWindow".                      */
  2297. /*                                      */
  2298. /**********************************************************************/
  2299.  
  2300. static VOID WmPaintListOrgWindow ( PGPFPARMS pGpfParms )
  2301.  {
  2302.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2303.  }
  2304. /**********************************************************************/
  2305. /* End of Private Function: WmPaintListOrgWindow              */
  2306. /**********************************************************************/
  2307. /**********************************************************************/
  2308.  
  2309.  
  2310.  
  2311. /**********************************************************************/
  2312. /**********************************************************************/
  2313. /*                                      */
  2314. /*   PRIVATE FUNCTION: WmShowListOrgWindow                  */
  2315. /*                                      */
  2316. /*   Wm Show Window "ListOrgWindow".                      */
  2317. /*                                      */
  2318. /**********************************************************************/
  2319.  
  2320. static VOID WmShowListOrgWindow ( PGPFPARMS pGpfParms )
  2321.  {
  2322.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  2323.  }
  2324. /**********************************************************************/
  2325. /* End of Private Function: WmShowListOrgWindow               */
  2326. /**********************************************************************/
  2327. /**********************************************************************/
  2328.  
  2329.  
  2330.  
  2331. /**********************************************************************/
  2332. /**********************************************************************/
  2333. /*                                      */
  2334. /*   PRIVATE FUNCTION: WmHideListOrgWindow                  */
  2335. /*                                      */
  2336. /*   Wm Hide Window "ListOrgWindow".                      */
  2337. /*                                      */
  2338. /**********************************************************************/
  2339.  
  2340. static VOID WmHideListOrgWindow ( PGPFPARMS pGpfParms )
  2341.  {
  2342.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  2343.  }
  2344. /**********************************************************************/
  2345. /* End of Private Function: WmHideListOrgWindow               */
  2346. /**********************************************************************/
  2347. /**********************************************************************/
  2348.  
  2349.  
  2350. /**********************************************************************/
  2351. /**********************************************************************/
  2352. /*                                      */
  2353. /*   PRIVATE FUNCTION: LoadBoxListBoxOrg                  */
  2354. /*                                      */
  2355. /*   Load Box To ID_LISTBOXORG                          */
  2356. /*                                      */
  2357. /**********************************************************************/
  2358. LONG LoadBoxListBoxOrg( VOID )
  2359.  {
  2360.   UCHAR String[256];
  2361.   PUCHAR Token = NULL;
  2362.   SHORT i;
  2363.  
  2364.                             
  2365.       /***************************************************/
  2366.       /* clear out both list boxes in preperation for a  */
  2367.       /* refresh given the new environment         */
  2368.       /***************************************************/
  2369.                             
  2370.       WinSendDlgItemMsg(hwndListOrgWindow,
  2371.             ID_LISTBOXORG,
  2372.             LM_DELETEALL,            
  2373.             MPFROMSHORT( NULL ),        
  2374.             MPFROMSHORT( NULL ) );        
  2375.                             
  2376.       /********************************/
  2377.       /* Declare Sql Cursor          */
  2378.       /********************************/
  2379.       EXEC SQL DECLARE CURSOR_10119 CURSOR FOR SELECT
  2380.                   DEPTNAME,
  2381.                   DEPTNUMB,
  2382.                   DIVISION,
  2383.                   LOCATION,
  2384.                   MANAGER
  2385.                FROM ORG ;
  2386.  
  2387.       /********************************/
  2388.       /* Open  Sql Cursor          */
  2389.       /********************************/
  2390.  
  2391.       /* Position cursor at first record */
  2392.  
  2393.       EXEC SQL OPEN CURSOR_10119;
  2394.       GpfDisplaySqlError(&sqlca);
  2395.  
  2396.       while (!sqlca.sqlcode)
  2397.     {
  2398.       ORG_DEPTNAME[0] = 0;
  2399.       ORG_DEPTNUMB = 0;
  2400.       ORG_DIVISION[0] = 0;
  2401.       ORG_LOCATION[0] = 0;
  2402.       ORG_MANAGER = 0;
  2403.  
  2404.       /******************************************************/
  2405.       /* Fetch next row inorder to properly position cursor */
  2406.       /******************************************************/
  2407.  
  2408.       EXEC SQL FETCH CURSOR_10119 INTO
  2409.              :ORG_DEPTNAME :ORG_DEPTNAME_N,
  2410.              :ORG_DEPTNUMB,
  2411.              :ORG_DIVISION :ORG_DIVISION_N,
  2412.              :ORG_LOCATION :ORG_LOCATION_N,
  2413.              :ORG_MANAGER :ORG_MANAGER_N;
  2414.       GpfDisplaySqlError(&sqlca);
  2415.  
  2416.       if (!sqlca.sqlcode)
  2417.          {
  2418.           /********************************/
  2419.           /* Add Item to ListBox/ComboBox */
  2420.           /********************************/
  2421.           i = 0;
  2422.           i += sprintf(&String[i],"%-14s\xFF",ORG_DEPTNAME);
  2423.           i += sprintf(&String[i]," %6d\xFF",ORG_DEPTNUMB);
  2424.           i += sprintf(&String[i],"%-10s\xFF",ORG_DIVISION);
  2425.           i += sprintf(&String[i],"%-13s\xFF",ORG_LOCATION);
  2426.           i += sprintf(&String[i]," %6d\xFF",ORG_MANAGER);
  2427.           WinSendDlgItemMsg ( hwndListOrgWindow,
  2428.                   ID_LISTBOXORG,
  2429.                   LM_INSERTITEM,
  2430.                   MPFROM2SHORT(LIT_END,0),
  2431.                   MPFROMP( String ));
  2432.          }
  2433.     }
  2434.       /********************************/
  2435.       /* Close Sql Cursor          */
  2436.       /********************************/
  2437.       EXEC SQL CLOSE CURSOR_10119;
  2438.       GpfDisplaySqlError(&sqlca);
  2439.  
  2440.       /********************************/
  2441.       /* Commit and Drop Lock          */
  2442.       /********************************/
  2443.       EXEC SQL COMMIT WORK;        /* Drop Table any table locks */
  2444.       GpfDisplaySqlError(&sqlca);
  2445.  
  2446.       /***************************************************/
  2447.       /* Make the first list item initially-selected.     */
  2448.       /***************************************************/
  2449.                             
  2450.       WinSendDlgItemMsg(hwndListOrgWindow,
  2451.             ID_LISTBOXORG,
  2452.             LM_SELECTITEM,            
  2453.             MPFROMSHORT(0), /* First item index value */
  2454.             MPFROMSHORT( TRUE ) );        
  2455.  
  2456.       return (LONG)NULL;
  2457.  }
  2458. /**********************************************************************/
  2459. /* End of Private Function - LoadBoxListBoxOrg                  */
  2460. /**********************************************************************/
  2461. /**********************************************************************/
  2462.  
  2463.  
  2464.  
  2465. /**********************************************************************/
  2466. /**********************************************************************/
  2467. /*                                      */
  2468. /*   PRIVATE FUNCTION: GetSelBoxListBoxOrg                  */
  2469. /*                                      */
  2470. /*   GetSelection Box To ID_LISTBOXORG                      */
  2471. /*                                      */
  2472. /**********************************************************************/
  2473. BOOL GetSelBoxListBoxOrg( VOID )
  2474.  {
  2475.   UCHAR String[256];
  2476.   SHORT Position;
  2477.   PUCHAR Token = (PUCHAR)NULL;
  2478.   PUCHAR Token1 = (PUCHAR)NULL;
  2479.   PUCHAR EndToken = (PUCHAR)NULL;
  2480.   MRESULT mresult;
  2481.  
  2482.  
  2483. /*********************************************************************/
  2484. /*  Get the first selection item.                     */
  2485. /*********************************************************************/
  2486.       mresult = WinSendDlgItemMsg(
  2487.             hwndListOrgWindow,
  2488.             ID_LISTBOXORG,
  2489.             LM_QUERYSELECTION,
  2490.             MPFROM2SHORT( LIT_END, 0 ),    
  2491.             MPFROMSHORT( NULL ) );        
  2492.       Position = SHORT1FROMMR(mresult);
  2493.  
  2494. /*********************************************************************/
  2495. /*  When nothing was selected by the user.                 */
  2496. /*********************************************************************/
  2497.       if ((Position == LIT_NONE) || (Position == LIT_ERROR))    
  2498.     return FALSE;                        
  2499.  
  2500. /*********************************************************************/
  2501. /*  When something was selected by the user.                 */
  2502. /*********************************************************************/
  2503.       WinSendDlgItemMsg(hwndListOrgWindow,
  2504.             ID_LISTBOXORG,
  2505.             LM_QUERYITEMTEXT,
  2506.             MPFROM2SHORT(Position,sizeof(String)-1),
  2507.             MPFROMP( String ) );        
  2508.  
  2509.       Token = String;
  2510.  
  2511. /**********************************************************************/
  2512. /*  Move selected Item by the user.                      */
  2513. /**********************************************************************/
  2514.       EndToken = strchr(Token,'\xFF');
  2515.       if(!EndToken)
  2516.     return FALSE;
  2517.       *EndToken = 0;                /* Set Null Separator */
  2518.       strcpy(ORG_DEPTNAME,Token);
  2519.       if (!strlen(Token))
  2520.       ORG_DEPTNAME_N = -1;
  2521.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  2522.  
  2523. /**********************************************************************/
  2524. /*  Move selected Item by the user.                      */
  2525. /**********************************************************************/
  2526.       EndToken = strchr(Token,'\xFF');
  2527.       if(!EndToken)
  2528.     return FALSE;
  2529.       *EndToken = 0;                /* Set Null Separator */
  2530.       ORG_DEPTNUMB = atoi(Token);
  2531.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  2532.  
  2533. /**********************************************************************/
  2534. /*  Move selected Item by the user.                      */
  2535. /**********************************************************************/
  2536.       EndToken = strchr(Token,'\xFF');
  2537.       if(!EndToken)
  2538.     return FALSE;
  2539.       *EndToken = 0;                /* Set Null Separator */
  2540.       strcpy(ORG_DIVISION,Token);
  2541.       if (!strlen(Token))
  2542.       ORG_DIVISION_N = -1;
  2543.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  2544.  
  2545. /**********************************************************************/
  2546. /*  Move selected Item by the user.                      */
  2547. /**********************************************************************/
  2548.       EndToken = strchr(Token,'\xFF');
  2549.       if(!EndToken)
  2550.     return FALSE;
  2551.       *EndToken = 0;                /* Set Null Separator */
  2552.       strcpy(ORG_LOCATION,Token);
  2553.       if (!strlen(Token))
  2554.       ORG_LOCATION_N = -1;
  2555.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  2556.  
  2557. /**********************************************************************/
  2558. /*  Move selected Item by the user.                      */
  2559. /**********************************************************************/
  2560.       EndToken = strchr(Token,'\xFF');
  2561.       if(!EndToken)
  2562.     return FALSE;
  2563.       *EndToken = 0;                /* Set Null Separator */
  2564.       ORG_MANAGER = atoi(Token);
  2565.       if (!strlen(Token))
  2566.       ORG_MANAGER_N = -1;
  2567.       Token = (EndToken+1);         /* Token = EndToken + Separator  */
  2568.  
  2569.       return TRUE;
  2570.  }
  2571. /**********************************************************************/
  2572. /* End of Private Function - GetSelBoxListBoxOrg              */
  2573. /**********************************************************************/
  2574. /**********************************************************************/
  2575.  
  2576.  
  2577.  
  2578. /**********************************************************************/
  2579. /**********************************************************************/
  2580. /*                                      */
  2581. /*   PRIVATE FUNCTION: ShowDialogOrg                      */
  2582. /*                                      */
  2583. /*   Show Window "DialogOrg".                          */
  2584. /*                                      */
  2585. /**********************************************************************/
  2586.  
  2587. BOOL  ShowDialogOrg( PVOID pCrtParms )
  2588.  {
  2589.  SWP Swp;
  2590.  HWND hwndPrevious;
  2591.  HWND hwndFramePrevious;
  2592.  BOOL Rc;
  2593.  
  2594.                         /* Save Old Hwnd (Recur). */
  2595.    hwndFramePrevious = hwndFrameDialogOrg;
  2596.    hwndPrevious      = hwndDialogOrg;
  2597.    CreateDialogOrg(pCrtParms);            /* Create New Window      */
  2598.    WinSetWindowPos( hwndFrameDialogOrg,
  2599.             NULL,0,0,0,0,SWP_RESTORE);
  2600.    WinQueryWindowPos( hwndFrameDialogOrg, &Swp );
  2601.    WinSetWindowPos( hwndFrameDialogOrg,
  2602.             HWND_TOP,
  2603.             Swp.x,Swp.y,Swp.cx,Swp.cy,
  2604.             SWP_ZORDER | SWP_SIZE | SWP_MOVE |
  2605.             SWP_ACTIVATE | SWP_SHOW
  2606.           );
  2607.    Rc = GpfProcessWnd( hwndFrameDialogOrg );
  2608.                           /* Destroy Window   */
  2609.    WinDestroyWindow( hwndFrameDialogOrg );
  2610.                           /* Restore Old Hwnd */
  2611.    hwndFrameDialogOrg = hwndFramePrevious;
  2612.    hwndDialogOrg = hwndPrevious;
  2613.    return(Rc);
  2614.  }
  2615.  
  2616. /**********************************************************************/
  2617. /**********************************************************************/
  2618. /*                                      */
  2619. /*   PRIVATE FUNCTION: DismissDialogOrg                   */
  2620. /*                                      */
  2621. /*   Dismiss Window Hide - Window "DialogOrg".                  */
  2622. /*                                      */
  2623. /**********************************************************************/
  2624.  
  2625. VOID  DismissDialogOrg( BOOL Rcode )
  2626.  {
  2627.                             /* Dismiss Window */
  2628.    GpfDismissWnd(hwndFrameDialogOrg,Rcode);
  2629.  
  2630.  }
  2631.  
  2632. /**********************************************************************/
  2633. /**********************************************************************/
  2634. /*                                      */
  2635. /*   PRIVATE FUNCTION: CreateDialogOrg                      */
  2636. /*                                      */
  2637. /*   Create the window "DialogOrg" And Controls.              */
  2638. /*                                      */
  2639. /**********************************************************************/
  2640.  
  2641. VOID CreateDialogOrg( PVOID pCrtParms)
  2642.  {
  2643.   /********************************************************************/
  2644.   /*   Register the window class "DialogOrg".                  */
  2645.   /********************************************************************/
  2646.   WinRegisterClass(              /* Register window class    */
  2647.       habMainTask,              /* Anchor block handle      */
  2648.       "DialogOrg",              /* Window class name          */
  2649.       fnwpDialogOrg,          /* Address window procedure */
  2650.       CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style          */
  2651.       CS_MOVENOTIFY |          /* Class style          */
  2652.       CS_SIZEREDRAW | CS_SYNCPAINT,   /* Class style          */
  2653.       EXTRAWORDS              /* Extra window words       */
  2654.       );
  2655.  
  2656.   /********************************************************************/
  2657.   /*   Create the window "DialogOrg".                      */
  2658.   /********************************************************************/
  2659.   hwndFrameDialogOrg =                      /* Save Hwnd    */
  2660.   GpfCreateTemplate( ID_DIALOGORG,              /* Ressource Id */
  2661.              hmodSample,              /* Ressource Md */
  2662.              HWND_DESKTOP,              /* Hwnd Parent  */
  2663.              HWND_DESKTOP,              /* Hwnd Owner   */
  2664.              pCrtParms);              /* User Parms   */
  2665.  }
  2666. /**********************************************************************/
  2667. /* End of Private Function - CreateDialogOrg                  */
  2668. /**********************************************************************/
  2669. /**********************************************************************/
  2670.  
  2671.  
  2672.  
  2673. /**********************************************************************/
  2674. /**********************************************************************/
  2675. /*                                      */
  2676. /*  WinProc: fnwpDialogOrg                          */
  2677. /*                                      */
  2678. /*  Controls the "DialogOrg" Area.                      */
  2679. /*                                      */
  2680. /*                                      */
  2681. /**********************************************************************/
  2682.  
  2683. MRESULT  EXPENTRY fnwpDialogOrg(
  2684.           HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  2685. {
  2686.   HPS        hps;          /* Presentation space handle         */
  2687.   RECTL     rcl;          /* Window rectangle             */
  2688.   PGPFPARMS pGpfParms;          /* Far Pointer             */
  2689.   SEL        Selector;          /* Seloctor                 */
  2690.  
  2691.   /*******************************************************************/
  2692.   /* Initialize Gpf Parameters                         */
  2693.   /*******************************************************************/
  2694.   pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
  2695.   if (pGpfParms)
  2696.      {
  2697.       pGpfParms->hwnd     = hwnd;      /* window handle             */
  2698.       pGpfParms->msg     = msg;       /* message number          */
  2699.       pGpfParms->mp1     = mp1;       /* 1st (packed) parms         */
  2700.       pGpfParms->mp2     = mp2;       /* 2nd (packed) parms         */
  2701.       pGpfParms->mresult = (MRESULT) FALSE; /* Mresult             */
  2702.       pGpfParms->Command = 0;          /* Command From mp1 (SHORT 1)  */
  2703.       pGpfParms->Notify  = 0;          /* Notify  From mp1 (SHORT 2)  */
  2704.      }
  2705.  
  2706.   switch(msg)
  2707.   {
  2708.     /**************************************************************/
  2709.     /* Things to do when the Window is first initalized          */
  2710.     /**************************************************************/
  2711.    case WM_INITDLG:
  2712.     /**************************************************************/
  2713.     /*  Initialize Window 'DialogOrg'                  */
  2714.     /**************************************************************/
  2715.     GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  2716.     WmInitWndDialogOrg(pGpfParms);    /* Init Dialog              */
  2717.     /**************************************************************/
  2718.     /*  Return pGpfParms Mresult                      */
  2719.     /**************************************************************/
  2720.     return (pGpfParms->mresult);
  2721.  
  2722.     /**************************************************************/
  2723.     /* Things to do when the Window is Activated/Deactivated      */
  2724.     /**************************************************************/
  2725.    case WM_ACTIVATE:
  2726.     if (SHORT1FROMMP(mp1))
  2727.         WmActiveDialogOrg(pGpfParms);     /* Activate Window   */
  2728.     else
  2729.         WmDeActiveDialogOrg(pGpfParms);     /* DeActivate Window */
  2730.     return (pGpfParms->mresult);
  2731.  
  2732.     /**************************************************************/
  2733.     /* Things to do when the Window is "Show/Hide"              */
  2734.     /**************************************************************/
  2735.    case WM_SHOW:
  2736.     if (SHORT1FROMMP(mp1))
  2737.         WmShowDialogOrg(pGpfParms);            /* Show Window */
  2738.     else
  2739.         WmHideDialogOrg(pGpfParms);            /* Hide Window */
  2740.     return (pGpfParms->mresult);
  2741.  
  2742.     /**************************************************************/
  2743.     /* The application has asked for the window to be created.    */
  2744.     /**************************************************************/
  2745.    case WM_CREATE:
  2746.     DosAllocSeg(sizeof(GPFPARMS),&Selector,0);    /* Getmain    */
  2747.     pGpfParms = MAKEP(Selector, 0);         /* Set Pointer*/
  2748.     WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
  2749.     memset(pGpfParms,0,sizeof(GPFPARMS));        /* Clear Area */
  2750.     pGpfParms->Options |= GPF_OP_ADJUSTSIZE; /* Set AdjustSize    */
  2751.     hwndDialogOrg = hwnd;                 /* Save Hwnd */
  2752.     hwndFrameDialogOrg = GpfGetHwndFrame(hwnd);
  2753.     pGpfParms->hwnd = hwnd;            /* window handle       */
  2754.     pGpfParms->msg    = msg;               /* message number      */
  2755.     pGpfParms->mp1    = mp1;               /* 1st (packed) parms  */
  2756.     pGpfParms->mp2    = mp2;               /* 2nd (packed) parms  */
  2757.     pGpfParms->hmod = hmodSample;    
  2758.     pGpfParms->hab    = habMainTask;           /* Anchor block handle */
  2759.     WmCreateDialogOrg(pGpfParms);           /* Create  Window      */
  2760.     break;
  2761.  
  2762.     /**************************************************************/
  2763.     /* The application has asked for the window to be destroyed.  */
  2764.     /**************************************************************/
  2765.    case WM_DESTROY:
  2766.     WmDestroyDialogOrg(pGpfParms);            /* Destroy Window */
  2767.     hwndFrameDialogOrg = (HWND)NULL;        /* Reset HwndFrm  */
  2768.     hwndDialogOrg = (HWND)NULL;            /* Reset Hwnd     */
  2769.     /* Destroy Template , Help Instance and GpfParms          */
  2770.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  2771.  
  2772.     /**************************************************************/
  2773.     /* The window needs painting.                      */
  2774.     /**************************************************************/
  2775.    case WM_PAINT:
  2776.     /**************************************************************/
  2777.     /* Obtain a cache PS                          */
  2778.     /**************************************************************/
  2779.     hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
  2780.     WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect          */
  2781.     pGpfParms->hps = hps;            /* Pass Hps ( Paint ) */
  2782.     WmPaintDialogOrg(pGpfParms);        /* Paint Window       */
  2783.     WinEndPaint( hps );            /* Release cache PS   */
  2784.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  2785.  
  2786.     /**************************************************************/
  2787.     /* Process ScrollBar received from the user              */
  2788.     /**************************************************************/
  2789.     case WM_VSCROLL:
  2790.     case WM_HSCROLL:
  2791.     /* Set Command From mp1 */
  2792.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  2793.     /* Set Notify From mp2    */
  2794.     pGpfParms->Notify = SHORT2FROMMP( mp2 );
  2795.     CommandDialogOrg( pGpfParms );          /* Process the command  */
  2796.     return (pGpfParms->mresult);
  2797.  
  2798.     /**************************************************************/
  2799.     /* Process Controls received from the user              */
  2800.     /**************************************************************/
  2801.    case WM_CONTROL:
  2802.     /* Set Command From mp1 */
  2803.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  2804.     /* Set Notify From mp1    */
  2805.     pGpfParms->Notify = SHORT2FROMMP( mp1 );
  2806.     CommandDialogOrg( pGpfParms );          /* Process the command  */
  2807.     return (pGpfParms->mresult);
  2808.  
  2809.     /**************************************************************/
  2810.     /* Process commands received from the user              */
  2811.     /**************************************************************/
  2812.    case WM_SYSCOMMAND:
  2813.    case WM_HELP:
  2814.    case WM_COMMAND:
  2815.     /* Set Command From mp1 */
  2816.     pGpfParms->Command = SHORT1FROMMP( mp1 );
  2817.     pGpfParms->Notify = COMMAND;          /* Set Notify From mp1  */
  2818.     CommandDialogOrg( pGpfParms );          /* Process the command  */
  2819.     if (pGpfParms->mresult)
  2820.         return (pGpfParms->mresult);
  2821.     /* If DID_CANCEL Dismiss Window */
  2822.     if (pGpfParms->Command == DID_CANCEL)
  2823.         DismissDialogOrg(FALSE);
  2824.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  2825.  
  2826.     /**************************************************************/
  2827.     /* All other messages are passed to the default procedure.    */
  2828.     /**************************************************************/
  2829.    default:
  2830.     /* Pass all other messages to the default window procedure    */
  2831.     return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
  2832.   }
  2833.   return ((MRESULT) FALSE);
  2834. }
  2835. /**********************************************************************/
  2836. /* End of window procedure - WinProc: fnwpDialogOrg              */
  2837. /**********************************************************************/
  2838. /**********************************************************************/
  2839.  
  2840.  
  2841.  
  2842. /**********************************************************************/
  2843. /**********************************************************************/
  2844. /*                                      */
  2845. /*   PRIVATE FUNCTION: CommandDialogOrg                   */
  2846. /*                                      */
  2847. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2848. /*   received by the window procedure.                      */
  2849. /*   Window "DialogOrg".                          */
  2850. /*                                      */
  2851. /**********************************************************************/
  2852.  
  2853. static VOID CommandDialogOrg ( PGPFPARMS pGpfParms )
  2854. {
  2855.   pGpfParms->mresult = (MRESULT) TRUE;        /* Set Return Code    */
  2856.   /* Switch according to Control chosen                   */
  2857.   switch( pGpfParms->Command )
  2858.   {
  2859.     /******************************************************************/
  2860.     /* Name  "OK2".                              */
  2861.     /* Alias "DID_CANCEL".                          */
  2862.     /* Text  "~Ok".                              */
  2863.     /******************************************************************/
  2864.     case ID_OK2:
  2865.     case DID_CANCEL:
  2866.      ActionOK2(pGpfParms);    
  2867.      return;
  2868.   }
  2869.   /* Take no action for any other selections                  */
  2870.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  2871. }
  2872. /**********************************************************************/
  2873. /* End of Private Function: CommandDialogOrg                  */
  2874. /**********************************************************************/
  2875. /**********************************************************************/
  2876.  
  2877.  
  2878. /**********************************************************************/
  2879. /**********************************************************************/
  2880. /*                                      */
  2881. /*   STATIC PRIVATE FUNCTION: ActionOK2                   */
  2882. /*                                      */
  2883. /*   Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
  2884. /*   received by the window procedure.                      */
  2885. /*   Window "DialogOrg".                          */
  2886. /*                                      */
  2887. /**********************************************************************/
  2888.  
  2889. static VOID ActionOK2( PGPFPARMS pGpfParms )    
  2890. {
  2891.   /* Switch according to Control chosen                   */
  2892.   switch( pGpfParms->Notify )
  2893.   {
  2894.    case BN_CLICKED:
  2895.    case BN_DBLCLICKED:
  2896.    case COMMAND:
  2897.     /**************************************************************/
  2898.     /* Dismiss Window Hide Window "DialogOrg".              */
  2899.     /**************************************************************/
  2900.     DismissDialogOrg(FALSE);
  2901.     return;
  2902.   }
  2903.   /* Take no action for any other selections                  */
  2904. }
  2905. /**********************************************************************/
  2906. /* End of Private Function                          */
  2907. /**********************************************************************/
  2908. /**********************************************************************/
  2909.  
  2910.  
  2911. /**********************************************************************/
  2912. /**********************************************************************/
  2913. /*                                      */
  2914. /*   PRIVATE FUNCTION: MoveDialogOrgToData                  */
  2915. /*                                      */
  2916. /*   Move "DialogOrg" To Assosiate Data.                  */
  2917. /*                                      */
  2918. /**********************************************************************/
  2919.  
  2920. BOOL  MoveDialogOrgToData ( VOID )
  2921.  {
  2922.   UCHAR  String[32];
  2923.   PUCHAR Token;
  2924.  
  2925.   String[0] = 0;     /* Null, Delete Unreferenced Local variable */
  2926.   Token  = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  2927.  
  2928. /**********************************************************************/
  2929. /*   Move "ID_DEPTNAME" To "ORG_DEPTNAME". (VARCHAR)              */
  2930. /**********************************************************************/
  2931.  
  2932.  
  2933.       WinQueryWindowText( WinWindowFromID( hwndDialogOrg,
  2934.                        ID_DEPTNAME),
  2935.               sizeof(ORG_DEPTNAME),
  2936.               ORG_DEPTNAME);
  2937.       if (!ORG_DEPTNAME[0])            /* If Null Data          */
  2938.       ORG_DEPTNAME_N = -1;            /* Set Sql Null Indicator */
  2939.  
  2940. /**********************************************************************/
  2941. /*   Move "ID_DEPTNUMB" To "ORG_DEPTNUMB". (SMALLINT)              */
  2942. /**********************************************************************/
  2943.  
  2944.  
  2945.       WinQueryWindowText( WinWindowFromID( hwndDialogOrg,
  2946.                        ID_DEPTNUMB),
  2947.               sizeof(String),
  2948.               String);
  2949.       if (!GpfStringIsNumeric(String))
  2950.      {
  2951.       WinSetFocus( HWND_DESKTOP,
  2952.                WinWindowFromID(hwndDialogOrg,ID_DEPTNUMB));
  2953.       return FALSE;
  2954.      }
  2955.       ORG_DEPTNUMB = atoi(String);       /* Convert String to Short */
  2956.  
  2957. /**********************************************************************/
  2958. /*   Move "ID_DIVISION" To "ORG_DIVISION". (VARCHAR)              */
  2959. /**********************************************************************/
  2960.  
  2961.  
  2962.       WinQueryWindowText( WinWindowFromID( hwndDialogOrg,
  2963.                        ID_DIVISION),
  2964.               sizeof(ORG_DIVISION),
  2965.               ORG_DIVISION);
  2966.       if (!ORG_DIVISION[0])            /* If Null Data          */
  2967.       ORG_DIVISION_N = -1;            /* Set Sql Null Indicator */
  2968.  
  2969. /**********************************************************************/
  2970. /*   Move "ID_LOCATION" To "ORG_LOCATION". (VARCHAR)              */
  2971. /**********************************************************************/
  2972.  
  2973.  
  2974.       WinQueryWindowText( WinWindowFromID( hwndDialogOrg,
  2975.                        ID_LOCATION),
  2976.               sizeof(ORG_LOCATION),
  2977.               ORG_LOCATION);
  2978.       if (!ORG_LOCATION[0])            /* If Null Data          */
  2979.       ORG_LOCATION_N = -1;            /* Set Sql Null Indicator */
  2980.  
  2981. /**********************************************************************/
  2982. /*   Move "ID_MANAGER" To "ORG_MANAGER". (SMALLINT)              */
  2983. /**********************************************************************/
  2984.  
  2985.  
  2986.       WinQueryWindowText( WinWindowFromID( hwndDialogOrg,
  2987.                        ID_MANAGER),
  2988.               sizeof(String),
  2989.               String);
  2990.       if (!GpfStringIsNumeric(String))
  2991.      {
  2992.       WinSetFocus( HWND_DESKTOP,
  2993.                WinWindowFromID(hwndDialogOrg,ID_MANAGER));
  2994.       return FALSE;
  2995.      }
  2996.       ORG_MANAGER = atoi(String);       /* Convert String to Short */
  2997.       ORG_MANAGER_N = 0;           /* Reset Sql Null Indicator*/
  2998.  
  2999.  
  3000.       return (TRUE);
  3001.  }
  3002. /**********************************************************************/
  3003. /* End of Private Function: MoveDialogOrgToData               */
  3004. /**********************************************************************/
  3005. /**********************************************************************/
  3006.  
  3007.  
  3008.  
  3009. /**********************************************************************/
  3010. /**********************************************************************/
  3011. /*                                      */
  3012. /*   PRIVATE FUNCTION: MoveDataToDialogOrg                  */
  3013. /*                                      */
  3014. /*   Move Data To Window "DialogOrg".                      */
  3015. /*                                      */
  3016. /**********************************************************************/
  3017.  
  3018. BOOL  MoveDataToDialogOrg ( VOID )
  3019.  {
  3020.   UCHAR  String[32];
  3021.   PUCHAR Token;
  3022.  
  3023.   String[0] = 0;      /* Null, Delete Unreferenced Local variable */
  3024.   Token   = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
  3025.  
  3026. /**********************************************************************/
  3027. /*   Move "ORG_DEPTNAME" To "ID_DEPTNAME". (VARCHAR)              */
  3028. /**********************************************************************/
  3029.  
  3030.       WinSendDlgItemMsg(hwndDialogOrg,
  3031.             ID_DEPTNAME,
  3032.             EM_SETTEXTLIMIT,
  3033.             MPFROMSHORT( sizeof(ORG_DEPTNAME) -1 ),
  3034.             MPFROMSHORT( NULL ) );
  3035.       if (ORG_DEPTNAME_N < 0)             /* If Null Indicator */
  3036.       ORG_DEPTNAME[0] = 0;             /* Set Null Data     */
  3037.       WinSetWindowText( WinWindowFromID( hwndDialogOrg,
  3038.             ID_DEPTNAME),
  3039.             ORG_DEPTNAME);    
  3040.  
  3041. /**********************************************************************/
  3042. /*   Move "ORG_DEPTNUMB" To "ID_DEPTNUMB". (SMALLINT)              */
  3043. /**********************************************************************/
  3044.  
  3045.       WinSendDlgItemMsg(hwndDialogOrg,
  3046.             ID_DEPTNUMB,
  3047.             EM_SETTEXTLIMIT,
  3048.             MPFROMSHORT( 5 ),
  3049.             MPFROMSHORT( NULL ) );
  3050.       itoa(ORG_DEPTNUMB,String,10);         /* Convert to string */
  3051.       WinSetWindowText( WinWindowFromID( hwndDialogOrg,
  3052.             ID_DEPTNUMB),
  3053.             String);
  3054.  
  3055. /**********************************************************************/
  3056. /*   Move "ORG_DIVISION" To "ID_DIVISION". (VARCHAR)              */
  3057. /**********************************************************************/
  3058.  
  3059.       WinSendDlgItemMsg(hwndDialogOrg,
  3060.             ID_DIVISION,
  3061.             EM_SETTEXTLIMIT,
  3062.             MPFROMSHORT( sizeof(ORG_DIVISION) -1 ),
  3063.             MPFROMSHORT( NULL ) );
  3064.       if (ORG_DIVISION_N < 0)             /* If Null Indicator */
  3065.       ORG_DIVISION[0] = 0;             /* Set Null Data     */
  3066.       WinSetWindowText( WinWindowFromID( hwndDialogOrg,
  3067.             ID_DIVISION),
  3068.             ORG_DIVISION);    
  3069.  
  3070. /**********************************************************************/
  3071. /*   Move "ORG_LOCATION" To "ID_LOCATION". (VARCHAR)              */
  3072. /**********************************************************************/
  3073.  
  3074.       WinSendDlgItemMsg(hwndDialogOrg,
  3075.             ID_LOCATION,
  3076.             EM_SETTEXTLIMIT,
  3077.             MPFROMSHORT( sizeof(ORG_LOCATION) -1 ),
  3078.             MPFROMSHORT( NULL ) );
  3079.       if (ORG_LOCATION_N < 0)             /* If Null Indicator */
  3080.       ORG_LOCATION[0] = 0;             /* Set Null Data     */
  3081.       WinSetWindowText( WinWindowFromID( hwndDialogOrg,
  3082.             ID_LOCATION),
  3083.             ORG_LOCATION);    
  3084.  
  3085. /**********************************************************************/
  3086. /*   Move "ORG_MANAGER" To "ID_MANAGER". (SMALLINT)              */
  3087. /**********************************************************************/
  3088.  
  3089.       WinSendDlgItemMsg(hwndDialogOrg,
  3090.             ID_MANAGER,
  3091.             EM_SETTEXTLIMIT,
  3092.             MPFROMSHORT( 5 ),
  3093.             MPFROMSHORT( NULL ) );
  3094.       if (ORG_MANAGER_N < 0)             /* If Null Indicator */
  3095.       String[0] = 0;             /* Set Null Data     */
  3096.       else
  3097.       itoa(ORG_MANAGER,String,10);         /* Convert to string */
  3098.       WinSetWindowText( WinWindowFromID( hwndDialogOrg,
  3099.             ID_MANAGER),
  3100.             String);
  3101.  
  3102.  
  3103.       return (TRUE);
  3104.  }
  3105. /**********************************************************************/
  3106. /* End of Private Function: MoveDataToDialogOrg               */
  3107. /**********************************************************************/
  3108. /**********************************************************************/
  3109.  
  3110.  
  3111.  
  3112. /**********************************************************************/
  3113. /**********************************************************************/
  3114. /*                                      */
  3115. /*   PRIVATE FUNCTION: WmInitWndDialogOrg                  */
  3116. /*                                      */
  3117. /*   Wm Init Window "DialogOrg".                      */
  3118. /*                                      */
  3119. /**********************************************************************/
  3120.  
  3121. static VOID WmInitWndDialogOrg ( PGPFPARMS pGpfParms )
  3122.  {
  3123.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  3124.     /**************************************************************/
  3125.     /* Center Window "DialogOrg".                      */
  3126.     /* Positions Window in the center of the screen           */
  3127.     /**************************************************************/
  3128.     GpfSetCentreWindow(hwndFrameDialogOrg);
  3129.     /**************************************************************/
  3130.     /* Move Data To Window "DialogOrg".                  */
  3131.     /**************************************************************/
  3132.     MoveDataToDialogOrg();
  3133.  }
  3134. /**********************************************************************/
  3135. /* End of Private Function: WmInitWndDialogOrg                  */
  3136. /**********************************************************************/
  3137. /**********************************************************************/
  3138.  
  3139.  
  3140.  
  3141. /**********************************************************************/
  3142. /**********************************************************************/
  3143. /*                                      */
  3144. /*   PRIVATE FUNCTION: WmActiveDialogOrg                  */
  3145. /*                                      */
  3146. /*   Wm Activate Window "DialogOrg".                      */
  3147. /*                                      */
  3148. /**********************************************************************/
  3149.  
  3150. static VOID WmActiveDialogOrg ( PGPFPARMS pGpfParms )
  3151.  {
  3152.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  3153.  }
  3154. /**********************************************************************/
  3155. /* End of Private Function: WmActiveDialogOrg                  */
  3156. /**********************************************************************/
  3157. /**********************************************************************/
  3158.  
  3159.  
  3160.  
  3161. /**********************************************************************/
  3162. /**********************************************************************/
  3163. /*                                      */
  3164. /*   PRIVATE FUNCTION: WmDeActiveDialogOrg                  */
  3165. /*                                      */
  3166. /*   DeActivate Window "DialogOrg".                      */
  3167. /*                                      */
  3168. /**********************************************************************/
  3169.  
  3170. static VOID WmDeActiveDialogOrg ( PGPFPARMS pGpfParms )
  3171.  {
  3172.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  3173.  }
  3174. /**********************************************************************/
  3175. /* End of Private Function: WmDeActiveDialogOrg               */
  3176. /**********************************************************************/
  3177. /**********************************************************************/
  3178.  
  3179.  
  3180.  
  3181. /**********************************************************************/
  3182. /**********************************************************************/
  3183. /*                                      */
  3184. /*   PRIVATE FUNCTION: WmCreateDialogOrg                  */
  3185. /*                                      */
  3186. /*   Wm Create Window "DialogOrg".                      */
  3187. /*                                      */
  3188. /**********************************************************************/
  3189.  
  3190. static VOID WmCreateDialogOrg ( PGPFPARMS pGpfParms )
  3191.  {
  3192.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  3193.  }
  3194. /**********************************************************************/
  3195. /* End of Private Function: WmCreateDialogOrg                  */
  3196. /**********************************************************************/
  3197. /**********************************************************************/
  3198.  
  3199.  
  3200.  
  3201. /**********************************************************************/
  3202. /**********************************************************************/
  3203. /*                                      */
  3204. /*   PRIVATE FUNCTION: WmDestroyDialogOrg                  */
  3205. /*                                      */
  3206. /*   Wm Destroy Window "DialogOrg".                      */
  3207. /*                                      */
  3208. /**********************************************************************/
  3209.  
  3210. static VOID WmDestroyDialogOrg ( PGPFPARMS pGpfParms )
  3211.  {
  3212.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  3213.  }
  3214. /**********************************************************************/
  3215. /* End of Private Function: WmDestroyDialogOrg                  */
  3216. /**********************************************************************/
  3217. /**********************************************************************/
  3218.  
  3219.  
  3220.  
  3221. /**********************************************************************/
  3222. /**********************************************************************/
  3223. /*                                      */
  3224. /*   PRIVATE FUNCTION: WmPaintDialogOrg                   */
  3225. /*                                      */
  3226. /*   Wm Paint Window "DialogOrg".                      */
  3227. /*                                      */
  3228. /**********************************************************************/
  3229.  
  3230. static VOID WmPaintDialogOrg ( PGPFPARMS pGpfParms )
  3231.  {
  3232.   pGpfParms->mresult = (MRESULT) FALSE;     /* Set Return Code    */
  3233.  }
  3234. /**********************************************************************/
  3235. /* End of Private Function: WmPaintDialogOrg                  */
  3236. /**********************************************************************/
  3237. /**********************************************************************/
  3238.  
  3239.  
  3240.  
  3241. /**********************************************************************/
  3242. /**********************************************************************/
  3243. /*                                      */
  3244. /*   PRIVATE FUNCTION: WmShowDialogOrg                      */
  3245. /*                                      */
  3246. /*   Wm Show Window "DialogOrg".                      */
  3247. /*                                      */
  3248. /**********************************************************************/
  3249.  
  3250. static VOID WmShowDialogOrg ( PGPFPARMS pGpfParms )
  3251.  {
  3252.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  3253.  }
  3254. /**********************************************************************/
  3255. /* End of Private Function: WmShowDialogOrg                  */
  3256. /**********************************************************************/
  3257. /**********************************************************************/
  3258.  
  3259.  
  3260.  
  3261. /**********************************************************************/
  3262. /**********************************************************************/
  3263. /*                                      */
  3264. /*   PRIVATE FUNCTION: WmHideDialogOrg                      */
  3265. /*                                      */
  3266. /*   Wm Hide Window "DialogOrg".                      */
  3267. /*                                      */
  3268. /**********************************************************************/
  3269.  
  3270. static VOID WmHideDialogOrg ( PGPFPARMS pGpfParms )
  3271.  {
  3272.   pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code          */
  3273.  }
  3274. /**********************************************************************/
  3275. /* End of Private Function: WmHideDialogOrg                  */
  3276. /**********************************************************************/
  3277. /**********************************************************************/
  3278.  
  3279.  
  3280.