home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / editor / epmtools / epmsmp / wincalls.e < prev   
Encoding:
Text File  |  1992-08-26  |  7.2 KB  |  174 lines

  1. ; The following contains samples of dynalinking to a few of the OS/2
  2. ; Win... calls from EPM.  These are building blocks for you to use in
  3. ; your own code.
  4.  
  5. ; By Larry Margolis
  6.  
  7.  
  8.    err = dynalink('PMWIN',
  9.                  'WINGETLASTERROR',
  10.                   gethwnd(0), 2)
  11.  
  12.    hheap=dynalink('PMWIN',
  13.                  'WINQUERYWINDOWULONG',
  14.                   gethwnd(handle)  ||
  15.                   atoi(4), 2)                      -- QWL_HHEAP
  16.  
  17.    largest=dynalink('PMWIN',
  18.                  'WINAVAILMEM',
  19.                   atol(hheap) ||
  20.                   atoi(0)     ||  -- Don't compact
  21.                   atoi(0) )       -- reserved
  22.  
  23.    TheTitle = substr('',1,255);
  24.    result = dynalink( 'PMWIN',
  25.                   'WINQUERYDLGITEMTEXT',
  26.                    mygethwnd(3)      ||    /* Parent Window handle */
  27.                    atoi(267)         ||    /* EntryBox Id  */
  28.                    atoi(255)         ||    /* Length of text */
  29.                    selector(TheTitle)||offset(TheTitle))
  30.    TheTitle = substr(TheTitle,1,result);
  31.  
  32.    call dynalink( 'PMWIN',               -- Set focus to the note window (this one)
  33.                   'WINSETFOCUS',
  34.                   atoi(0) ||               /* HWND_DESKTOP is 1 */
  35.                   atoi(1) ||
  36.                   gethwnd(5) )             /* EPM client */
  37.  
  38.    call dynalink( 'PMWIN',
  39.              'WINSHOWWINDOW',
  40.               gethwnd(6)              ||
  41.               atoi(1) )                       -- Set Window State Visible
  42.  
  43.    rect = '????????????????'     -- Left, Bottom, Right, Top
  44.    call dynalink( 'PMWIN',
  45.              'WINQUERYWINDOWRECT',
  46.               gethwnd(EPMINFO_EDITCLIENT) ||
  47.               selector(rect)              ||      /* string selector                   */
  48.               offset(rect) )                      /* string offset                     */
  49.  
  50.   return dynalink( 'PMWIN',
  51.                    'WINMESSAGEBOX',
  52.                    atoi(0) || atoi(1) ||   -- Parent
  53.                    -- atoi(0) || atoi(1) ||   -- Owner
  54.                    gethwnd(EPMINFO_EDITFRAME) ||   /* edit frame handle             */
  55.                    selector(text)     ||   -- Text
  56.                    offset(text)       ||
  57.                    selector(caption)  ||   -- Title
  58.                    offset(caption)    ||
  59.                    atoi(0)            ||   -- Window
  60.                    atoi(msgtype) )         -- Style
  61.  
  62.    len= dynalink( 'PMWIN',
  63.              'WINQUERYWINDOWTEXT',
  64.               atol_swap(hwnd)         ||
  65.               atoi(255)               ||
  66.               selector(str)           ||      /* string selector                   */
  67.               offset(str) )                   /* string offset                     */
  68.  
  69.    call dynalink( 'PMWIN',
  70.              'WINSETWINDOWPOS',
  71.               gethwnd(EPMINFO_EDITFRAME) ||
  72.               atoi(0) || atoi(3)         ||      /* HWND_TOP   */
  73.               atoi(x)                    ||
  74.               atoi(y)                    ||
  75.               atoi(cx)                   ||
  76.               atoi(cy)                   ||
  77.               atoi(opts))                        /* SWP_MOVE | SWP_SIZE */
  78.  
  79.    call dynalink('PMWIN',
  80.                  'WINQUERYWINDOWPOS',
  81.                   gethwnd(EPMINFO_EDITCLIENT)  ||
  82.                   selector(swp1)               ||
  83.                   offset(swp1) )
  84.  
  85.    call dynalink( 'PMWIN',
  86.                   'WINPOSTMSG',
  87.                    gethwnd(5)      ||    -- Tell client to destroy itself
  88.                    atoi(41)        ||    -- WM_CLOSE
  89.                    atol(0)         ||
  90.                    atol(0) )
  91.  
  92.    return dynalink( 'PMWIN',
  93.                     'WINQUERYSYSVALUE',
  94.                      atoi(0) || atoi(1)      ||
  95.                      atoi(20 + (upcase(cxcy)='Y')))
  96.  
  97.    call dynalink( 'PMWIN',
  98.       'WINSENDMSG',
  99.        gethwnd(17)             ||
  100.        atoi(402)               ||      -- MM_SETITEMATTR
  101.        atoi(1)                 ||      -- search submenus
  102.        atoi(menuid)            ||
  103.        atoi(mask)              ||
  104.        atoi(attr), 2)
  105.  
  106.    hab=gethwnd(0)                           /* get EPM's anchorblock     */
  107.    call dynalink('PMWIN',                   /* Open PM's clipboard       */
  108.                  'WINOPENCLIPBRD',
  109.                  hab)
  110.    result = dynalink('PMWIN',               /* call PM function to       */
  111.                      'WINQUERYCLIPBRDDATA', /* look at the data in the cb*/
  112.                      hab ||                 /* anchor block              */
  113.                      atoi(1),               /* data format ( TEXT )      */
  114.                      2)                     /* return a 4 byte result    */
  115.  
  116.    call dynalink('PMWIN',                   -- Empty the clipboard completely
  117.                  'WINEMPTYCLIPBRD',         -- before filling it.
  118.                  hab)
  119.    call dynalink('PMWIN',                   /* call PM function to       */
  120.                  'WINSETCLIPBRDDATA',       /* move data into the PM e cb*/
  121.                   hab ||                    /* anchor block              */
  122.                   atol(result) ||           /* pointer to text.          */
  123.                   atoi(1) ||                /* format (TEXT)             */
  124.                   atoi(256))                /* selector                  */
  125.  
  126.    call dynalink('PMWIN',
  127.                  'WINCLOSECLIPBRD',
  128.                  hab)
  129.  
  130. defproc clipcheck(var format)  -- Returns error code; if OK, sets FORMAT
  131.    hab=gethwnd(0)                          -- get EPM's anchorblock
  132.    format = \0\0                           -- (reserve two bytes)
  133.    rc=dynalink('PMWIN',                    -- call PM function to
  134.                'WINQUERYCLIPBRDFMTINFO',   -- look at the data in the cb
  135.                hab              ||         -- anchor block
  136.                atoi(1)          ||         -- data format ( TEXT )
  137.                selector(format) ||
  138.                offset(format))
  139.    format = itoa(format,10)                -- Convert format to ASCII
  140.    return rc
  141.  
  142.  
  143.    hAtomTable = dynalink('PMWIN',                    -- call PM function to
  144.                          'WINQUERYSYSTEMATOMTABLE',  -- get handle of system atom table
  145.                          '', 2)
  146.  
  147.    atomname = 'some string'\0
  148.    Atom = dynalink('PMWIN',              -- call PM function to
  149.                    'WINADDATOM',         -- add an atom
  150.                    atol_swap(hAtomTable)   ||
  151.                    selector(atomname)      ||
  152.                    offset(atomname))
  153.  
  154.    atomname = 'some string'\0
  155.    Atom = dynalink('PMWIN',              -- call PM function to
  156.                    'WINFINDATOM',        -- find an atom
  157.                    atol_swap(hAtomTable)   ||
  158.                    selector(atomname)      ||
  159.                    offset(atomname))
  160.  
  161.    atomname = copies(\0, 255)
  162.    len = dynalink('PMWIN',              -- call PM function to
  163.                   'WINQUERYATOMNAME',   -- return an atom name
  164.                   atol_swap(hAtomTable)   ||
  165.                   atoi(atom)              ||
  166.                   selector(atomname)      ||
  167.                   offset(atomname)        ||
  168.                   atoi(255) )
  169.    if len=0 then
  170.       sayerror 'atom or table invalid'
  171.    else
  172.       sayerror '"'leftstr(atomname, len)'"'
  173.    endif
  174.