home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PRECOM.ZIP / SAMPLE.ZIP / TEST.MOD < prev    next >
Text File  |  1992-09-27  |  6KB  |  177 lines

  1. MODULE Test;
  2. FROM Sample IMPORT Staff,Org;
  3. FROM Lists IMPORT GenList;
  4. FROM LstBox IMPORT ListBox;
  5. FROM Sample IMPORT GetOrgLst;
  6. FROM SQLEnv IMPORT SQLGSTRD;
  7. FROM Str IMPORT Length,Copy;
  8. FROM SQLCA IMPORT sqlca;
  9. IMPORT SAM;
  10.  
  11.    (* presentation manager junk *)
  12.  
  13. (*# call(same_ds => off) *)
  14. (*# data(heap_size=> 3000) *)
  15.  
  16.  
  17. IMPORT OS2DEF,Win,Lib,SYSTEM;
  18.  
  19. FROM OS2DEF IMPORT HDC,HRGN,HAB,HPS,HBITMAP,HWND,HMODULE,HSEM,
  20.                    POINTL,RECTL,PID,TID,LSET,NULL,
  21.                    COLOR,NullVar,NullStr,BOOL ;
  22.  
  23. CONST
  24.   WindowId = 255;
  25.  
  26. VAR
  27.   Hab       : HAB;
  28.   Hps       : HPS;
  29.   BackColor : COLOR;
  30.   ForeColor : COLOR;
  31.   ChangeBack: BOOLEAN;
  32.  
  33.  
  34.  
  35.   (********************* application stuff *)
  36.   StaffObj : Staff;
  37.   OrgObj   : Org;
  38.   OrgList  : ListBox;
  39.   DBName   : ARRAY[0..20] OF CHAR;
  40.   SQLca    : sqlca;
  41.   RC : CARDINAL;
  42.  
  43.  
  44.  
  45. PROCEDURE Setup();
  46.  
  47. BEGIN
  48.   Copy(DBName,'SAMPLE');
  49.   RC := SQLGSTRD(0,Length(DBName),'S',SQLca,NIL,DBName); (* start the database*)
  50.   GetOrgLst(OrgList.ItemList);
  51. END Setup;
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. (*--------------------  Start of window procedure  ---------------------*)
  60. (*# save,
  61.     call(near_call=>off, reg_param=>(), reg_saved=>(di,si,ds,es,st1,st2)) *)
  62. PROCEDURE WindowProc(hwnd : HWND;msg:CARDINAL;mp1,mp2:Win.MPARAM):Win.MRESULT;
  63.  (* this main window will only call the dialogs on the create *)
  64.  (* and will wait for the end message from the system menu    *)
  65. VAR
  66.   C : CARDINAL;
  67.   Reply : Win.MRESULT;
  68. BEGIN
  69.   CASE msg OF
  70.   | Win.WM_CREATE:Setup();  (* read the database *)
  71.                    C := Win.DlgBox(Win.HWND_DESKTOP, Win.HWND_DESKTOP, SAM.SampleMessageProc,
  72.                         0, SAM.OrgLst, ADR(OrgList));
  73.                    Reply := Win.SendMsg(hwnd,Win.DID_CANCEL,mp1,mp2);
  74.                            (* when done with org unit - done with everything*)
  75.             
  76.  
  77.  
  78.   | Win.WM_CLOSE:
  79.  
  80.       (*----------------------------------------------------------------*)
  81.       (* This is the place to put your termination routines             *)
  82.       (*----------------------------------------------------------------*)
  83.  
  84.       IF NOT Win.PostMsg( hwnd, Win.WM_QUIT, 0, 0 )
  85.        THEN  (* Cause termination        *)
  86.        END;
  87.  
  88.     ELSE
  89.  
  90.       (*----------------------------------------------------------------*)
  91.       (* Everything else comes here.  This call MUST exist              *)
  92.       (* in your window procedure.                                      *)
  93.       (*----------------------------------------------------------------*)
  94.  
  95.       RETURN Win.DefWindowProc( hwnd, msg, mp1, mp2 );
  96.     END;
  97.     RETURN Win.MPARAM(FALSE);
  98.  
  99. END WindowProc;
  100. (*# restore *)
  101.  
  102. PROCEDURE Main;
  103. (*****************************************************************
  104.    This procedure is taken from the JPI sample code
  105.  
  106. ******************************************************************)
  107.  
  108. VAR
  109.   hmq      : Win.HMQ;
  110.   qmsg     : Win.QMSG;
  111.   client   : HWND;
  112.   frame    : HWND;
  113.   createfl : LSET;
  114.   b        : BOOLEAN;
  115.   r        : Win.MRESULT;
  116.  
  117. BEGIN
  118.   Hab := Win.Initialize( NULL );        (* Initialize PM                *)
  119.   hmq := Win.CreateMsgQueue( Hab, 0 );  (* Create a message queue       *)
  120.  
  121.   IF NOT Win.RegisterClass(             (* Register window class        *)
  122.      Hab,                               (* Anchor block handle          *)
  123.      FarADR("Datamanager"),                (* Window class name            *)
  124.      WindowProc,                        (* Address of window procedure  *)
  125.      0,                                 (* No special Class Style       *)
  126.      0                                  (* No extra window words        *)
  127.      ) THEN END;
  128.  
  129.   createfl := Win.FCF_TITLEBAR+
  130.               Win.FCF_MINMAX+Win.FCF_SYSMENU +
  131.               Win.FCF_SHELLPOSITION+
  132.               Win.FCF_TASKLIST+
  133.               Win.FCF_SIZEBORDER;         (* Set Frame Control Flag       *)
  134.  
  135.   frame := Win.CreateStdWindow(
  136.                Win.HWND_DESKTOP,        (* Desktop window is parent     *)
  137.                Win.FS_TASKLIST+Win.WS_VISIBLE,         (* Class Style                  *)
  138.                createfl,                (* Frame control flag           *)
  139.                FarADR("Datamanager"),      (* Client window class name     *)
  140.                'JPI MOD2 IBM Datamanager SQL Demo',(* Title                    *)
  141.                0,                       (* No special class style       *)
  142.                NULL,                    (* Resource is in .EXE file     *)
  143.                WindowId,                (* Frame window identifier      *)
  144.                client                   (* Client window handle         *)
  145.                );
  146.  
  147.  
  148. (*
  149.   IF NOT Win.SetWindowPos( frame,       (* Set the size and position of *)
  150.                    Win.HWND_TOP,        (* the window before showing.   *)
  151.                    0, 0, 500, 500,
  152.                    Win.SWP_SIZE+Win.SWP_MOVE+Win.SWP_ACTIVATE+Win.SWP_SHOW
  153.                  ) THEN END;
  154. *)
  155. (*----------------------------------------------------------------------*)
  156. (* Get and dispatch messages from the application message queue         *)
  157. (* until WinGetMsg returns FALSE, indicating a WM_QUIT message.         *)
  158. (*----------------------------------------------------------------------*)
  159.   WHILE( Win.GetMsg( Hab, qmsg, HWND(NULL), 0, 0 ) ) DO
  160.     r := Win.DispatchMsg( Hab, qmsg );
  161.   END;
  162.  
  163.   IF NOT Win.DestroyWindow( frame ) THEN      (* Tidy up...                   *)
  164.       END;
  165.   IF NOT Win.DestroyMsgQueue( hmq ) THEN      (* and                          *)
  166.       END;
  167.   IF NOT Win.Terminate( Hab ) THEN            (* terminate the application    *)
  168.      END;
  169.  
  170. END Main;
  171. (*----------------------  End of main procedure  -----------------------*)
  172.  
  173.  
  174. BEGIN
  175.   Main();
  176. END Test.
  177.