Microsoft KB Archive/39192

From BetaArchive Wiki

COBOL 3.0 Can Call Mouse in MS OS/2 Protected Mode

PSS ID Number: Q39192 Article last modified on 04-20-1993

3.00 3.00a OS/2

The information in this article applies to:
- Microsoft COBOL for OS/2, versions 3.0 and 3.0a

Summary: Microsoft COBOL Versions 3.0 and 3.0a can initialize and use the mouse in MS OS/2 protected mode. The following example demonstrates how to call the following API routines: MouOpen MouDrawPtr MouGetNumQueEl MouReadEventQue MouClose

Code Example

The following code example demonstrates the OS/2 mouse API calls listed above:

  $SET OSVS ANS85 LITLINK
   Working-storage section.
   01 ws-null          pic 9(8) comp-5 value zeros.
   01 mouse-handle     pic 9(4) comp-5.
   01 Display-Return   pic 9(4) comp-5.
   01 NumMouEventStruct.
       05 cEvents      pic 9(4) comp-5 value 0.
       05 cMaxEvents   pic 9(2) comp-5 value 0.
   01 needed-input     pic x.
   01 pmoueventinfo.
       05 fs    pic 9(4) comp-5.
       05 timex pic 9(8) comp-5.
       05 rowx  pic 9(4) comp-5.
       05 colx  pic 9(4) comp-5.
   01 pfwait     pic 9(4) comp-5 value 1.
   Procedure Division.
   main-para.
       call "__MouOpen" using by reference mouse-handle
                              by value ws-null.
       if RETURN-CODE not = 0
           DISPLAY "MOUSE OPEN ERROR"
           EXHIBIT NAMED RETURN-CODE
           STOP RUN.
       display "1-open ok".
       call "__MouDrawPtr" using by value mouse-handle.
       if RETURN-CODE not = 0
           DISPLAY "MOUSE DRAW PTR ERROR"
           EXHIBIT NAMED RETURN-CODE
           STOP RUN.
       display "2-drawptr ok".
       display "need input".
       accept needed-input.
       call "__mouGetNumQueEl" using by value mouse-handle
                                     by reference NumMouEventStruct.
       if RETURN-CODE not = 0
           DISPLAY "MOUSE GETNUMQ ERROR"
           EXHIBIT NAMED RETURN-CODE
           STOP RUN.
       display "3-GETNUMQ ok".
       call "__MouReadEventQue" using by value mouse-handle
                                      by reference pfwait
                                      by reference pmoueventinfo.
       if RETURN-CODE not = 0
           DISPLAY "MOUSE READQ ERROR"
           EXHIBIT NAMED RETURN-CODE
           STOP RUN.
       display "4-READQ ok".
       call "__MouClose" using by value mouse-handle.
       if RETURN-CODE not = 0
           DISPLAY "MOUSE CLOSE ERROR"
           EXHIBIT NAMED RETURN-CODE
           STOP RUN.
       STOP RUN.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.