Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003197 [JEDI VCL] 00 JVCL Components major always 2005-09-15 05:55 2006-01-08 11:57
Reporter mhoeper View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.00
Summary 0003197: Parameter "Rect" in the "OnDrawLeftMargin" event in class "TJvStandardMenuItemPainter" is wrong.
Description There is a bug in the TJvCustomMenuItemPainter.Paint method, if "menu animation" in Windows is ENABLED:

CanvasWindow := WindowFromDC(Canvas.Handle); // CanvasWindow = 0!
GetWindowRect(CanvasWindow, CanvasRect); // CanvasRect wrong
LeftMarginRect := Rect(..., 0, ..., CanvasRect.Bottom - ...) // LeftMarginRect wrong

so that the calculated LeftMarginRect in this method is wrong. Afterwards the event OnDrawLeftMargin in TJvStandardMenuItemPainter gets a wrong Rect parameter.
Additional Information Only occures if "menu animation" in Windows system ("system control/display/design?(the tab next to settings)/effects") is turned on.

A solution could be changing the "TrackPopupMenu" WindowsAPI call in method "TJvPopupMenu.Popup" in the following way:

TrackPopupMenu(Items.Handle, Flags[UseRightToLeftAlignment, Alignment] or Buttons[TrackButton] or TPM_NOANIMATION, X, Y, 0, PopupList.Window, nil);
Tags No tags attached.
Attached Files

- Relationships

-  Notes
obones (administrator)
2005-11-26 09:10

WindowFromDC does not always return 0. When drawing a menu, there is at least one time when it returns a valid handle. As such, the rectangle will be ok that time. What about I do not call DrawLeftMargin if WindowFromDC returned 0? That would change the code from this:

  // draw the margin, if any
  if LeftMargin > 0 then

to this:

  // draw the margin, if any
  if (LeftMargin > 0) and (CanvasWindow <> 0) then

This is ok with me, but what about you?
mhoeper (reporter)
2005-11-30 01:33

That works wrong, too: In this case DrawLeftMargin will not be called, if the Menu pops up, because the CanvasWindow is 0 this time. Its only <> 0, if you move the mouse over an menu item.
So my Graphic will only drawed in the Rect of the single menu item:

procedure TMy.JvStandardMenuItemPainterDrawLeftMargin(
  Sender: TMenu; Rect: TRect);
  JvPopupMenu.Canvas.Draw(Rect.Left, Rect.Top, MyImage.Picture.Graphic);
obones (administrator)
2006-01-08 11:57

I've put some changes inside JvMenus that address this issue. See around line 2183 for the explanation.

- Issue History
Date Modified Username Field Change
2005-09-15 05:55 mhoeper New Issue
2005-09-15 05:59 mhoeper Issue Monitored: mhoeper
2005-11-26 05:28 obones Status new => assigned
2005-11-26 05:28 obones Assigned To => obones
2005-11-26 09:10 obones Note Added: 0008168
2005-11-26 09:10 obones Status assigned => feedback
2005-11-30 01:33 mhoeper Note Added: 0008177
2006-01-08 11:57 obones Status feedback => resolved
2006-01-08 11:57 obones Resolution open => fixed
2006-01-08 11:57 obones Note Added: 0008341

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker