home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / WINCALLS.E < prev    next >
Text File  |  1995-01-20  |  9KB  |  181 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.  The dynalink32 calls are for 32-bit EPM only (EPM 6).
  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 edit window (this one)
  33.                   'WINSETFOCUS',
  34.                   atoi(0) ||               /* HWND_DESKTOP is 1 */
  35.                   atoi(1) ||
  36.                   gethwnd(5) )             /* EPM client */
  37.  
  38.    call dynalink32( 'PMWIN',               -- Set focus to the note window
  39.                     '#860',                -- ordinal for Win32SetFocus
  40.                     atol(1) ||               /* HWND_DESKTOP is 1 */
  41.                     gethwndc(EPMINFO_EDITCLIENT) )
  42.  
  43.    call dynalink( 'PMWIN',
  44.              'WINSHOWWINDOW',
  45.               gethwnd(6)              ||
  46.               atoi(1) )                       -- Set Window State Visible
  47.  
  48.    rect = '????????????????'     -- Left, Bottom, Right, Top
  49.    call dynalink( 'PMWIN',
  50.              'WINQUERYWINDOWRECT',
  51.               gethwnd(EPMINFO_EDITCLIENT) ||
  52.               selector(rect)              ||      /* string selector                   */
  53.               offset(rect) )                      /* string offset                     */
  54.  
  55.   return dynalink( 'PMWIN',
  56.                    'WINMESSAGEBOX',
  57.                    atoi(0) || atoi(1) ||   -- Parent
  58.                    -- atoi(0) || atoi(1) ||   -- Owner
  59.                    gethwnd(EPMINFO_EDITFRAME) ||   /* edit frame handle             */
  60.                    selector(text)     ||   -- Text
  61.                    offset(text)       ||
  62.                    selector(caption)  ||   -- Title
  63.                    offset(caption)    ||
  64.                    atoi(0)            ||   -- Window
  65.                    atoi(msgtype) )         -- Style
  66.  
  67.    len= dynalink( 'PMWIN',
  68.              'WINQUERYWINDOWTEXT',
  69.               atol_swap(hwnd)         ||
  70.               atoi(255)               ||
  71.               selector(str)           ||      /* string selector                   */
  72.               offset(str) )                   /* string offset                     */
  73.  
  74.    call dynalink( 'PMWIN',
  75.              'WINSETWINDOWPOS',
  76.               gethwnd(EPMINFO_EDITFRAME) ||
  77.               atoi(0) || atoi(3)         ||      /* HWND_TOP   */
  78.               atoi(x)                    ||
  79.               atoi(y)                    ||
  80.               atoi(cx)                   ||
  81.               atoi(cy)                   ||
  82.               atoi(opts))                        /* SWP_MOVE | SWP_SIZE */
  83.  
  84.    call dynalink('PMWIN',
  85.                  'WINQUERYWINDOWPOS',
  86.                   gethwnd(EPMINFO_EDITCLIENT)  ||
  87.                   selector(swp1)               ||
  88.                   offset(swp1) )
  89.  
  90.    call dynalink( 'PMWIN',
  91.                   'WINPOSTMSG',
  92.                    gethwnd(5)      ||    -- Tell client to destroy itself
  93.                    atoi(41)        ||    -- WM_CLOSE
  94.                    atol(0)         ||
  95.                    atol(0) )
  96.  
  97.    return dynalink( 'PMWIN',
  98.                     'WINQUERYSYSVALUE',
  99.                      atoi(0) || atoi(1)      ||
  100.                      atoi(20 + (upcase(cxcy)='Y')))
  101.  
  102.    call dynalink( 'PMWIN',
  103.       'WINSENDMSG',
  104.        gethwnd(17)             ||
  105.        atoi(402)               ||      -- MM_SETITEMATTR
  106.        atoi(1)                 ||      -- search submenus
  107.        atoi(menuid)            ||
  108.        atoi(mask)              ||
  109.        atoi(attr), 2)
  110.  
  111.    hab=gethwnd(0)                           /* get EPM's anchorblock     */
  112.    call dynalink('PMWIN',                   /* Open PM's clipboard       */
  113.                  'WINOPENCLIPBRD',
  114.                  hab)
  115.    result = dynalink('PMWIN',               /* call PM function to       */
  116.                      'WINQUERYCLIPBRDDATA', /* look at the data in the cb*/
  117.                      hab ||                 /* anchor block              */
  118.                      atoi(1),               /* data format ( TEXT )      */
  119.                      2)                     /* return a 4 byte result    */
  120.  
  121.    call dynalink('PMWIN',                   -- Empty the clipboard completely
  122.                  'WINEMPTYCLIPBRD',         -- before filling it.
  123.                  hab)
  124.    call dynalink('PMWIN',                   /* call PM function to       */
  125.                  'WINSETCLIPBRDDATA',       /* move data into the PM e cb*/
  126.                   hab ||                    /* anchor block              */
  127.                   atol(result) ||           /* pointer to text.          */
  128.                   atoi(1) ||                /* format (TEXT)             */
  129.                   atoi(256))                /* selector                  */
  130.  
  131.    call dynalink('PMWIN',
  132.                  'WINCLOSECLIPBRD',
  133.                  hab)
  134.  
  135. defproc clipcheck(var format)  -- Returns error code; if OK, sets FORMAT
  136.    hab=gethwnd(0)                          -- get EPM's anchorblock
  137.    format = \0\0                           -- (reserve two bytes)
  138.    rc=dynalink('PMWIN',                    -- call PM function to
  139.                'WINQUERYCLIPBRDFMTINFO',   -- look at the data in the cb
  140.                hab              ||         -- anchor block
  141.                atoi(1)          ||         -- data format ( TEXT )
  142.                selector(format) ||
  143.                offset(format))
  144.    format = itoa(format,10)                -- Convert format to ASCII
  145.    return rc
  146.  
  147.  
  148.    hAtomTable = dynalink('PMWIN',                    -- call PM function to
  149.                          'WINQUERYSYSTEMATOMTABLE',  -- get handle of system atom table
  150.                          '', 2)
  151.  
  152.    atomname = 'some string'\0
  153.    Atom = dynalink('PMWIN',              -- call PM function to
  154.                    'WINADDATOM',         -- add an atom
  155.                    atol_swap(hAtomTable)   ||
  156.                    selector(atomname)      ||
  157.                    offset(atomname))
  158.  
  159.    atomname = 'some string'\0
  160.    Atom = dynalink('PMWIN',              -- call PM function to
  161.                    'WINFINDATOM',        -- find an atom
  162.                    atol_swap(hAtomTable)   ||
  163.                    selector(atomname)      ||
  164.                    offset(atomname))
  165.  
  166.    atomname = copies(\0, 255)
  167.    len = dynalink('PMWIN',              -- call PM function to
  168.                   'WINQUERYATOMNAME',   -- return an atom name
  169.                   atol_swap(hAtomTable)   ||
  170.                   atoi(atom)              ||
  171.                   selector(atomname)      ||
  172.                   offset(atomname)        ||
  173.                   atoi(255) )
  174.    if len=0 then
  175.       sayerror 'atom or table invalid'
  176.    else
  177.       sayerror '"'leftstr(atomname, len)'"           nj306odv TXT    NlNl!!                     nj306oe  TXT    àlàl!!                     nj306oe0 TXT    ╝l╝l!!                     nj306oe1 TXT    ≤l≤l!!                     nj306oe2 TXT    *m*m!!                     nj306oe3 TXT    amam!!                     nj306oe4 TXT    ÿmÿm!!                     nj306oe5 TXT    ╧m╧m!!                     nj306oe6 TXT    nn!!                     nj306oe7 TXT    =n=n!!                     nj306oe8 TXT    tntn!!                     nj306oe9 TXT    ½n½n!!                     nj306oea TXT    ΓnΓn!!                     nj306oeb TXT    oo!!                     nj306oec TXT    PoPo!!                     nj306oed TXT    çoço!!                     nj306oee TXT    ╛o╛o!!                     nj306oef TXT    ⌡o⌡o!!                     nj306oeg TXT    ,p,pr Win32QueryActiveWindow
  178.                          atol(1)     ||         -- HWND_DESKTOP
  179.                          atol(hwnd), 2)
  180.  
  181.