Ignore:
Timestamp:
Jan 10, 2003, 12:03:22 AM (23 years ago)
Author:
umoeller
Message:

Misc fixes.

File:
1 edited

Legend:

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

    r238 r239  
    29692969
    29702970/*
     2971 *@@ winhQueryMenuSysFont:
     2972 *      returns the system menu font in a new buffer
     2973 *      to be free()'d by caller.
     2974 *
     2975 *@@added V1.0.1 (2003-01-05) [umoeller]
     2976 */
     2977
     2978PSZ winhQueryMenuSysFont(VOID)
     2979{
     2980    PSZ pszStdMenuFont;
     2981    if (!(pszStdMenuFont = prfhQueryProfileData(HINI_USER,
     2982                                                PMINIAPP_SYSTEMFONTS, // "PM_SystemFonts",
     2983                                                PMINIKEY_MENUSFONT, // "Menus",
     2984                                                NULL)))
     2985        pszStdMenuFont = prfhQueryProfileData(HINI_USER,
     2986                                              PMINIAPP_SYSTEMFONTS, // "PM_SystemFonts",
     2987                                              PMINIKEY_DEFAULTFONT, // "DefaultFont",
     2988                                              NULL);
     2989
     2990    return pszStdMenuFont;
     2991}
     2992
     2993/*
    29712994 *@@ winhSetWindowFont:
    29722995 *      this sets a window's font by invoking
     
    38253848
    38263849/*
     3850 *@@ winhQueryWindowText2:
     3851 *      this returns the window text of the specified
     3852 *      HWND in a newly allocated buffer.
     3853 *
     3854 *      If pulExtra is specified, *pulExtra bytes will
     3855 *      be allocated in addition to the window text
     3856 *      length. Useful if you plan to append something
     3857 *      to the string. On output, *pulExtra receives
     3858 *      the string length excluding the extra bytes
     3859 *      and the terminating null byte.
     3860 *
     3861 *      Returns NULL on error. Use free()
     3862 *      to free the return value.
     3863 *
     3864 *@@added V1.0.1 (2003-01-05) [umoeller]
     3865 */
     3866
     3867PSZ winhQueryWindowText2(HWND hwnd,         // in: window whose text to query
     3868                         PULONG pulExtra)   // in: extra bytes to allocate or NULL,
     3869                                            // out: size of allocated buffer (including null byte)
     3870{
     3871    PSZ     pszText = NULL;
     3872    ULONG   cbText;
     3873    if (cbText = WinQueryWindowTextLength(hwnd))
     3874    {
     3875        ULONG cbExtra = 1;      // additional null character
     3876        if (pulExtra)
     3877            cbExtra += *pulExtra;
     3878
     3879        if (pszText = (PSZ)malloc(cbText + cbExtra))
     3880        {
     3881            WinQueryWindowText(hwnd,
     3882                               cbText + 1,
     3883                               pszText);
     3884            if (pulExtra)
     3885                *pulExtra = cbText;
     3886        }
     3887    }
     3888
     3889    return pszText;
     3890}
     3891
     3892/*
    38273893 *@@ winhQueryWindowText:
    38283894 *      this returns the window text of the specified
     
    38313897 *      Returns NULL on error. Use free()
    38323898 *      to free the return value.
     3899 *
     3900 *@@changed V1.0.1 (2003-01-05) [umoeller]: now using winhQueryWindowText2
    38333901 */
    38343902
    38353903PSZ winhQueryWindowText(HWND hwnd)
    38363904{
    3837     PSZ     pszText = NULL;
    3838     ULONG   cbText;
    3839     if (cbText = WinQueryWindowTextLength(hwnd))
    3840     {
    3841         if (pszText = (PSZ)malloc(cbText + 1))  // additional null character
    3842             WinQueryWindowText(hwnd,
    3843                                cbText + 1,
    3844                                pszText);
    3845     }
    3846 
    3847     return pszText;
     3905    return winhQueryWindowText2(hwnd, NULL);        // V1.0.1 (2003-01-05) [umoeller]
     3906}
     3907
     3908/*
     3909 *@@ winhQueryDlgItemText2:
     3910 *      shortcut around winhQueryWindowText2 to allow for
     3911 *      specifying a dialog item ID instead.
     3912 *
     3913 *@@added V1.0.1 (2003-01-05) [umoeller]
     3914 */
     3915
     3916PSZ winhQueryDlgItemText2(HWND hwnd,
     3917                          USHORT usItemID,
     3918                          PULONG pulExtra)
     3919{
     3920    return winhQueryWindowText2(WinWindowFromID(hwnd, usItemID),
     3921                                pulExtra);
    38483922}
    38493923
     
    38723946    return WinSetWindowText(hwnd,
    38733947                            szBuf);
     3948}
     3949
     3950/*
     3951 *@@ winhAppendWindowEllipseText:
     3952 *      appends three dots ("...") to the title
     3953 *      of the given window.
     3954 *
     3955 *@@added V1.0.1 (2003-01-05) [umoeller]
     3956 */
     3957
     3958BOOL winhAppendWindowEllipseText(HWND hwnd)
     3959{
     3960    ULONG cbExtra = 3;
     3961    PSZ psz;
     3962    BOOL brc = FALSE;
     3963    if (psz = winhQueryWindowText2(hwnd, &cbExtra))
     3964    {
     3965        memcpy(psz + cbExtra, "...", 4);
     3966        brc = WinSetWindowText(hwnd, psz);
     3967        free(psz);
     3968    }
     3969
     3970    return brc;
     3971}
     3972
     3973/*
     3974 *@@ winhAppendDlgItemEllipseText:
     3975 *
     3976 *@@added V1.0.1 (2003-01-05) [umoeller]
     3977 */
     3978
     3979BOOL winhAppendDlgItemEllipseText(HWND hwnd,
     3980                                  USHORT usItemID)
     3981{
     3982    return winhAppendWindowEllipseText(WinWindowFromID(hwnd, usItemID));
    38743983}
    38753984
Note: See TracChangeset for help on using the changeset viewer.