Changeset 14 for trunk/src/helpers/winh.c
- Timestamp:
- Dec 9, 2000, 8:19:42 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/winh.c
r13 r14 20 20 /* 21 21 * Copyright (C) 1997-2000 Ulrich Mller. 22 * This file is part of the XWorkplacesource package.23 * XWorkplaceis free software; you can redistribute it and/or modify22 * This file is part of the "XWorkplace helpers" source package. 23 * This is free software; you can redistribute it and/or modify 24 24 * it under the terms of the GNU General Public License as published 25 25 * by the Free Software Foundation, in version 2 as it comes in the … … 36 36 // as unsigned char 37 37 38 #define INCL_DOSPROCESS 39 #define INCL_DOSMODULEMGR 40 #define INCL_DOSSEMAPHORES 41 #define INCL_DOSDEVICES 38 42 #define INCL_DOSDEVIOCTL 39 #define INCL_DOS40 43 #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 46 65 #define INCL_SPL 47 66 #define INCL_SPLDOSPRINT 48 67 #define INCL_SPLERRORS 49 68 69 #define INCL_GPIBITMAPS 70 #define INCL_GPIPRIMITIVES 50 71 #include <os2.h> 51 72 … … 69 90 70 91 /* ****************************************************************** 71 * *72 * Menu helpers *73 * *92 * 93 * Menu helpers 94 * 74 95 ********************************************************************/ 75 96 … … 255 276 * not found. 256 277 * 257 * If something != NULL is returned, you258 * should free() the buffer afterwards.278 * Returns NULL on error. Use winhFree() 279 * to free the return value. 259 280 * 260 281 * Use the WinSetMenuItemText macro to … … 387 408 388 409 /* ****************************************************************** 389 * *390 * Slider helpers *391 * *410 * 411 * Slider helpers 412 * 392 413 ********************************************************************/ 393 414 … … 791 812 792 813 /* ****************************************************************** 793 * *794 * Spin button helpers *795 * *814 * 815 * Spin button helpers 816 * 796 817 ********************************************************************/ 797 818 … … 896 917 897 918 /* ****************************************************************** 898 * *899 * List box helpers *900 * *919 * 920 * List box helpers 921 * 901 922 ********************************************************************/ 902 923 … … 905 926 * returns the text of the specified 906 927 * 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. 909 932 * 910 933 *@@added V0.9.1 (99-12-14) [umoeller] … … 1025 1048 1026 1049 /* ****************************************************************** 1027 * *1028 * Scroll bar helpers *1029 * *1050 * 1051 * Scroll bar helpers 1052 * 1030 1053 ********************************************************************/ 1031 1054 … … 1503 1526 1504 1527 /* ****************************************************************** 1505 * *1506 * Window positioning helpers *1507 * *1528 * 1529 * Window positioning helpers 1530 * 1508 1531 ********************************************************************/ 1509 1532 … … 1916 1939 1917 1940 /* 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 1949 HWND 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 /* 1918 1975 *@@category: Helpers\PM helpers\Presentation parameters 1919 1976 */ 1920 1977 1921 1978 /* ****************************************************************** 1922 * *1923 * Presparams helpers *1924 * *1979 * 1980 * Presparams helpers 1981 * 1925 1982 ********************************************************************/ 1926 1983 … … 1928 1985 *@@ winhQueryWindowFont: 1929 1986 * 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. 1932 1991 * 1933 1992 *@@added V0.9.1 (2000-02-14) [umoeller] … … 1966 2025 1967 2026 BOOL winhSetWindowFont(HWND hwnd, 1968 PSZ pszFont)2027 const char *pcszFont) 1969 2028 { 1970 2029 CHAR szFont[256]; 1971 2030 1972 if (p szFont == NULL)2031 if (pcszFont == NULL) 1973 2032 { 1974 2033 if (doshIsWarp4()) … … 1978 2037 } 1979 2038 else 1980 strhncpy0(szFont, p szFont, sizeof(szFont));2039 strhncpy0(szFont, pcszFont, sizeof(szFont)); 1981 2040 1982 2041 return (WinSetPresParam(hwnd, … … 2060 2119 * Use free() on your PPRESPARAMS pointer (whose 2061 2120 * address was passed) after WinCreateWindow. 2121 * 2122 * See winhQueryPresColor for typical presparams 2123 * used in OS/2. 2062 2124 * 2063 2125 * Example: … … 2139 2201 * 3) if this fails or (fInherit == FALSE), WinQuerySysColor 2140 2202 * 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. 2142 2205 * 2143 2206 * The return value is always an RGB LONG, _not_ a color index. … … 2205 2268 *@@changed V0.9.0 [umoeller]: removed INI key query, using SYSCLR_* instead; function prototype changed 2206 2269 *@@changed V0.9.0 [umoeller]: added fInherit parameter 2270 *@@changed V0.9.7 (2000-12-02) [umoeller]: added lSysColor == -1 support 2207 2271 */ 2208 2272 … … 2229 2293 2230 2294 // 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; 2232 2299 } 2233 2300 … … 2237 2304 2238 2305 /* ****************************************************************** 2239 * *2240 * Help instance helpers *2241 * *2306 * 2307 * Help instance helpers 2308 * 2242 2309 ********************************************************************/ 2243 2310 … … 2760 2827 2761 2828 /* ****************************************************************** 2762 * *2763 * Miscellaneous *2764 * *2829 * 2830 * Miscellaneous 2831 * 2765 2832 ********************************************************************/ 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 2848 VOID winhFree(PVOID p) 2849 { 2850 if (p) 2851 free(p); 2852 } 2766 2853 2767 2854 /* … … 2930 3017 *@@ winhQueryWindowText: 2931 3018 * this returns the window text of the specified 2932 * HWND in a newly allocated buffer , which has2933 * 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. 2936 3023 */ 2937 3024 … … 3058 3145 *@@added V0.9.0 [umoeller] 3059 3146 *@@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 3060 3148 */ 3061 3149 … … 3119 3207 3120 3208 // 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, 3123 3217 TRUE); // calc client from frame 3124 3218 WinSetWindowPos(*phwndClient, … … 3515 3609 3516 3610 /* 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 3627 PSWBLOCK 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 3652 HWND 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 /* 3517 3662 *@@ winhKillTasklist: 3518 3663 * this will destroy the Tasklist (window list) window. … … 3525 3670 VOID winhKillTasklist(VOID) 3526 3671 { 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(); 3532 3673 WinPostMsg(hwndTasklist, 3533 3674 0x0454, // undocumented msg for killing tasklist … … 3695 3836 3696 3837 /* ****************************************************************** 3697 * *3698 * WPS Class List helpers *3699 * *3838 * 3839 * WPS Class List helpers 3840 * 3700 3841 ********************************************************************/ 3701 3842 … … 3712 3853 * See WinEnumObjectClasses() for details. 3713 3854 * 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. 3719 3857 * 3720 3858 *@@added V0.9.0 [umoeller]
Note:
See TracChangeset
for help on using the changeset viewer.