Print Page | Close Window

Bug in CXTPPopupBar

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=5966
Printed Date: 21 December 2024 at 8:47pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Bug in CXTPPopupBar
Posted By: fishy
Subject: Bug in CXTPPopupBar
Date 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



Replies:
Posted By: fishy
Date 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.



Posted By: Oleg
Date Posted: 04 January 2007 at 2:15am
Hello,
Yes, thank you, we included it.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: fishy
Date 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





Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net