home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xwphescr.zip / XWPH0208.ZIP / include / helpers / winh.h < prev    next >
C/C++ Source or Header  |  2002-08-10  |  40KB  |  983 lines

  1.  
  2. /*
  3.  *@@sourcefile winh.h:
  4.  *      header file for winh.c (PM helper funcs). See remarks there.
  5.  *
  6.  *      Special #define's which this thing reacts to:
  7.  *
  8.  *      --  If WINH_STANDARDWRAPPERS is defined to anything, this include
  9.  *          file maps a number of freqently API calls (such as WinSendMsg)
  10.  *          to winh* equivalents to reduce the amount of fixup records
  11.  *          in the final executable.
  12.  *
  13.  *      Note: Version numbering in this file relates to XWorkplace version
  14.  *            numbering.
  15.  */
  16.  
  17. /*      Copyright (C) 1997-2000 Ulrich Möller.
  18.  *      This file is part of the "XWorkplace helpers" source package.
  19.  *      This is free software; you can redistribute it and/or modify
  20.  *      it under the terms of the GNU General Public License as published
  21.  *      by the Free Software Foundation, in version 2 as it comes in the
  22.  *      "COPYING" file of the XWorkplace main distribution.
  23.  *      This program is distributed in the hope that it will be useful,
  24.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  25.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26.  *      GNU General Public License for more details.
  27.  *
  28.  *@@include #define INCL_WINWINDOWMGR
  29.  *@@include #define INCL_WINMESSAGEMGR
  30.  *@@include #define INCL_WINSYS             // for winhStorePresParam
  31.  *@@include #define INCL_WINDIALOGS
  32.  *@@include #define INCL_WINMENUS           // for menu helpers
  33.  *@@include #define INCL_WINENTRYFIELDS     // for entry field helpers
  34.  *@@include #define INCL_WINBUTTONS         // for button/check box helpers
  35.  *@@include #define INCL_WINLISTBOXES       // for list box helpers
  36.  *@@include #define INCL_WINSTDSPIN         // for spin button helpers
  37.  *@@include #define INCL_WINSTDSLIDER       // for slider helpers
  38.  *@@include #define INCL_WININPUT
  39.  *@@include #define INCL_WINSYS
  40.  *@@include #define INCL_WINSHELLDATA
  41.  *@@include #define INCL_WINSWITCHLIST      // for winhQuerySwitchList
  42.  *@@include #define INCL_WINPROGRAMLIST     // for appStartApp
  43.  *@@include #define INCL_WINHELP            // for help manager helpers
  44.  *@@include #include <os2.h>
  45.  *@@include #include "helpers\winh.h"
  46.  */
  47.  
  48. #if __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52. #ifndef WINH_HEADER_INCLUDED
  53.     #define WINH_HEADER_INCLUDED
  54.  
  55.     #ifndef XWPENTRY
  56.         #error You must define XWPENTRY to contain the standard linkage for the XWPHelpers.
  57.     #endif
  58.  
  59.     /* ******************************************************************
  60.      *
  61.      *   Declarations
  62.      *
  63.      ********************************************************************/
  64.  
  65.     #define MPNULL                 (MPFROMP(NULL))
  66.     #define MPZERO                 (MPFROMSHORT(0))
  67.     #define MRTRUE                 (MRFROMSHORT((SHORT) TRUE))
  68.     #define MRFALSE                (MRFROMSHORT((SHORT) FALSE))
  69.     #define BM_UNCHECKED           0   // for checkboxes: disabled
  70.     #define BM_CHECKED             1   // for checkboses: enabled
  71.     #define BM_INDETERMINATE       2   // for tri-state checkboxes: indeterminate
  72.  
  73.     /* ******************************************************************
  74.      *
  75.      *   Wrappers
  76.      *
  77.      ********************************************************************/
  78.  
  79.     // if WINH_STANDARDWRAPPERS is #define'd before including winh.h,
  80.     // all the following Win* API calls are redirected to the winh*
  81.     // counterparts
  82.  
  83.     #ifdef WINH_STANDARDWRAPPERS
  84.  
  85.         MRESULT XWPENTRY winhSendMsg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  86.         #define WinSendMsg(a,b,c,d) winhSendMsg((a),(b),(c),(d))
  87.  
  88.         MRESULT XWPENTRY winhSendDlgItemMsg(HWND hwnd, ULONG id, ULONG msg, MPARAM mp1, MPARAM mp2);
  89.         #define WinSendDlgItemMsg(a,b,c,d,e) winhSendDlgItemMsg((a),(b),(c),(d),(e))
  90.  
  91.         BOOL XWPENTRY winhPostMsg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  92.         #define WinPostMsg(a,b,c,d) winhPostMsg((a),(b),(c),(d))
  93.  
  94.         HWND XWPENTRY winhWindowFromID(HWND hwnd, ULONG id);
  95.         #define WinWindowFromID(a,b) winhWindowFromID((a),(b))
  96.  
  97.         HWND XWPENTRY winhQueryWindow(HWND hwnd, LONG lCode);
  98.         #define WinQueryWindow(a,b) winhQueryWindow((a),(b))
  99.  
  100.         PVOID XWPENTRY winhQueryWindowPtr(HWND hwnd, LONG index);
  101.         #define WinQueryWindowPtr(a,b) winhQueryWindowPtr((a),(b))
  102.  
  103.         BOOL XWPENTRY winhSetWindowText2(HWND hwnd, const char *pcsz);
  104.         #define WinSetWindowText(a,b) winhSetWindowText2((a),(b))
  105.  
  106.         BOOL XWPENTRY winhSetDlgItemText(HWND hwnd, ULONG id, const char *pcsz);
  107.         #define WinSetDlgItemText(a,b,c) winhSetDlgItemText((a),(b),(c))
  108.  
  109.         // pmwin.h defines the WinEnableControl macro; turn this into our function call
  110.         #ifdef WinEnableControl
  111.             #undef WinEnableControl
  112.         #endif
  113.         #define WinEnableControl(hwndDlg, id, fEnable) winhEnableDlgItem((hwndDlg), (id), (fEnable))
  114.  
  115.         #ifdef INCL_WINMESSAGEMGR
  116.             APIRET XWPENTRY winhRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
  117.             #define WinRequestMutexSem(a, b) winhRequestMutexSem((a), (b))
  118.         #endif
  119.     #endif
  120.  
  121.     /* ******************************************************************
  122.      *
  123.      *   Macros
  124.      *
  125.      ********************************************************************/
  126.  
  127.     /*
  128.      *  Here come some monster macros for
  129.      *  frequently needed functions.
  130.      */
  131.  
  132.     #define winhDebugBox(hwndOwner, title, text) \
  133.     WinMessageBox(HWND_DESKTOP, hwndOwner, ((PSZ)text), ((PSZ)title), 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE)
  134.  
  135.     #define winhYesNoBox(title, text) \
  136.     WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, ((PSZ)text), ((PSZ)title), 0, MB_YESNO | MB_ICONQUESTION | MB_MOVEABLE)
  137.  
  138.     #define winhSetDlgItemChecked(hwnd, id, bCheck) \
  139.             WinSendDlgItemMsg((hwnd), (id), BM_SETCHECK, MPFROMSHORT(bCheck), MPNULL)
  140.     #define winhIsDlgItemChecked(hwnd, id) \
  141.             (SHORT1FROMMR(WinSendDlgItemMsg((hwnd), (id), BM_QUERYCHECK, MPNULL, MPNULL)))
  142.  
  143.     #define winhSetMenuItemChecked(hwndMenu, usId, bCheck) \
  144.             WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(usId, TRUE), \
  145.                     MPFROM2SHORT(MIA_CHECKED, (((bCheck)) ? MIA_CHECKED : FALSE)))
  146.  
  147.     #define winhShowDlgItem(hwnd, id, show) \
  148.             WinShowWindow(WinWindowFromID(hwnd, id), show)
  149.  
  150.     // made these functions V0.9.12 (2001-05-18) [umoeller]
  151.     /* #define winhEnableDlgItem(hwndDlg, ulId, Enable) \
  152.             WinEnableWindow(WinWindowFromID(hwndDlg, ulId), Enable)
  153.     #define winhIsDlgItemEnabled(hwndDlg, ulId) \
  154.             WinIsWindowEnabled(WinWindowFromID(hwndDlg, ulId))
  155.         */
  156.  
  157.     #define winhSetDlgItemFocus(hwndDlg, ulId) \
  158.             WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwndDlg, ulId))
  159.  
  160.     /* ******************************************************************
  161.      *
  162.      *   Rectangle helpers
  163.      *
  164.      ********************************************************************/
  165.  
  166.     VOID XWPENTRY winhOffsetRect(PRECTL prcl, LONG lx, LONG ly);
  167.  
  168.     /* ******************************************************************
  169.      *
  170.      *   Generics
  171.      *
  172.      ********************************************************************/
  173.  
  174.     ULONG XWPENTRY winhQueryWindowStyle(HWND hwnd);
  175.  
  176.     BOOL XWPENTRY winhEnableDlgItem(HWND hwndDlg, SHORT id, BOOL fEnable);
  177.  
  178.     BOOL XWPENTRY winhIsDlgItemEnabled(HWND hwndDlg, SHORT id);
  179.  
  180.     /* ******************************************************************
  181.      *
  182.      *   Menu helpers
  183.      *
  184.      ********************************************************************/
  185.  
  186.     #ifdef INCL_WINMENUS
  187.         BOOL XWPENTRY winhQueryMenuItem(HWND hwndMenu,
  188.                                         USHORT usItemID,
  189.                                         BOOL fSearchSubmenus,
  190.                                         PMENUITEM pmi);
  191.     #endif
  192.  
  193.     HWND XWPENTRY winhQuerySubmenu(HWND hMenu, SHORT sID);
  194.  
  195.     /*
  196.      * winhCreateEmptyMenu:
  197.      *      this macro creates an empty menu, which can
  198.      *      be used with winhInsertMenuItem etc. later.
  199.      *      Useful for creating popup menus on the fly.
  200.      *      Note that even though HWND_DESKTOP is specified
  201.      *      here as both the parent and the owner, the
  202.      *      actual owner and parent are specified later
  203.      *      with WinPopupMenu.
  204.      */
  205.  
  206.     #define winhCreateEmptyMenu()                                   \
  207.     WinCreateWindow(HWND_DESKTOP, WC_MENU, "", 0, 0, 0, 0, 0,       \
  208.                     HWND_DESKTOP, HWND_TOP, 0, 0, 0)
  209.  
  210.     SHORT XWPENTRY winhInsertMenuItem(HWND hwndMenu,
  211.                                       SHORT iPosition,
  212.                                       SHORT sItemId,
  213.                                       const char *pcszItemTitle,
  214.                                       SHORT afStyle,
  215.                                       SHORT afAttr);
  216.     typedef SHORT XWPENTRY WINHINSERTMENUITEM(HWND hwndMenu,
  217.                                               SHORT iPosition,
  218.                                               SHORT sItemId,
  219.                                               const char *pcszItemTitle,
  220.                                               SHORT afStyle,
  221.                                               SHORT afAttr);
  222.     typedef WINHINSERTMENUITEM *PWINHINSERTMENUITEM;
  223.  
  224.     HWND XWPENTRY winhInsertSubmenu(HWND hwndMenu,
  225.                                     ULONG iPosition,
  226.                                     SHORT sMenuId,
  227.                                     const char *pcszSubmenuTitle,
  228.                                     USHORT afMenuStyle,
  229.                                     SHORT sItemId,
  230.                                     const char *pcszItemTitle,
  231.                                     USHORT afItemStyle,
  232.                                     USHORT afAttribute);
  233.     typedef HWND XWPENTRY WINHINSERTSUBMENU(HWND hwndMenu,
  234.                                             ULONG iPosition,
  235.                                             SHORT sMenuId,
  236.                                             const char *pcszSubmenuTitle,
  237.                                             USHORT afMenuStyle,
  238.                                             SHORT sItemId,
  239.                                             const char *pcszItemTitle,
  240.                                             USHORT afItemStyle,
  241.                                             USHORT afAttribute);
  242.     typedef WINHINSERTSUBMENU *PWINHINSERTSUBMENU;
  243.  
  244.     BOOL XWPENTRY winhSetMenuCondCascade(HWND hwndMenu,
  245.                                          LONG lDefaultItem);
  246.  
  247.     /*
  248.      *@@ winhRemoveMenuItem:
  249.      *      removes a menu item (SHORT) from the
  250.      *      given menu (HWND). Returns the no. of
  251.      *      remaining menu items (SHORT).
  252.      *
  253.      *      This works for whole submenus too.
  254.      */
  255.  
  256.     #define winhRemoveMenuItem(hwndMenu, sItemId) \
  257.             (SHORT)WinSendMsg(hwndMenu, MM_REMOVEITEM, MPFROM2SHORT(sItemId, FALSE), 0)
  258.  
  259.     /*
  260.      *@@ winhDeleteMenuItem:
  261.      *      deleted a menu item (SHORT) from the
  262.      *      given menu (HWND). Returns the no. of
  263.      *      remaining menu items (SHORT).
  264.      *
  265.      *      As opposed to MM_REMOVEITEM, MM_DELETEITEM
  266.      *      frees submenus and bitmaps also.
  267.      *
  268.      *      This works for whole submenus too.
  269.      */
  270.  
  271.     #define winhDeleteMenuItem(hwndMenu, sItemId) \
  272.             (SHORT)WinSendMsg(hwndMenu, MM_DELETEITEM, MPFROM2SHORT(sItemId, FALSE), 0)
  273.  
  274.     SHORT XWPENTRY winhInsertMenuSeparator(HWND hMenu,
  275.                                            SHORT iPosition,
  276.                                            SHORT sId);
  277.  
  278.     #define COPYFL_STRIPTABS            0x0001
  279.  
  280.     BOOL XWPENTRY winhCopyMenuItem2(HWND hmenuTarget,
  281.                                     HWND hmenuSource,
  282.                                     USHORT usID,
  283.                                     SHORT sTargetPosition,
  284.                                     ULONG fl);
  285.  
  286.     BOOL XWPENTRY winhCopyMenuItem(HWND hmenuTarget,
  287.                                    HWND hmenuSource,
  288.                                    USHORT usID,
  289.                                    SHORT sTargetPosition);
  290.     typedef BOOL XWPENTRY WINHCOPYMENUITEM(HWND hmenuTarget,
  291.                                    HWND hmenuSource,
  292.                                    USHORT usID,
  293.                                    SHORT sTargetPosition);
  294.     typedef WINHCOPYMENUITEM *PWINHCOPYMENUITEM;
  295.  
  296.     HWND XWPENTRY winhMergeIntoSubMenu(HWND hmenuTarget,
  297.                                        SHORT sTargetPosition,
  298.                                        const char *pcszTitle,
  299.                                        SHORT sID,
  300.                                        HWND hmenuSource);
  301.     typedef HWND XWPENTRY WINHMERGEINTOSUBMENU(HWND hmenuTarget,
  302.                                        SHORT sTargetPosition,
  303.                                        const char *pcszTitle,
  304.                                        SHORT sID,
  305.                                        HWND hmenuSource);
  306.     typedef WINHMERGEINTOSUBMENU *PWINHMERGEINTOSUBMENU;
  307.  
  308.     ULONG XWPENTRY winhMergeMenus(HWND hmenuTarget,
  309.                                   SHORT sTargetPosition,
  310.                                   HWND hmenuSource,
  311.                                   ULONG fl);
  312.     typedef ULONG XWPENTRY WINHMERGEMENUS(HWND hmenuTarget,
  313.                                           SHORT sTargetPosition,
  314.                                           HWND hmenuSource,
  315.                                           ULONG fl);
  316.     typedef WINHMERGEMENUS *PWINHMERGEMENUS;
  317.  
  318.     PSZ XWPENTRY winhQueryMenuItemText(HWND hwndMenu,
  319.                                        USHORT usItemID);
  320.  
  321.     BOOL XWPENTRY winhAppend2MenuItemText(HWND hwndMenu,
  322.                                           USHORT usItemID,
  323.                                           const char *pcszAppend,
  324.                                           BOOL fTab);
  325.  
  326.     VOID XWPENTRY winhMenuRemoveEllipse(HWND hwndMenu,
  327.                                         USHORT usItemId);
  328.  
  329.     SHORT XWPENTRY winhQueryItemUnderMouse(HWND hwndMenu, POINTL *pptlMouse, RECTL *prtlItem);
  330.  
  331.     /* ******************************************************************
  332.      *
  333.      *   Slider helpers
  334.      *
  335.      ********************************************************************/
  336.  
  337.     HWND XWPENTRY winhReplaceWithLinearSlider(HWND hwndParent,
  338.                                               HWND hwndOwner,
  339.                                               HWND hwndInsertAfter,
  340.                                               ULONG ulID,
  341.                                               ULONG ulSliderStyle,
  342.                                               ULONG ulTickCount);
  343.  
  344.     BOOL XWPENTRY winhSetSliderTicks(HWND hwndSlider,
  345.                                      MPARAM mpEveryOther1,
  346.                                      ULONG ulPixels1,
  347.                                      MPARAM mpEveryOther2,
  348.                                      ULONG ulPixels2);
  349.     typedef BOOL XWPENTRY WINHSETSLIDERTICKS(HWND hwndSlider,
  350.                                              MPARAM mpEveryOther1,
  351.                                              ULONG ulPixels1,
  352.                                              MPARAM mpEveryOther2,
  353.                                              ULONG ulPixels2);
  354.     typedef WINHSETSLIDERTICKS *PWINHSETSLIDERTICKS;
  355.  
  356.     /*
  357.      * winhSetSliderArmPosition:
  358.      *      this moves the slider arm in a given
  359.      *      linear slider.
  360.      *
  361.      *      usMode can be one of the following:
  362.      *      --  SMA_RANGEVALUE: usOffset is in pixels
  363.      *          from the slider's home position.
  364.      *      --  SMA_INCREMENTVALUE: usOffset is in
  365.      *          units of the slider's primary scale.
  366.      */
  367.  
  368.     #define winhSetSliderArmPosition(hwndSlider, usMode, usOffset)  \
  369.             WinSendMsg(hwndSlider, SLM_SETSLIDERINFO,               \
  370.                    MPFROM2SHORT(SMA_SLIDERARMPOSITION,              \
  371.                      usMode),                                       \
  372.                    MPFROMSHORT(usOffset))
  373.  
  374.     /*
  375.      * winhQuerySliderArmPosition:
  376.      *      reverse to the previous, this returns a
  377.      *      slider arm position (as a LONG value).
  378.      */
  379.  
  380.     #define winhQuerySliderArmPosition(hwndSlider, usMode)          \
  381.             (LONG)(WinSendMsg(hwndSlider,                           \
  382.                               SLM_QUERYSLIDERINFO,                  \
  383.                               MPFROM2SHORT(SMA_SLIDERARMPOSITION,   \
  384.                                            usMode),                 \
  385.                               0))
  386.  
  387.     HWND XWPENTRY winhReplaceWithCircularSlider(HWND hwndParent,
  388.                                                 HWND hwndOwner,
  389.                                                 HWND hwndInsertAfter,
  390.                                                 ULONG ulID,
  391.                                                 ULONG ulSliderStyle,
  392.                                                 SHORT sMin,
  393.                                                 SHORT sMax,
  394.                                                 USHORT usIncrement,
  395.                                                 USHORT usTicksEvery);
  396.  
  397.     /* ******************************************************************
  398.      *
  399.      *   Spin button helpers
  400.      *
  401.      ********************************************************************/
  402.  
  403.     VOID XWPENTRY winhSetDlgItemSpinData(HWND hwndDlg,
  404.                                          ULONG idSpinButton,
  405.                                          ULONG min,
  406.                                          ULONG max,
  407.                                          ULONG current);
  408.     typedef VOID XWPENTRY WINHSETDLGITEMSPINDATA(HWND hwndDlg,
  409.                                                  ULONG idSpinButton,
  410.                                                  ULONG min,
  411.                                                  ULONG max,
  412.                                                  ULONG current);
  413.     typedef WINHSETDLGITEMSPINDATA *PWINHSETDLGITEMSPINDATA;
  414.  
  415.     LONG XWPENTRY winhAdjustDlgItemSpinData(HWND hwndDlg,
  416.                                             USHORT usItemID,
  417.                                             LONG lGrid,
  418.                                             USHORT usNotifyCode);
  419.     typedef LONG XWPENTRY WINHADJUSTDLGITEMSPINDATA(HWND hwndDlg,
  420.                                                     USHORT usItemID,
  421.                                                     LONG lGrid,
  422.                                                     USHORT usNotifyCode);
  423.     typedef WINHADJUSTDLGITEMSPINDATA *PWINHADJUSTDLGITEMSPINDATA;
  424.  
  425.     /* ******************************************************************
  426.      *
  427.      *   Entry field helpers
  428.      *
  429.      ********************************************************************/
  430.  
  431.     /*
  432.      * winhSetEntryFieldLimit:
  433.      *      sets the maximum length for the entry field
  434.      *      (EM_SETTEXTLIMIT message).
  435.      *
  436.      *      PMREF doesn't say this, but the limit does
  437.      *      _not_ include the null-terminator. That is,
  438.      *      if you specify "12" characters here, you can
  439.      *      really enter 12 characters.
  440.      *
  441.      *      The default length is 30 characters, I think.
  442.      */
  443.  
  444.     #define winhSetEntryFieldLimit(hwndEntryField, usLength)        \
  445.             WinSendMsg(hwndEntryField, EM_SETTEXTLIMIT, (MPARAM)(usLength), (MPARAM)0)
  446.  
  447.     /*
  448.      *@@ winhEntryFieldSelectAll:
  449.      *      this selects the entire text in the entry field.
  450.      *      Useful when the thing gets the focus.
  451.      */
  452.  
  453.     #define winhEntryFieldSelectAll(hwndEntryField)                 \
  454.             WinSendMsg(hwndEntryField, EM_SETSEL, MPFROM2SHORT(0, 10000), MPNULL)
  455.  
  456.     /*
  457.      *@@ winhHasEntryFieldChanged:
  458.      *      this queries whether the entry field's contents
  459.      *      have changed (EM_QUERYCHANGED message).
  460.      *
  461.      *      This returns TRUE if changes have occured since
  462.      *      the last time this message or WM_QUERYWINDOWPARAMS
  463.      *      (WinQueryWindowText) was received.
  464.      */
  465.  
  466.     #define winhHasEntryFieldChanged(hwndEntryField)                \
  467.             (BOOL)WinSendMsg(hwndEntryField, EM_QUERYCHANGED, (MPARAM)0, (MPARAM)0)
  468.  
  469.     /* ******************************************************************
  470.      *
  471.      *   List box helpers
  472.      *
  473.      ********************************************************************/
  474.  
  475.     /*  The following macros are defined in the OS/2 headers for
  476.         list boxes:
  477.  
  478.         LONG WinQueryLboxCount(HWND hwndLbox);
  479.                     // wrapper around LM_QUERYITEMCOUNT;
  480.                     // list box item count
  481.  
  482.         SHORT WinQueryLboxItemTextLength(HWND hwndLbox,
  483.                                          SHORT index); // item index, starting from 0
  484.                     // wrapper around LM_QUERYITEMTEXTLENGTH;
  485.                     // returns length of item text, excluding NULL character
  486.  
  487.         LONG WinQueryLboxItemText(HWND hwndLbox,
  488.                                   SHORT index,      // item index, starting from 0
  489.                                   PSZ psz,          // buffer
  490.                                   PSZ cchMax);      // size of buffer, incl. null
  491.                     // wrapper around LM_QUERYITEMTEXT;
  492.                     // returns length of item text, excluding NULL character
  493.  
  494.         BOOL WinSetLboxItemText(HWND hwndLbox,
  495.                                 LONG index,
  496.                                 PSZ psz);
  497.                     // wrapper around LM_SETITEMTEXT
  498.  
  499.         LONG WinInsertLboxItem(HWND hwndLbox,
  500.                                LONG index,          // new item index, starting from 0
  501.                                                     // or LIT_END
  502.                                                     // or LIT_SORTASCENDING
  503.                                                     // or LIT_SORTDESCENDING
  504.                                PSZ psz)
  505.                     // wrapper around LM_INSERTITEM;
  506.                     // returns LIT_MEMERROR, LIT_ERROR, or zero-based index
  507.  
  508.         LONG WinDeleteLboxItem(HWND hwndLbox,
  509.                                LONG index);         // item index, starting from 0
  510.  
  511.         LONG WinQueryLboxSelectedItem(HWND hwndLbox);
  512.                     // wrapper around LM_QUERYSELECTION;
  513.                     // works with single selection only,
  514.                     // use winhQueryLboxSelectedItem instead
  515.     */
  516.  
  517.     /*
  518.      * winhQueryLboxItemCount:
  519.      *      returns the no. of items in the listbox
  520.      *      as a SHORT.
  521.      *
  522.      *added V0.9.1 (99-12-14) [umoeller]
  523.      */
  524.  
  525.     // #define winhQueryLboxItemCount(hwndListBox)
  526.     // (SHORT)WinSendMsg(hwndListBox, LM_QUERYITEMCOUNT, 0, 0)
  527.  
  528.     // removed, use WinQueryLboxCount
  529.  
  530.     /*
  531.      *@@ winhDeleteAllItems:
  532.      *      deletes all list box items. Returns
  533.      *      a BOOL.
  534.      *
  535.      *@@added V0.9.1 (99-12-14) [umoeller]
  536.      */
  537.  
  538.     #define winhDeleteAllItems(hwndListBox)                     \
  539.         (BOOL)WinSendMsg(hwndListBox,                           \
  540.                          LM_DELETEALL, 0, 0)
  541.     /*
  542.      *@@ winhQueryLboxSelectedItem:
  543.      *      this queries the next selected list box item.
  544.      *      For the first call, set sItemStart to LIT_FIRST;
  545.      *      then repeat the call with sItemStart set to
  546.      *      the previous return value until this returns
  547.      *      LIT_NONE.
  548.      *
  549.      *      Example:
  550.      +          SHORT sItemStart = LIT_FIRST;
  551.      +          while (TRUE)
  552.      +          {
  553.      +              sItemStart = winhQueryLboxSelectedItem(hwndListBox,
  554.      +                                                     sItemStart)
  555.      +              if (sItemStart == LIT_NONE)
  556.      +                  break;
  557.      +              ...
  558.      +          }
  559.      *
  560.      *      To have the cursored item returned, use LIT_CURSOR.
  561.      *
  562.      *      For single selection, you can also use
  563.      *      WinQueryLboxSelectedItem from the OS/2 PM headers.
  564.      */
  565.  
  566.     #define winhQueryLboxSelectedItem(hwndListBox, sItemStart) \
  567.             SHORT1FROMMR(WinSendMsg(hwndListBox,                    \
  568.                             LM_QUERYSELECTION,                 \
  569.                             (MPARAM)(sItemStart),              \
  570.                             MPNULL))
  571.  
  572.     /*
  573.      *@@ winhSetLboxSelectedItem:
  574.      *      selects a list box item.
  575.      *      This works for both single-selection and
  576.      *      multiple-selection listboxes.
  577.      *      In single-selection listboxes, if an item
  578.      *      is selected (fSelect == TRUE), the previous
  579.      *      item is automatically deselected.
  580.      *      Note that (BOOL)fSelect is ignored if
  581.      *      sItemIndex == LIT_NONE.
  582.      */
  583.  
  584.     #define winhSetLboxSelectedItem(hwndListBox, sItemIndex, fSelect)   \
  585.             (BOOL)(WinSendMsg(hwndListBox,                              \
  586.                             LM_SELECTITEM,                              \
  587.                             (MPARAM)(sItemIndex),                       \
  588.                             (MPARAM)(fSelect)))
  589.  
  590.     ULONG XWPENTRY winhLboxSelectAll(HWND hwndListBox, BOOL fSelect);
  591.  
  592.     /*
  593.      * winhSetLboxItemHandle:
  594.      *      sets the "item handle" for the specified sItemIndex.
  595.      *      See LM_SETITEMHANDLE in PMREF for details.
  596.      */
  597.  
  598.     #define winhSetLboxItemHandle(hwndListBox, sItemIndex, ulHandle)    \
  599.             (BOOL)(WinSendMsg(hwndListBox, LM_SETITEMHANDLE,            \
  600.                               (MPARAM)(sItemIndex),                     \
  601.                               (MPARAM)ulHandle))
  602.  
  603.     /*
  604.      * winhQueryLboxItemHandle:
  605.      *      the reverse to the previous. Returns a ULONG.
  606.      */
  607.  
  608.     #define winhQueryLboxItemHandle(hwndListBox, sItemIndex)            \
  609.             (ULONG)WinSendMsg(hwndListBox, LM_QUERYITEMHANDLE,          \
  610.                               MPFROMSHORT(sItemIndex), (MPARAM)NULL)
  611.  
  612.     PSZ XWPENTRY winhQueryLboxItemText(HWND hwndListbox, SHORT sIndex);
  613.  
  614.     BOOL XWPENTRY winhMoveLboxItem(HWND hwndSource,
  615.                                    SHORT sSourceIndex,
  616.                                    HWND hwndTarget,
  617.                                    SHORT sTargetIndex,
  618.                                    BOOL fSelectTarget);
  619.  
  620.     ULONG XWPENTRY winhLboxFindItemFromHandle(HWND hwndListBox,
  621.                                               ULONG ulHandle);
  622.  
  623.     /* ******************************************************************
  624.      *
  625.      *   Scroll bar helpers
  626.      *
  627.      ********************************************************************/
  628.  
  629.     BOOL XWPENTRY winhUpdateScrollBar(HWND hwndScrollBar,
  630.                                       ULONG ulWinPels,
  631.                                       ULONG ulViewportPels,
  632.                                       ULONG ulCurUnitOfs,
  633.                                       BOOL fAutoHide);
  634.  
  635.     BOOL XWPENTRY winhHandleScrollMsg(HWND hwnd2Scroll,
  636.                                       HWND hwndScrollBar,
  637.                                       PULONG pulCurPelsOfs,
  638.                                       PRECTL prcl2Scroll,
  639.                                       LONG ulViewportPels,
  640.                                       USHORT usLineStepUnits,
  641.                                       ULONG msg,
  642.                                       MPARAM mp2);
  643.  
  644.     BOOL XWPENTRY winhProcessScrollChars(HWND hwndClient,
  645.                                          HWND hwndVScroll,
  646.                                          HWND hwndHScroll,
  647.                                          MPARAM mp1,
  648.                                          MPARAM mp2,
  649.                                          ULONG ulVertMax,
  650.                                          ULONG ulHorzMax);
  651.  
  652.     /* ******************************************************************
  653.      *
  654.      *   Window positioning helpers
  655.      *
  656.      ********************************************************************/
  657.  
  658.     BOOL XWPENTRY winhSaveWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey);
  659.  
  660.     BOOL XWPENTRY winhRestoreWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey, ULONG fl);
  661.  
  662.     #define XAC_MOVEX       0x0001
  663.     #define XAC_MOVEY       0x0002
  664.     #define XAC_SIZEX       0x0004
  665.     #define XAC_SIZEY       0x0008
  666.  
  667.     /*
  668.      *@@ XADJUSTCTRLS:
  669.      *
  670.      */
  671.  
  672.     typedef struct _XADJUSTCTRLS
  673.     {
  674.         BOOL        fInitialized;
  675.         SWP         swpMain;            // SWP for main window
  676.         SWP         *paswp;             // pointer to array of control SWP structs
  677.     } XADJUSTCTRLS, *PXADJUSTCTRLS;
  678.  
  679.     BOOL XWPENTRY winhAdjustControls(HWND hwndDlg,
  680.                                      const MPARAM *pmpFlags,
  681.                                      ULONG ulCount,
  682.                                      PSWP pswpNew,
  683.                                      PXADJUSTCTRLS pxac);
  684.  
  685.     void XWPENTRY winhCenterWindow(HWND hwnd);
  686.     typedef void XWPENTRY WINHCENTERWINDOW(HWND hwnd);
  687.     typedef WINHCENTERWINDOW *PWINHCENTERWINDOW;
  688.  
  689.     #define PLF_SMART               0x0001
  690.  
  691.     BOOL winhPlaceBesides(HWND hwnd,
  692.                           HWND hwndRelative,
  693.                           ULONG fl);
  694.  
  695.     HWND XWPENTRY winhFindWindowBelow(HWND hwndFind);
  696.  
  697.     /* ******************************************************************
  698.      *
  699.      *   Presparams helpers
  700.      *
  701.      ********************************************************************/
  702.  
  703.     PSZ XWPENTRY winhQueryWindowFont(HWND hwnd);
  704.     typedef PSZ XWPENTRY WINHQUERYWINDOWFONT(HWND hwnd);
  705.     typedef WINHQUERYWINDOWFONT *PWINHQUERYWINDOWFONT;
  706.  
  707.     BOOL XWPENTRY winhSetWindowFont(HWND hwnd, const char *pcszFont);
  708.     typedef BOOL XWPENTRY WINHSETWINDOWFONT(HWND hwnd, const char *pcszFont);
  709.     typedef WINHSETWINDOWFONT *PWINHSETWINDOWFONT;
  710.  
  711.     /*
  712.      *@@ winhSetDlgItemFont:
  713.      *      invokes winhSetWindowFont on a dialog
  714.      *      item.
  715.      *
  716.      *      Returns TRUE if successful or FALSE otherwise.
  717.      *
  718.      *@@added V0.9.0
  719.      */
  720.  
  721.     #define winhSetDlgItemFont(hwnd, usId, pszFont) \
  722.             (winhSetWindowFont(WinWindowFromID(hwnd, usId), pszFont))
  723.  
  724.     ULONG XWPENTRY winhSetControlsFont(HWND hwndDlg, SHORT usIDMin, SHORT usIDMax, const char *pcszFont);
  725.  
  726.     #ifdef INCL_WINSYS
  727.         BOOL XWPENTRY winhStorePresParam(PPRESPARAMS *pppp,
  728.                                          ULONG ulAttrType,
  729.                                          ULONG cbData,
  730.                                          PVOID pData);
  731.     #endif
  732.  
  733.     LONG XWPENTRY winhQueryPresColor(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
  734.     typedef LONG XWPENTRY WINHQUERYPRESCOLOR(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
  735.     typedef WINHQUERYPRESCOLOR *PWINHQUERYPRESCOLOR;
  736.  
  737.     LONG XWPENTRY winhQueryPresColor2(HWND hwnd,
  738.                                       ULONG ulppRGB,
  739.                                       ULONG ulppIndex,
  740.                                       BOOL fInherit,
  741.                                       LONG lSysColor);
  742.  
  743.     BOOL XWPENTRY winhSetPresColor(HWND hwnd, ULONG ulIndex, LONG lColor);
  744.  
  745.     /* ******************************************************************
  746.      *
  747.      *   Help instance helpers
  748.      *
  749.      ********************************************************************/
  750.  
  751.     #ifdef INCL_WINHELP
  752.         HWND XWPENTRY winhCreateHelp(HWND hwndFrame,
  753.                                      const char *pcszFileName,
  754.                                      HMODULE hmod,
  755.                                      PHELPTABLE pHelpTable,
  756.                                      const char *pcszWindowTitle);
  757.  
  758.         ULONG winhDisplayHelpPanel(HWND hwndHelpInstance,
  759.                                    ULONG ulHelpPanel);
  760.  
  761.         void XWPENTRY winhDestroyHelp(HWND hwndHelp, HWND hwndFrame);
  762.     #endif
  763.  
  764.     /* ******************************************************************
  765.      *
  766.      *   Application control
  767.      *
  768.      ********************************************************************/
  769.  
  770.     BOOL XWPENTRY winhAnotherInstance(const char *pcszSemName, BOOL fSwitch);
  771.  
  772.     HSWITCH XWPENTRY winhAddToTasklist(HWND hwnd, HPOINTER hIcon);
  773.  
  774.     /* ******************************************************************
  775.      *
  776.      *   Miscellaneous
  777.      *
  778.      ********************************************************************/
  779.  
  780.     VOID XWPENTRY winhFree(PVOID p);
  781.     typedef VOID XWPENTRY WINHFREE(PVOID p);
  782.     typedef WINHFREE *PWINHFREE;
  783.  
  784.     HAB XWPENTRY winhMyAnchorBlock(VOID);
  785.     typedef HAB XWPENTRY WINHMYANCHORBLOCK(VOID);
  786.     typedef WINHMYANCHORBLOCK *PWINHMYANCHORBLOCK;
  787.  
  788.     VOID XWPENTRY winhSleep(ULONG ulSleep);
  789.  
  790.     #define WINH_FOD_SAVEDLG        0x0001
  791.     #define WINH_FOD_INILOADDIR     0x0010
  792.     #define WINH_FOD_INISAVEDIR     0x0020
  793.  
  794.     BOOL XWPENTRY winhFileDlg(HWND hwndOwner,
  795.                               PSZ pszFile,
  796.                               ULONG flFlags,
  797.                               HINI hini,
  798.                               const char *pcszApplication,
  799.                               const char *pcszKey);
  800.  
  801.     HPOINTER XWPENTRY winhSetWaitPointer(VOID);
  802.  
  803.     PSZ XWPENTRY winhQueryWindowText(HWND hwnd);
  804.  
  805.     BOOL XWPENTRY winhSetWindowText(HWND hwnd,
  806.                                     const char *pcszFormat,
  807.                                     ...);
  808.  
  809.     /*
  810.      *@@ winhQueryDlgItemText:
  811.      *      like winhQueryWindowText, but for the dialog item
  812.      *      in hwnd which has the ID usItemID.
  813.      */
  814.  
  815.     #define winhQueryDlgItemText(hwnd, usItemID) winhQueryWindowText(WinWindowFromID(hwnd, usItemID))
  816.  
  817.     BOOL XWPENTRY winhReplaceWindowText(HWND hwnd,
  818.                                         const char *pcszSearch,
  819.                                         const char *pcszReplaceWith);
  820.  
  821.     ULONG XWPENTRY winhCenteredDlgBox(HWND hwndParent, HWND hwndOwner,
  822.                   PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
  823.     typedef ULONG XWPENTRY WINHCENTEREDDLGBOX(HWND hwndParent, HWND hwndOwner,
  824.                   PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
  825.     typedef WINHCENTEREDDLGBOX *PWINHCENTEREDDLGBOX;
  826.  
  827.     ULONG XWPENTRY winhEnableControls(HWND hwndDlg,
  828.                                       USHORT usIDFirst,
  829.                                       USHORT usIDLast,
  830.                                       BOOL fEnable);
  831.  
  832.     ULONG winhEnableControls2(HWND hwndDlg,
  833.                               const ULONG *paulIDs,
  834.                               ULONG cIDs,
  835.                               BOOL fEnable);
  836.  
  837.     HWND XWPENTRY winhCreateStdWindow(HWND hwndFrameParent,
  838.                                       PSWP pswpFrame,
  839.                                       ULONG flFrameCreateFlags,
  840.                                       ULONG ulFrameStyle,
  841.                                       const char *pcszFrameTitle,
  842.                                       ULONG ulResourcesID,
  843.                                       const char *pcszClassClient,
  844.                                       ULONG flStyleClient,
  845.                                       ULONG ulID,
  846.                                       PVOID pClientCtlData,
  847.                                       PHWND phwndClient);
  848.  
  849.     HWND XWPENTRY winhCreateObjectWindow(const char *pcszWindowClass,
  850.                                          PVOID pvCreateParam);
  851.  
  852.     HWND XWPENTRY winhCreateControl(HWND hwndParentAndOwner,
  853.                                     const char *pcszClass,
  854.                                     const char *pcszText,
  855.                                     ULONG ulStyle,
  856.                                     ULONG ulID);
  857.  
  858.     VOID XWPENTRY winhRepaintWindows(HWND hwndParent);
  859.  
  860.     HMQ XWPENTRY winhFindMsgQueue(PID pid, TID tid, HAB* phab);
  861.  
  862.     VOID XWPENTRY winhFindPMErrorWindows(HWND *phwndHardError, HWND *phwndSysError);
  863.  
  864.     HWND XWPENTRY winhCreateFakeDesktop(HWND hwndSibling);
  865.  
  866.     BOOL XWPENTRY winhAssertWarp4Notebook(HWND hwndDlg,
  867.                                           USHORT usIdThreshold);
  868.  
  869.     ULONG XWPENTRY winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd);
  870.  
  871.     #ifdef INCL_WINSWITCHLIST
  872.         PSWBLOCK XWPENTRY winhQuerySwitchList(HAB hab);
  873.         typedef PSWBLOCK XWPENTRY WINHQUERYSWITCHLIST(HAB hab);
  874.         typedef WINHQUERYSWITCHLIST *PWINHQUERYSWITCHLIST;
  875.  
  876.         HSWITCH XWPENTRY winhHSWITCHfromHAPP(HAPP happ);
  877.     #endif
  878.  
  879.     HWND XWPENTRY winhQueryTasklistWindow(VOID);
  880.     typedef HWND XWPENTRY WINHQUERYTASKLISTWINDOW(VOID);
  881.     typedef WINHQUERYTASKLISTWINDOW *PWINHQUERYTASKLISTWINDOW;
  882.  
  883.     VOID XWPENTRY winhKillTasklist(VOID);
  884.  
  885.     ULONG XWPENTRY winhQueryPendingSpoolJobs(VOID);
  886.  
  887.     VOID XWPENTRY winhSetNumLock(BOOL fState);
  888.  
  889.     /*
  890.      *@@ winhQueryScreenCX:
  891.      *      helper macro for getting the screen width.
  892.      */
  893.  
  894.     #define winhQueryScreenCX() (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN))
  895.  
  896.     /*
  897.      *@@ winhQueryScreenCY:
  898.      *      helper macro for getting the screen height.
  899.      */
  900.  
  901.     #define winhQueryScreenCY() (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN))
  902.  
  903.     /* ******************************************************************
  904.      *
  905.      *   Extended frame
  906.      *
  907.      ********************************************************************/
  908.  
  909.     #define XFCF_STATUSBAR          0x0001
  910.  
  911.     #define FID_STATUSBAR           0x8100
  912.  
  913.     /*
  914.      *@@ EXTFRAMECDATA:
  915.      *
  916.      *@@added V0.9.16 (2001-09-29) [umoeller]
  917.      */
  918.  
  919.     typedef struct _EXTFRAMECDATA
  920.     {
  921.         PSWP        pswpFrame;            // in: frame wnd pos
  922.         ULONG       flFrameCreateFlags;  // in: FCF_* flags
  923.         ULONG       flExtFlags;          // in: XFCF_* flags
  924.         ULONG       ulFrameStyle;        // in: WS_* flags (e.g. WS_VISIBLE, WS_ANIMATE)
  925.         const char  *pcszFrameTitle; // in: frame title (title bar)
  926.         ULONG       ulResourcesID;       // in: according to FCF_* flags
  927.         const char  *pcszClassClient; // in: client class name
  928.         ULONG       flStyleClient;       // in: client style
  929.         ULONG       ulID;                // in: frame window ID
  930.         PVOID       pClientCtlData;      // in: pCtlData structure pointer for client
  931.     } EXTFRAMECDATA, *PEXTFRAMECDATA;
  932.  
  933.     /*
  934.      *@@ EXTFRAMEDATA:
  935.      *
  936.      *@@added V0.9.16 (2001-09-29) [umoeller]
  937.      */
  938.  
  939.     typedef struct _EXTFRAMEDATA
  940.     {
  941.         EXTFRAMECDATA   CData;
  942.  
  943.         PFNWP           pfnwpOrig;      // original frame wnd proc from subclassing
  944.  
  945.         PVOID           pvUser;         // more data for user (e.g. for additional subclassing)
  946.  
  947.     } EXTFRAMEDATA, *PEXTFRAMEDATA;
  948.  
  949.     HWND winhCreateStatusBar(HWND hwndFrame,
  950.                              HWND hwndOwner,
  951.                              const char *pcszText,
  952.                              const char *pcszFont,
  953.                              LONG lColor);
  954.  
  955.     HWND winhCreateExtStdWindow(PEXTFRAMECDATA pData,
  956.                                 PHWND phwndClient);
  957.  
  958.     /* ******************************************************************
  959.      *
  960.      *   WPS Class List helpers
  961.      *
  962.      ********************************************************************/
  963.  
  964.     PBYTE XWPENTRY winhQueryWPSClassList(VOID);
  965.  
  966.     PBYTE XWPENTRY winhQueryWPSClass(PBYTE pObjClass, const char *pszClass);
  967.  
  968.     APIRET XWPENTRY winhRegisterClass(const char* pcszClassName,
  969.                                       const char* pcszModule,
  970.                                       PSZ pszBuf,
  971.                                       ULONG cbBuf);
  972.  
  973.     BOOL XWPENTRY winhIsClassRegistered(const char *pcszClass);
  974.  
  975.     ULONG XWPENTRY winhResetWPS(HAB hab);
  976.  
  977. #endif
  978.  
  979. #if __cplusplus
  980. }
  981. #endif
  982.  
  983.