Weirdness with MLE and Presentation Parameters - OS2

This is a discussion on Weirdness with MLE and Presentation Parameters - OS2 ; Hallo, the MLE seems to pick up presentation parameters if, for example, a color is dropped on it using the color palette (I am using WinStoreWindowPos,WinRestoreWindowPos which also saves/restores presentation parameters). However, dropping a font on it from the font ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Weirdness with MLE and Presentation Parameters

  1. Weirdness with MLE and Presentation Parameters

    Hallo,

    the MLE seems to pick up presentation parameters if, for example, a
    color is dropped on it using the color palette (I am using
    WinStoreWindowPos,WinRestoreWindowPos which also saves/restores
    presentation parameters).
    However, dropping a font on it from the font palette does not seem to be
    persistent. I have to manually set the font presentation parameter on
    the MLE when the MLE is created and read (because it could have changed)
    and save the font presentation parameter shortly before the MLE is
    destroyed.

    Can someone shed some light on this inconsistent behaviour and/or give
    me some small sample code how to properly save/restore presentation
    parameters ?

    Lars

  2. Re: Weirdness with MLE and Presentation Parameters

    Hello Lars!

    You must save the preparams yourself, here's how I do it:

    void savePresParam(HWND hwnd, ULONG ulPPAttrId)
    {
    char szAppName[80];
    char szKey[32];
    char szFont[80];
    RGB rgbColor;

    WinLoadString(hab, NULLHANDLE, IDS_PRFAPPNAME, 80, szAppName);

    switch(ulPPAttrId) {
    case PP_FOREGROUNDCOLOR:
    WinLoadString(hab, NULLHANDLE, IDS_PRFFOREGROUND, 32, szKey);
    WinQueryPresParam(hwnd, ulPPAttrId, 0, NULL, sizeof(RGB),
    &rgbColor, 0);
    PrfWriteProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    sizeof(RGB));
    break;

    case PP_BACKGROUNDCOLOR:
    WinLoadString(hab, NULLHANDLE, IDS_PRFBACKGROUND, 32, szKey);
    WinQueryPresParam(hwnd, ulPPAttrId, 0, NULL, sizeof(RGB),
    &rgbColor, 0);
    PrfWriteProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    sizeof(RGB));
    break;

    case PP_FONTNAMESIZE:
    WinLoadString(hab, NULLHANDLE, IDS_PRFFONT, 32, szKey);
    WinQueryPresParam(hwnd, ulPPAttrId, 0, NULL, 80, &szFont, 0);
    PrfWriteProfileString(HINI_USER, szAppName, szKey, szFont);
    break;
    } // end switch

    } // end savePresParam

    Just call it from your window proc, like this:

    case WM_PRESPARAMCHANGED:
    savePresParam(hwnd, (ULONG) mp1);
    break;

    You need the following string entries in your resource segment:

    IDS_PRFAPPNAME Name of "application" key in os2.ini
    IDS_PRFFOREGROUND Name of key where to store foreground color
    IDS_PRFBACKGROUND Name of key where to store background color
    IDS_PRFFONT Name of key where to store font

    The following code will load the presparams again, call from your
    WM_INIT or just after the window has been created but before it is shown.

    /*
    * Load font
    */
    WinLoadString(hab, NULLHANDLE, IDS_DEFAULTFONT, 32, szDefault);
    WinLoadString(hab, NULLHANDLE, IDS_PRFFONT, 32, szKey);
    PrfQueryProfileString(HINI_USER, szAppName, szKey, szDefault,
    szFont, 32);
    WinSetPresParam(hwndClient, PP_FONTNAMESIZE, strlen(szFont)+1,
    szFont);

    /*
    * Load foreground and background colors
    */
    ulSize = sizeof(RGB);
    WinLoadString(hab, NULLHANDLE, IDS_PRFFOREGROUND, 32, szKey);
    if (PrfQueryProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    &ulSize))
    WinSetPresParam(hwndClient, PP_FOREGROUNDCOLOR, ulSize,
    &rgbColor);

    WinLoadString(hab, NULLHANDLE, IDS_PRFBACKGROUND, 32, szKey);
    if (PrfQueryProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    &ulSize))
    WinSetPresParam(hwndClient, PP_BACKGROUNDCOLOR, ulSize,
    &rgbColor);

    Take Care!
    Harald!

  3. Re: Weirdness with MLE and Presentation Parameters

    Hi,

    maybe my question was a bit misleading. I understand that of course I need
    to save away the presentation parameters in some way and I am using
    WinStoreWindowPos/WinRestoreWindowPos which, apart from the window position,
    also saves away/restores the presentation parameters (I wanted to also save
    the window position, so this does it all).
    That was not the problem. The problem was that I saved away the presparams
    for the frame. When restoring the presparams, the restore is supposed to go
    to all windows that are owned by the frame. This went ok for all color
    parameters but not the font parameter.
    The MLE picked up all color parameters but I had to do an extra
    WinSetPresParam to the MLE to pick up the font parameter.
    Can a sub-window somehow ignore the change of presentation parameters
    (WM_PRESPARMCHANGED) passed down by an owner window but react to an explicit
    setting of a presentation parameter (WM_SETPRESPARAM) ?
    Is this behaviour somehow arbitrary ?

    Lars

    "Harald Eilertsen" schrieb im Newsbeitrag
    news:dj09hi$gca$1@services.kq.no...
    > Hello Lars!
    >
    > You must save the preparams yourself, here's how I do it:
    >
    > void savePresParam(HWND hwnd, ULONG ulPPAttrId)
    > {
    > char szAppName[80];
    > char szKey[32];
    > char szFont[80];
    > RGB rgbColor;
    >
    > WinLoadString(hab, NULLHANDLE, IDS_PRFAPPNAME, 80, szAppName);
    >
    > switch(ulPPAttrId) {
    > case PP_FOREGROUNDCOLOR:
    > WinLoadString(hab, NULLHANDLE, IDS_PRFFOREGROUND, 32, szKey);
    > WinQueryPresParam(hwnd, ulPPAttrId, 0, NULL, sizeof(RGB),
    > &rgbColor, 0);
    > PrfWriteProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    > sizeof(RGB));
    > break;
    >
    > case PP_BACKGROUNDCOLOR:
    > WinLoadString(hab, NULLHANDLE, IDS_PRFBACKGROUND, 32, szKey);
    > WinQueryPresParam(hwnd, ulPPAttrId, 0, NULL, sizeof(RGB),
    > &rgbColor, 0);
    > PrfWriteProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    > sizeof(RGB));
    > break;
    >
    > case PP_FONTNAMESIZE:
    > WinLoadString(hab, NULLHANDLE, IDS_PRFFONT, 32, szKey);
    > WinQueryPresParam(hwnd, ulPPAttrId, 0, NULL, 80, &szFont, 0);
    > PrfWriteProfileString(HINI_USER, szAppName, szKey, szFont);
    > break;
    > } // end switch
    >
    > } // end savePresParam
    >
    > Just call it from your window proc, like this:
    >
    > case WM_PRESPARAMCHANGED:
    > savePresParam(hwnd, (ULONG) mp1);
    > break;
    >
    > You need the following string entries in your resource segment:
    >
    > IDS_PRFAPPNAME Name of "application" key in os2.ini
    > IDS_PRFFOREGROUND Name of key where to store foreground color
    > IDS_PRFBACKGROUND Name of key where to store background color
    > IDS_PRFFONT Name of key where to store font
    >
    > The following code will load the presparams again, call from your
    > WM_INIT or just after the window has been created but before it is shown.
    >
    > /*
    > * Load font
    > */
    > WinLoadString(hab, NULLHANDLE, IDS_DEFAULTFONT, 32, szDefault);
    > WinLoadString(hab, NULLHANDLE, IDS_PRFFONT, 32, szKey);
    > PrfQueryProfileString(HINI_USER, szAppName, szKey, szDefault,
    > szFont, 32);
    > WinSetPresParam(hwndClient, PP_FONTNAMESIZE, strlen(szFont)+1,
    > szFont);
    >
    > /*
    > * Load foreground and background colors
    > */
    > ulSize = sizeof(RGB);
    > WinLoadString(hab, NULLHANDLE, IDS_PRFFOREGROUND, 32, szKey);
    > if (PrfQueryProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    > &ulSize))
    > WinSetPresParam(hwndClient, PP_FOREGROUNDCOLOR, ulSize,
    > &rgbColor);
    >
    > WinLoadString(hab, NULLHANDLE, IDS_PRFBACKGROUND, 32, szKey);
    > if (PrfQueryProfileData(HINI_USER, szAppName, szKey, &rgbColor,
    > &ulSize))
    > WinSetPresParam(hwndClient, PP_BACKGROUNDCOLOR, ulSize,
    > &rgbColor);
    >
    > Take Care!
    > Harald!




  4. Re: Weirdness with MLE and Presentation Parameters

    On Mon, 17 Oct 2005 15:38:44 +0200, Harald Eilertsen
    wrote:

    > char szAppName[80];
    > char szKey[32];
    > char szFont[80];
    >
    > WinLoadString(hab, NULLHANDLE, IDS_PRFAPPNAME, 80, szAppName);
    > WinLoadString(hab, NULLHANDLE, IDS_PRFFOREGROUND, 32, szKey);


    As this is a programming group, I feel I must remark on your utterly
    dreadful coding style.
    Hard-coding 32 and 80 into those calls is exceedingly bad programming
    practice.
    It's this sort of crap in other people's code that I have been chasing
    to get fixed at work for at least the last 2 months - they changed
    the size of the buffer and what was going in it, but didn't update the
    hard coded parameter.

    IT IS SO EASY TO DO IT PROPERLY, SO DO IT.

  5. Re: Weirdness with MLE and Presentation Parameters

    Paul Ratcliffe wrote:

    > As this is a programming group, I feel I must remark on your utterly
    > dreadful coding style.
    > Hard-coding 32 and 80 into those calls is exceedingly bad programming
    > practice.


    Agreed, and taken note of!

    Take Care!
    Harald!

  6. Re: Weirdness with MLE and Presentation Parameters


    >> char szAppName[80];
    >> char szKey[32];
    >> char szFont[80];


    >> WinLoadString(hab, NULLHANDLE, IDS_PRFAPPNAME, 80, szAppName);
    >> WinLoadString(hab, NULLHANDLE, IDS_PRFFOREGROUND, 32, szKey);


    > As this is a programming group, I feel I must remark on your utterly
    > dreadful coding style.
    > Hard-coding 32 and 80 into those calls is exceedingly bad programming
    > practice.
    > It's this sort of crap in other people's code that I have been chasing
    > to get fixed at work for at least the last 2 months - they changed
    > the size of the buffer and what was going in it, but didn't update the
    > hard coded parameter.


    > IT IS SO EASY TO DO IT PROPERLY, SO DO IT.


    A slightly related, basic level question. Given the C source below, how
    to avoid the following warnings of ICC?

    err.c(7:15) : informational EDC0424: The condition is always true.

    Or, with ICC /Sp1:

    err.c(7:15) : informational EDC0424: The condition is always false.



    ---
    #include

    typedef struct {char a;char b;char c;int i;} MS;

    int main(void)
    {

    if (sizeof(MS)!=7)
    {
    printf("Warning. Stop using fread() with sizeof(MS) to read a header of 7\n");
    printf("bytes, because the actual size of MS is %d bytes?\n",sizeof(MS));
    }

    return 0;
    }

  7. Re: Weirdness with MLE and Presentation Parameters

    In , on 12/04/2005
    at 03:56 PM, spamgate@hotmai1.com (ML) said:


    >A slightly related, basic level question. Given the C source below, how
    >to avoid the following warnings of ICC?


    > err.c(7:15) : informational EDC0424: The condition is always true.
    >
    >Or, with ICC /Sp1:


    > err.c(7:15) : informational EDC0424: The condition is always false.


    Use a #pragma info to turn off the messages for the error class (i.e.
    cnd).

    Steven

    --
    --------------------------------------------------------------------------------------------
    Steven Levine MR2/ICE 2.67 #10183
    Warp4.something/14.100c_W4 www.scoug.com irc.fyrelizard.com #scoug (Wed 7pm PST)
    --------------------------------------------------------------------------------------------


  8. Re: Weirdness with MLE and Presentation Parameters


    "ML" wrote in message news:nWvkDlQNAxOd090yn@hotmai1.com...
    snip

    > A slightly related, basic level question. Given the C source below, how
    > to avoid the following warnings of ICC?
    >
    > err.c(7:15) : informational EDC0424: The condition is always true.
    >
    > Or, with ICC /Sp1:
    >
    > err.c(7:15) : informational EDC0424: The condition is always false.
    >
    >
    >
    > ---
    > #include
    >
    > typedef struct {char a;char b;char c;int i;} MS;
    >
    > int main(void)
    > {
    >
    > if (sizeof(MS)!=7)
    > {
    > printf("Warning. Stop using fread() with sizeof(MS) to read a header of 7\n");
    > printf("bytes, because the actual size of MS is %d bytes?\n",sizeof(MS));
    > }
    >
    > return 0;
    > }


    Hi all,
    in the past, I always used the following workaround, to avoid
    that compilers 'info msg'. Assign the constant value to a temp.
    variable and later use the variable...
    Guenter

    #include

    typedef struct {char a;char b;char c;int i;} MS;

    int main(void)
    {
    int dummy;
    dummy = 7;

    if (sizeof(MS)!=dummy)
    {
    printf("Warning. Stop using fread() with sizeof(MS) to read a header of 7\n");
    printf("bytes, because the actual size of MS is %d bytes?\n",sizeof(MS));
    }

    return 0;
    }



+ Reply to Thread