home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: WPS_PM / WPS_PM.zip / xfld085s.zip / helpers / winh.h < prev    next >
C/C++ Source or Header  |  1999-02-23  |  7KB  |  180 lines

  1.  
  2. /*
  3.  * winh.h:
  4.  *      header file for winh.h, which contains Presentation Manager
  5.  *      helper functions that are  independent of a single application,
  6.  *      i.e. these can be  used w/out the rest of the XFolder source in
  7.  *      any PM program.
  8.  *
  9.  *      Copyright (C) 1997-99 Ulrich Möller.
  10.  *      This file is part of the XFolder source package.
  11.  *      XFolder is free software; you can redistribute it and/or modify
  12.  *      it under the terms of the GNU General Public License as published
  13.  *      by the Free Software Foundation, in version 2 as it comes in the
  14.  *      "COPYING" file of the XFolder main distribution.
  15.  *      This program is distributed in the hope that it will be useful,
  16.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  *      GNU General Public License for more details.
  19.  */
  20.  
  21. #if __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. #ifndef WINH_HEADER_INCLUDED
  26.     #define WINH_HEADER_INCLUDED
  27.  
  28.     /*
  29.      *  Here come some monster macros for
  30.      *  frequently needed functions.
  31.      */
  32.  
  33.     #define DebugBox(title, text) \
  34.              WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,   \
  35.                 (PSZ)text, (PSZ)title,    \
  36.                 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE)
  37.  
  38.     #define YesNoBox(title, text) \
  39.              WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,   \
  40.                 (PSZ)text, (PSZ)title,    \
  41.                 0, MB_YESNO | MB_ICONQUESTION | MB_MOVEABLE)
  42.  
  43.     #define MPNULL                 (MPFROMP(NULL))
  44.     #define MPZERO                 (MPFROMSHORT(0))
  45.     #define MRTRUE                 (MRFROMSHORT((SHORT) TRUE))
  46.     #define MRFALSE                (MRFROMSHORT((SHORT) FALSE))
  47.     #define BM_UNCHECKED           0   // for checkboxes: disabled
  48.     #define BM_CHECKED             1   // for checkboses: enabled
  49.     #define BM_INDETERMINATE       2   // for tri-state checkboxes: indeterminate
  50.  
  51.     #define winhSetDlgItemChecked(hwnd, id, bCheck) \
  52.             WinSendDlgItemMsg(hwnd, id, BM_SETCHECK, MPFROMSHORT(bCheck), MPNULL)
  53.  
  54.     #define winhIsDlgItemChecked(hwnd, id) \
  55.             (SHORT1FROMMR(WinSendDlgItemMsg((hwnd), (id), BM_QUERYCHECK, MPNULL, MPNULL)))
  56.  
  57.     #define winhSetMenuItemChecked(hwndMenu, usId, bCheck) \
  58.             WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(usId, TRUE), \
  59.                     MPFROM2SHORT(MIA_CHECKED, ((bCheck) ? MIA_CHECKED : FALSE)))
  60.  
  61.     #define winhShowDlgItem(hwnd, id, show) \
  62.             WinShowWindow(WinWindowFromID(hwnd, id), show)
  63.  
  64.     #define winhSetWindowFont(hwnd, szFont)\
  65.             (WinSetPresParam(hwnd),\
  66.             PP_FONTNAMESIZE, (ULONG)strlen(szFont)+1, szFont))
  67.  
  68.     #define winhSetDlgItemFont(hwnd, usId, szFont)\
  69.             (WinSetPresParam(WinWindowFromID(hwnd, usId),\
  70.             PP_FONTNAMESIZE, (ULONG)strlen(szFont)+1, szFont))
  71.  
  72.     #define winhEnableDlgItem(hwndDlg, ulId, Enable) \
  73.             WinEnableWindow(WinWindowFromID(hwndDlg, ulId), Enable)
  74.  
  75.     #define winhIsDlgItemEnabled(hwndDlg, ulId) \
  76.             WinIsWindowEnabled(WinWindowFromID(hwndDlg, ulId))
  77.  
  78.     #define winhSetDlgItemFocus(hwndDlg, ulId) \
  79.             WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwndDlg, ulId))
  80.  
  81.     #define winhQueryCnrInfo(hwndCnr, CnrInfo) \
  82.             WinSendMsg(hwndCnr, CM_QUERYCNRINFO,  \
  83.                     (MPARAM)&CnrInfo,             \
  84.                     (MPARAM)sizeof(CnrInfo))
  85.  
  86.     #define winhCnrSelectRecord(hwndCnr, precc) \
  87.             WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, \
  88.                     (MPARAM)precc, \
  89.                     MPFROM2SHORT(TRUE, CRA_SELECTED))
  90.  
  91.     SHORT winhInsertMenuItem(HWND hwndMenu,
  92.                              SHORT iPosition,
  93.  
  94.                              SHORT sItemId,
  95.                              PSZ pszItemTitle,
  96.                              SHORT afStyle,
  97.                              SHORT afAttr);
  98.  
  99.     HWND winhInsertSubmenu(HWND hwndMenu,
  100.                            ULONG iPosition,
  101.                            SHORT sMenuId,
  102.                            PSZ pszSubmenuTitle,
  103.                            USHORT afMenuStyle,
  104.  
  105.                            SHORT sItemId,
  106.  
  107.                            PSZ pszItemTitle,
  108.                            USHORT afItemStyle,
  109.                            USHORT afAttribute);
  110.  
  111.     SHORT winhInsertMenuSeparator(HWND hMenu,
  112.                                   SHORT iPosition,
  113.                                   SHORT sId);
  114.  
  115.     VOID winhMenuRemoveEllipse(HWND hwndMenu,
  116.                                USHORT usItemId);
  117.  
  118.     VOID winhSetDlgItemSpinData(HWND hwndDlg,
  119.                                ULONG idSpinButton,
  120.                                ULONG min,
  121.                                ULONG max,
  122.                                ULONG current);
  123.  
  124.     LONG winhAdjustDlgItemSpinData(HWND hwndDlg,
  125.                                    USHORT usItemID,
  126.                                    LONG lGrid,
  127.                                    USHORT usNotifyCode);
  128.  
  129.     ULONG winhCnrScrollToRecord(HWND hwndCnr, PRECORDCORE pRec,
  130.                                 ULONG fsExtent, BOOL KeepParent);
  131.  
  132.     PRECORDCORE winhCnrAllocRecord(HWND hwndCnr, ULONG cbrecc);
  133.  
  134.     PRECORDCORE winhCnrInsertRecord(HWND hwndCnr, PRECORDCORE preccParent, PRECORDCORE precc,
  135.                 PSZ pszText, ULONG flRecordAttr);
  136.  
  137.     BOOL winhSaveWindowPos(HWND hwnd,
  138.                            HINI hIni,
  139.                            PSZ pszApp,
  140.                            PSZ pszKey);
  141.  
  142.     BOOL winhRestoreWindowPos(HWND hwnd,
  143.                            HINI hIni,
  144.                            PSZ pszApp,
  145.                            PSZ pszKey,
  146.                            ULONG fl);
  147.  
  148.     void winhCenterWindow(HWND hwnd);
  149.  
  150.     ULONG winhCenteredDlgBox(HWND hwndParent, HWND hwndOwner,
  151.                   PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
  152.  
  153.     LONG winhQueryPresColor(HWND hwnd,
  154.                             ULONG ulPP,
  155.                             PSZ pszKeyName,
  156.                             PSZ pszDefault);
  157.  
  158.     HWND winhCreateFakeDesktop(HWND hwndSibling);
  159.  
  160.     HWND winhQueryCnrFromFrame(HWND hwndFrame);
  161.  
  162.     BOOL winhAssertWarp4Notebook(HWND hwndDlg,
  163.                         USHORT usIdThreshold,    // in: ID threshold
  164.                         ULONG ulDownUnits);      // in: dialog units or 0
  165.  
  166.     SHORT winhQueryItemUnderMouse(HWND hwndMenu, POINTL *pptlMouse, RECTL *prtlItem);
  167.  
  168.     ULONG winhDrawFormattedText(HPS hps, PRECTL prcl, PSZ pszText, ULONG flCmd);
  169.  
  170.     VOID winhKillTasklist(VOID);
  171.  
  172.     ULONG winhQueryPendingSpoolJobs(VOID);
  173.  
  174. #endif
  175.  
  176. #if __cplusplus
  177. }
  178. #endif
  179.  
  180.