Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Bug in CXTPPopupBar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Bug in CXTPPopupBar

 Post Reply Post Reply
Author
Message
fishy View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2005
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote fishy Quote  Post ReplyReply Direct Link To This Post Topic: Bug in CXTPPopupBar
    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
Back to Top
fishy View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2005
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote fishy Quote  Post ReplyReply Direct Link To This Post Posted: 03 January 2007 at 2:53pm
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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 January 2007 at 2:15am
Hello,
Yes, thank you, we included it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
fishy View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2005
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote fishy Quote  Post ReplyReply Direct Link To This Post Posted: 04 January 2007 at 9:37am
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


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.