"Remy Lebeau (TeamB)" <✉no.spam.com> wrote in message news:✉forums.codegear.com...
> "Lorne Anderson" <✉hotmail.com> wrote in message > news:✉forums.codegear.com... > >> Does anybody know how to use TrackPopupMenuEx with >> owner draw Popup menus? > > Just call it normally. There is nothing special you have to do to let > owner-drawing operate correctly. > >> It appears to size and position the menu before the owner draw routines >> have executed any DrawItem or MeasureItem code so although the >> vertical position is OK the Width is wrong and nothing gets drawn. > > Then the owner-drawing code is likely buggy to begin with. Can you show > the actual code? > > -- > Remy Lebeau (TeamB)
The owner draw code is not processed if I launch the popup with TrackPopupMenuEx - even with a simple test procedure like this:
procedure TMainView.DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean); begin ACanvas.TextRect(ARect, ARect.Left + 5, ARect.Top + 2, TMenuItem(Sender).Caption); end;
Also onMeasureItem is not called.
Here is my code for calling TrackPopupMenuEx:
pt := ClientToScreen(Point(DDBtn.Left, DDBtn.Top)); Selected := Ord(TrackPopupMenuEx(test.Handle, TPM_LEFTALIGN + TPM_BOTTOMALIGN + TPM_RETURNCMD, pt.X, pt.Y, handle, nil)); if Selected > 0 then test.Items[Selected - 1].Click;
If I turn off ownerdraw it launches in the correct place with correct size.