Article

From:
To:
Remy Lebeau (TeamB)
Subject:
Re: TrackPopupMenuEx and owner draw
Newsgroup:
embarcadero.public.delphi.language.delphi.general

Re: TrackPopupMenuEx and owner draw

"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.
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Sat, 23 Nov 2024 21:46:01 UTC
Copyright © 2009-2024
HREF Tools Corp.