Menu

BUG: CWnd::CenterWindow()

ajk
2022-03-13
2022-03-15
  • ajk

    ajk - 2022-03-13

    When dealing with the multi-monitor case, after identifying the monitor to deal with, the code fails to update the parentRect with the new dimensions. In my copy, about wxx_wincode.h line 247, the code currently reads:

                    desktopRect = mi.rcWork;
                    if (GetParent().GetHwnd() == 0) desktopRect = mi.rcWork;
    

    where at best the second line is not required.

    I think the code should read:

                    desktopRect = mi.rcWork;
                    if (GetParent().GetHwnd() == 0) parentRect = mi.rcWork;
    

    (I'm afraid I don't know if the code works in these circustances, not having multiple monitors)

    Cheers Andy

     
  • David

    David - 2022-03-15

    Hi Andy,

    I've submitted a correction to the code you mentioned. The code now looks like this.

    if (pfnGetMonitorInfo(hActiveMonitor, &mi))
    {
        desktopRect = mi.rcWork;
        if (GetParent().GetHwnd() == 0) 
            parentRect = mi.rcWork;
    }
    

    You can download the latest snapshot of the code from the code section.

    Best regards,
    David

     

Log in to post a comment.