Bug in CXTPPopupBar |
Post Reply |
Author | |
fishy
Newbie Joined: 26 October 2005 Status: Offline Points: 17 |
Post Options
Thanks(0)
Posted: 02 January 2007 at 4:46pm |
There is a bug in the CXTPPopupBar::CalculatePopupRect method that shows itself when the drop-down portion of a menu is displayed when the main window is an AppBar window. The method CXTPPopupBar::CalculatePopupRect calculates a rectangle for the window that lies within the desktop’s work area (see CXTPDrawHelpers::GetWorkArea() and ::SystemParametersInfo(SPI_GETWORKAREA,…) ). This is fine except for the case when the popup window is associated with a parent window which itself is an AppBar, which by definition lies outside the work area when AppBars are set to stay on top of other windows (see the “Keep the taskbar on top of other windows” option on the “Taskbar and Start Menu Properties” dialog). In that case, the drop-down portion of the menu is displayed OUTSIDE the parent window. A case should be added to CXTPPopupBar::CalculatePopupRect() to detect the case where the parent window is entirely outside the work area, in which case the popup window should kept inside the screen rectangle, NOT the work area rectangle.
This is a pretty awful bug to any application that uses menus and is itself an AppBar. Anyway we could get a fix for it? - fishy |
|
fishy
Newbie Joined: 26 October 2005 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
The following changes were made to fix the bug:
1. Add the following method to the CXTPMultiMonitor class: CRect CXTPMultiMonitor::GetScreenArea(POINT ptScreenCoords) { MONITORINFO info; HMONITOR hMonitor = InitMultipleMonitorStubs() ? m_pfnMonitorFromPoint(ptScreenCoords, 0) : 0; if (GetMonitorInfo(hMonitor, &info)) { return info.rcMonitor; } return CRect(0, 0, ::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN)); } 2. Add the following method to the CXTPDrawHelpers class: static CRect AFX_CDECL CXTPDrawHelpers::GetScreenArea(const POINT& point) { return CXTPMultiMonitor::s_monInstance.GetScreenArea(pWnd->GetSafeHwnd()); } 3. Use the following code in the CXTPPopupBar::CalculatePopupRect() method to calculate the “work area” rectangle used to determine if the popup needs to be relocated: CRect CXTPPopupBar::CalculatePopupRect(CSize sz) { RECT rcWork = m_rcExclude.IsRectEmpty() ? CXTPDrawHelpers::GetWorkArea(m_ptPopup) : CXTPDrawHelpers::GetWorkArea(m_rcExclude); RECT screenRect = CXTPDrawHelpers::GetScreenArea(m_ptPopup); // If point is on the screen, but not in the work area, then the point // must be inside an AppBar. if ( PtInRect(&screenRect,m_ptPopup) && !PtInRect(&rcWork,m_ptPopup) ) { rcWork = screenRect; } ... Any chance we could get these changes integrated into a new release at some point? It would be extremely helpful. Thanks, fishy. |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello,
Yes, thank you, we included it.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
fishy
Newbie Joined: 26 October 2005 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
Heh, I made a stupid copy and paste error in the code above. If you look closely, there is an obvious error in #2.
static CRect AFX_CDECL CXTPDrawHelpers::GetScreenArea(const POINT& point) { return CXTPMultiMonitor::s_monInstance.GetScreenArea(pWnd->GetSafeHwnd()); } Should be changed to: static CRect AFX_CDECL CXTPDrawHelpers::GetScreenArea(const POINT& point) { return CXTPMultiMonitor::s_monInstance.GetScreenArea(point); } Thanks - fishy |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |