Ignore:
Timestamp:
Dec 9, 2000, 8:19:42 PM (25 years ago)
Author:
umoeller
Message:

Major updates; timers, LVM, miscellaneous.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/winh.c

    r13 r14  
    2020/*
    2121 *      Copyright (C) 1997-2000 Ulrich M”ller.
    22  *      This file is part of the XWorkplace source package.
    23  *      XWorkplace is free software; you can redistribute it and/or modify
     22 *      This file is part of the "XWorkplace helpers" source package.
     23 *      This is free software; you can redistribute it and/or modify
    2424 *      it under the terms of the GNU General Public License as published
    2525 *      by the Free Software Foundation, in version 2 as it comes in the
     
    3636    // as unsigned char
    3737
     38#define INCL_DOSPROCESS
     39#define INCL_DOSMODULEMGR
     40#define INCL_DOSSEMAPHORES
     41#define INCL_DOSDEVICES
    3842#define INCL_DOSDEVIOCTL
    39 #define INCL_DOS
    4043#define INCL_DOSERRORS
    41 #define INCL_WIN
    42 #define INCL_GPI
    43 
    44 // spooler #include's
    45 #define INCL_BASE
     44
     45#define INCL_WINWINDOWMGR
     46#define INCL_WINMESSAGEMGR
     47#define INCL_WINFRAMEMGR
     48#define INCL_WININPUT
     49#define INCL_WINDIALOGS
     50#define INCL_WINPOINTERS
     51#define INCL_WINRECTANGLES
     52#define INCL_WINSHELLDATA
     53#define INCL_WINSYS
     54#define INCL_WINHELP
     55#define INCL_WINPROGRAMLIST
     56#define INCL_WINSWITCHLIST
     57#define INCL_WINMENUS
     58#define INCL_WINSCROLLBARS
     59#define INCL_WINLISTBOXES
     60#define INCL_WINSTDSPIN
     61#define INCL_WINSTDSLIDER
     62#define INCL_WINCIRCULARSLIDER
     63#define INCL_WINSTDFILE
     64
    4665#define INCL_SPL
    4766#define INCL_SPLDOSPRINT
    4867#define INCL_SPLERRORS
    4968
     69#define INCL_GPIBITMAPS
     70#define INCL_GPIPRIMITIVES
    5071#include <os2.h>
    5172
     
    6990
    7091/* ******************************************************************
    71  *                                                                  *
    72  *   Menu helpers                                                   *
    73  *                                                                  *
     92 *
     93 *   Menu helpers
     94 *
    7495 ********************************************************************/
    7596
     
    255276 *      not found.
    256277 *
    257  *      If something != NULL is returned, you
    258  *      should free() the buffer afterwards.
     278 *      Returns NULL on error. Use winhFree()
     279 *      to free the return value.
    259280 *
    260281 *      Use the WinSetMenuItemText macro to
     
    387408
    388409/* ******************************************************************
    389  *                                                                  *
    390  *   Slider helpers                                                 *
    391  *                                                                  *
     410 *
     411 *   Slider helpers
     412 *
    392413 ********************************************************************/
    393414
     
    791812
    792813/* ******************************************************************
    793  *                                                                  *
    794  *   Spin button helpers                                            *
    795  *                                                                  *
     814 *
     815 *   Spin button helpers
     816 *
    796817 ********************************************************************/
    797818
     
    896917
    897918/* ******************************************************************
    898  *                                                                  *
    899  *   List box helpers                                               *
    900  *                                                                  *
     919 *
     920 *   List box helpers
     921 *
    901922 ********************************************************************/
    902923
     
    905926 *      returns the text of the specified
    906927 *      list box item in a newly allocated
    907  *      buffer, which you should free() afterwards,
    908  *      or NULL upon errors.
     928 *      buffer.
     929 *
     930 *      Returns NULL on error. Use winhFree()
     931 *      to free the return value.
    909932 *
    910933 *@@added V0.9.1 (99-12-14) [umoeller]
     
    10251048
    10261049/* ******************************************************************
    1027  *                                                                  *
    1028  *   Scroll bar helpers                                             *
    1029  *                                                                  *
     1050 *
     1051 *   Scroll bar helpers
     1052 *
    10301053 ********************************************************************/
    10311054
     
    15031526
    15041527/* ******************************************************************
    1505  *                                                                  *
    1506  *   Window positioning helpers                                     *
    1507  *                                                                  *
     1528 *
     1529 *   Window positioning helpers
     1530 *
    15081531 ********************************************************************/
    15091532
     
    19161939
    19171940/*
     1941 *@@ winhFindWindowBelow:
     1942 *      finds the window with the same parent
     1943 *      which sits right below hwndFind in the
     1944 *      window Z-order.
     1945 *
     1946 *@@added V0.9.7 (2000-12-04) [umoeller]
     1947 */
     1948
     1949HWND winhFindWindowBelow(HWND hwndFind)
     1950{
     1951    HWND hwnd = NULLHANDLE,
     1952         hwndParent = WinQueryWindow(hwndFind, QW_PARENT);
     1953
     1954    if (hwndParent)
     1955    {
     1956        HENUM   henum = WinBeginEnumWindows(hwndParent);
     1957        HWND    hwndThis;
     1958        while (hwndThis = WinGetNextWindow(henum))
     1959        {
     1960            SWP swp;
     1961            WinQueryWindowPos(hwndThis, &swp);
     1962            if (swp.hwndInsertBehind == hwndFind)
     1963            {
     1964                hwnd = hwndThis;
     1965                break;
     1966            }
     1967        }
     1968        WinEndEnumWindows(henum);
     1969    }
     1970
     1971    return (hwnd);
     1972}
     1973
     1974/*
    19181975 *@@category: Helpers\PM helpers\Presentation parameters
    19191976 */
    19201977
    19211978/* ******************************************************************
    1922  *                                                                  *
    1923  *   Presparams helpers                                             *
    1924  *                                                                  *
     1979 *
     1980 *   Presparams helpers
     1981 *
    19251982 ********************************************************************/
    19261983
     
    19281985 *@@ winhQueryWindowFont:
    19291986 *      returns the window font presentation parameter
    1930  *      in a newly allocated buffer, which you must
    1931  *      free() afterwards. Returns NULL if not found.
     1987 *      in a newly allocated buffer.
     1988 *
     1989 *      Returns NULL on error. Use winhFree()
     1990 *      to free the return value.
    19321991 *
    19331992 *@@added V0.9.1 (2000-02-14) [umoeller]
     
    19662025
    19672026BOOL winhSetWindowFont(HWND hwnd,
    1968                        PSZ pszFont)
     2027                       const char *pcszFont)
    19692028{
    19702029    CHAR    szFont[256];
    19712030
    1972     if (pszFont == NULL)
     2031    if (pcszFont == NULL)
    19732032    {
    19742033        if (doshIsWarp4())
     
    19782037    }
    19792038    else
    1980         strhncpy0(szFont, pszFont, sizeof(szFont));
     2039        strhncpy0(szFont, pcszFont, sizeof(szFont));
    19812040
    19822041    return (WinSetPresParam(hwnd,
     
    20602119 *      Use free() on your PPRESPARAMS pointer (whose
    20612120 *      address was passed) after WinCreateWindow.
     2121 *
     2122 *      See winhQueryPresColor for typical presparams
     2123 *      used in OS/2.
    20622124 *
    20632125 *      Example:
     
    21392201 *      3)  if this fails or (fInherit == FALSE), WinQuerySysColor
    21402202 *          is called to get lSysColor (which should be a SYSCLR_*
    2141  *          index).
     2203 *          index), if lSysColor != -1;
     2204 *      4)  if (lSysColor == -1), -1 is returned.
    21422205 *
    21432206 *      The return value is always an RGB LONG, _not_ a color index.
     
    22052268 *@@changed V0.9.0 [umoeller]: removed INI key query, using SYSCLR_* instead; function prototype changed
    22062269 *@@changed V0.9.0 [umoeller]: added fInherit parameter
     2270 *@@changed V0.9.7 (2000-12-02) [umoeller]: added lSysColor == -1 support
    22072271 */
    22082272
     
    22292293
    22302294    // not found: get system color
    2231     return (WinQuerySysColor(HWND_DESKTOP, lSysColor, 0));
     2295    if (lSysColor != -1)
     2296        return (WinQuerySysColor(HWND_DESKTOP, lSysColor, 0));
     2297
     2298    return -1;
    22322299}
    22332300
     
    22372304
    22382305/* ******************************************************************
    2239  *                                                                  *
    2240  *   Help instance helpers                                          *
    2241  *                                                                  *
     2306 *
     2307 *   Help instance helpers
     2308 *
    22422309 ********************************************************************/
    22432310
     
    27602827
    27612828/* ******************************************************************
    2762  *                                                                  *
    2763  *   Miscellaneous                                                  *
    2764  *                                                                  *
     2829 *
     2830 *   Miscellaneous
     2831 *
    27652832 ********************************************************************/
     2833
     2834/*
     2835 *@@ winhFree:
     2836 *      frees a block of memory allocated by the
     2837 *      winh* functions.
     2838 *
     2839 *      Since the winh* functions use malloc(),
     2840 *      you can also use free() directly on such
     2841 *      blocks. However, you must use winhFree
     2842 *      if the winh* functions are in a module
     2843 *      with a different C runtime.
     2844 *
     2845 *@@added V0.9.7 (2000-12-06) [umoeller]
     2846 */
     2847
     2848VOID winhFree(PVOID p)
     2849{
     2850    if (p)
     2851        free(p);
     2852}
    27662853
    27672854/*
     
    29303017 *@@ winhQueryWindowText:
    29313018 *      this returns the window text of the specified
    2932  *      HWND in a newly allocated buffer, which has
    2933  *      the exact size of the window text.
    2934  *
    2935  *      This buffer must be free()'d later.
     3019 *      HWND in a newly allocated buffer.
     3020 *
     3021 *      Returns NULL on error. Use winhFree()
     3022 *      to free the return value.
    29363023 */
    29373024
     
    30583145 *@@added V0.9.0 [umoeller]
    30593146 *@@changed V0.9.5 (2000-08-13) [umoeller]: flStyleClient never worked, fixed
     3147 *@@changed V0.9.7 (2000-12-08) [umoeller]: fixed client calc for invisible window
    30603148 */
    30613149
     
    31193207
    31203208            // position client
    3121             WinQueryWindowRect(hwndFrame, &rclClient);
    3122             WinCalcFrameRect(hwndFrame, &rclClient,
     3209            // WinQueryWindowRect(hwndFrame, &rclClient);
     3210            // doesn't work because it might be invisible V0.9.7 (2000-12-08) [umoeller]
     3211            rclClient.xLeft = 0;
     3212            rclClient.yBottom = 0;
     3213            rclClient.xRight = pswpFrame->cx;
     3214            rclClient.yTop = pswpFrame->cy;
     3215            WinCalcFrameRect(hwndFrame,
     3216                             &rclClient,
    31233217                             TRUE);     // calc client from frame
    31243218            WinSetWindowPos(*phwndClient,
     
    35153609
    35163610/*
     3611 *@@ winhQuerySwitchList:
     3612 *      returns the switch list in a newly
     3613 *      allocated buffer. This does the
     3614 *      regular double WinQuerySwitchList
     3615 *      call to first get the no. of items
     3616 *      and then get the items.
     3617 *
     3618 *      The no. of items can be found in
     3619 *      the returned SWBLOCK.cwsentry.
     3620 *
     3621 *      Returns NULL on errors. Use
     3622 *      winhFree to free the return value.
     3623 *
     3624 *@@added V0.9.7 (2000-12-06) [umoeller]
     3625 */
     3626
     3627PSWBLOCK winhQuerySwitchList(HAB hab)
     3628{
     3629    ULONG   cItems = WinQuerySwitchList(hab, NULL, 0);
     3630    ULONG   ulBufSize = (cItems * sizeof(SWENTRY)) + sizeof(HSWITCH);
     3631    PSWBLOCK pSwBlock = (PSWBLOCK)malloc(ulBufSize);
     3632    if (pSwBlock)
     3633    {
     3634        cItems = WinQuerySwitchList(hab, pSwBlock, ulBufSize);
     3635        if (!cItems)
     3636        {
     3637            free(pSwBlock);
     3638            pSwBlock = NULL;
     3639        }
     3640    }
     3641
     3642    return (pSwBlock);
     3643}
     3644
     3645/*
     3646 *@@ winhQueryTasklistWindow:
     3647 *      returns the window handle of the PM task list.
     3648 *
     3649 *@@added V0.9.7 (2000-12-07) [umoeller]
     3650 */
     3651
     3652HWND winhQueryTasklistWindow(VOID)
     3653{
     3654    SWBLOCK  swblock;
     3655    HWND     hwndTasklist = winhQueryTasklistWindow();
     3656    // the tasklist has entry #0 in the SWBLOCK
     3657    WinQuerySwitchList(NULLHANDLE, &swblock, sizeof(SWBLOCK));
     3658    return (swblock.aswentry[0].swctl.hwnd);
     3659}
     3660
     3661/*
    35173662 *@@ winhKillTasklist:
    35183663 *      this will destroy the Tasklist (window list) window.
     
    35253670VOID winhKillTasklist(VOID)
    35263671{
    3527     SWBLOCK  swblock;
    3528     HWND     hwndTasklist;
    3529     // the tasklist has entry #0 in the SWBLOCK
    3530     WinQuerySwitchList(NULLHANDLE, &swblock, sizeof(SWBLOCK));
    3531     hwndTasklist = swblock.aswentry[0].swctl.hwnd;
     3672    HWND     hwndTasklist = winhQueryTasklistWindow();
    35323673    WinPostMsg(hwndTasklist,
    35333674               0x0454,     // undocumented msg for killing tasklist
     
    36953836
    36963837/* ******************************************************************
    3697  *                                                                  *
    3698  *   WPS Class List helpers                                         *
    3699  *                                                                  *
     3838 *
     3839 *   WPS Class List helpers
     3840 *
    37003841 ********************************************************************/
    37013842
     
    37123853 *      See WinEnumObjectClasses() for details.
    37133854 *
    3714  *      The buffer is allocated using malloc(), so
    3715  *      you should free() it when it is no longer
    3716  *      needed.
    3717  *
    3718  *      This returns NULL if an error occured.
     3855 *      Returns NULL on error. Use winhFree()
     3856 *      to free the return value.
    37193857 *
    37203858 *@@added V0.9.0 [umoeller]
Note: See TracChangeset for help on using the changeset viewer.