View Issue Details

IDProjectCategoryView StatusLast Update
0003197JEDI VCL00 JVCL Componentspublic2006-01-08 11:57
ReportermhoeperAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 
Target VersionFixed in Version3.20 
Summary0003197: Parameter "Rect" in the "OnDrawLeftMargin" event in class "TJvStandardMenuItemPainter" is wrong.
DescriptionThere 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 InformationOnly 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);
TagsNo tags attached.

Activities

obones

2005-11-26 09:10

administrator   ~0008168

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
    DrawLeftMargin(LeftMarginRect);

to this:

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


This is ok with me, but what about you?

mhoeper

2005-11-30 01:33

reporter   ~0008177

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);
begin
  JvPopupMenu.Canvas.Draw(Rect.Left, Rect.Top, MyImage.Picture.Graphic);
end;

obones

2006-01-08 11:57

administrator   ~0008341

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-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