Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delphi : Keep a PopupMenu open after a click?

926 views
Skip to first unread message

bear...@googlemail.com

unread,
Feb 16, 2009, 1:31:23 PM2/16/09
to
Hi,

I am trying to stop my popupmenu from closing when i click it. I know
the simple hack is to just repopup the menu after the click but i
would like to keep the popupmenu structure intact before the click
(i.e. i might have gone down several subitems and i dont believe you
can repopup to the exact subitems state)

I notice TMS software has a component that can do this, but can anyone
save me some money and help me achieve the same thing without having
to buy it?

TAdvStickyPopupMenu -> http://www.tmssoftware.com/site/atbdev10.asp

Regards,

Chris

alang...@aol.com

unread,
Feb 17, 2009, 5:24:03 AM2/17/09
to
On 16 Feb, 18:31, beardi...@googlemail.com wrote:
>
> I am trying to stop my popupmenu from closing when i click it. I know
> the simple hack is to just repopup the menu after the click but i
> would like to keep the popupmenu structure intact before the click
> (i.e. i might have gone down several subitems and i dont believe you
> can repopup to the exact subitems state)
>

Here's one way of doing it for a popup on a form. Similar for other
objects.

procedure TForm1.FormCreate(Sender: TObject);
begin
// or set these in Object Inspector
PopUpMenu1.AutoPopup := false;
Form1.Popup := false;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
MousePoint : TPoint;
begin
if (Button = mbRight) then begin
MousePoint := ClientToScreen(point(X, Y)); // convert to Screen co-
ordinates
PopUpMenu1.PopUp(MousePoint.X, MousePoint.Y); // needs screen co-
ords
end;
end;

Alan Lloyd

JJ

unread,
Feb 17, 2009, 11:08:48 AM2/17/09
to

TAdvStickyPopupMenu doesn't use a standard popup menu. It only mimics
the standard popup menu in order to implement a "sticky" popup menu feature.

Similar method can be done using a TForm with bsNone BorderStyle. You'll
need to assign TForm OnPaint event in order to draw the popup menu modal
border using the DrawFrameControl Windows API function. The form should
contains one or more TLabel components to represent each menu item. Each
TLabel has its OnMouseOver event assigned in order to mimic the menu
selection by changing the TLabel Color and Font.Color.

To simplify things, create a new TForm decendant class where its
constructor prepares the required TLabels based on existing TPopupMenu
object.

codu...@btinternet.com

unread,
Jun 6, 2020, 10:52:20 AM6/6/20
to
It's a long time since this thread was active but I'll ask anyway.

I assume alang's Form1 is the application's original form, while jj's Form1 is a new form/unit?

alang: I don't see any Popup property for a TForm.

jj: I don't see any OnMouseOver event for a TLabel.

DrawFrameControl draws a blank on RAD Studio's Help.

Any chance of a working example? :-)
0 new messages