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

missing TPopupMenu features?

1,790 views
Skip to first unread message

Bogdan X

unread,
May 19, 2000, 3:00:00 AM5/19/00
to
How do I check if the popup-menu is visible to the user (if it has poped
up)? There is no TPopupMenu.visible property (it is not derived from
TControl).
Isn't there a TPopupMenu.OnPopdown :) event ?

Bogdan X

Peter Below (TeamB)

unread,
May 20, 2000, 3:00:00 AM5/20/00
to
In article <8g47km$mc...@bornews.borland.com>, Bogdan X wrote:
> How do I check if the popup-menu is visible to the user (if it has poped
> up)? There is no TPopupMenu.visible property (it is not derived from
> TControl).
Where would you place such a check? Windows takes over the message processing
when the menu pops up and you don't get control back until the menu is closed.

In D5 there is finally a method to detect when the menu was closed without a
selection (i.e. none of the menuitem OnClick handlers fired). Add the unit
below to your project and the form the popup menu is on will receive the
custom messages defined in the unit when the menu appears or closes.

unit ExPopupList;

interface

uses Controls;

const
CM_MENUCLOSED = CM_BASE - 1;
CM_ENTERMENULOOP = CM_BASE - 2;
CM_EXITMENULOOP = CM_BASE - 3;

implementation

uses Messages, Forms, Menus;

Type
TExPopupList = class( TPopupList )
protected
procedure WndProc(var Message: TMessage); override;
end;

{ TExPopupList }

procedure TExPopupList.WndProc(var Message: TMessage);
Procedure Send( msg: Integer );
Begin
If Assigned( Screen.Activeform ) Then
Screen.ActiveForm.Perform( msg, Message.wparam, Message.lparam );
End;
begin
Case message.Msg Of
WM_ENTERMENULOOP: Send( CM_ENTERMENULOOP );
WM_EXITMENULOOP : Send( CM_EXITMENULOOP );
WM_MENUSELECT :
With TWMMenuSelect( Message ) Do
If (Menuflag = $FFFF) and (Menu = 0) Then
Send( CM_MENUCLOSED );
End; { Case }
inherited;
end;

Initialization
Popuplist.Free;
PopupList:= TExPopupList.Create;
// Note: will be freed by Finalization section of Menus unit.
end.

Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitly requested!


0 new messages