OK... here's the hack...This may or may not help you. 
Not quite what you're after, I realised, BUT you could stick the MenuAtPt() call in a 
timer and call some proc when it eventually returns false. I am very ashamed of having 
thought up such horrible code ;) I don't recommend anyone use this sort of code in a 
production system. Luckily, I was able to avoid using this eventually :)

function GetControlAtPt(p:TPoint): TWinControl;
begin
  Result := FindControl(WindowFromPoint(P));
end;

function MenuAtPt(p: TPoint; fm:TCustomForm): boolean;
var
  c:TControl;
begin
  Result := False;
  { this is a lot of a fudge! if there's no control beneath the mouse and 
  it's inside the bounds of the main window then assume it's a menu that's beneath it}
  if PtInRect(fm.BoundsRect, p) then begin
    c := GetControlAtPt(p);
    if not Assigned(c) then
      Result := True;
  end;
end;


HTH,

Chris


> -----Original Message-----
> From: Chris Milham 
> Sent: Monday, 21 October 2002 4:22 p.m.
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: How to add an OnClose event to a TPopup menu?
> 
> 
> My short answer, and please correct me if I'm wrong, is that 
> it's not possible.
> I had so may fun & games a while back trying to do the same thing.
> It appears to be a limitation of the Win API menus that Delphi wraps.
> I had to do some horrible hack to simulate this but can't 
> remember what, or where it is now.
> Will have a quick dig around for it now.
> 
> Chris
> 
> -----Original Message-----
> From: Jason Coley [mailto:Jason@;software-solutions.co.nz]
> Sent: Monday, 21 October 2002 4:16 p.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: How to add an OnClose event to a TPopup menu?
> 
> 
> Does anyone know how to add an OnClose event to a TPopup menu?
> 
> Regards
> Jason
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to