...Close / Hide a TPopupMenu?

Author: Alexandre Trindade e Thiago Pagels
Homepage: http://www.habitus.com.br

Category: VCL

{---------------------------------------------------------------------
This code shows how to hide a TPopupMenu without destroying it!!

Put this code on the form that has owned the popup menu.
It simulates a mouse click (without click really), making windows think
that de user has clicked the mouse buttom and so hides the TPopupMenu.
---------------------------------------------------------------------}

procedure HidePopupMenu;
begin
  
PostMessage(Handle, WM_LBUTTONDOWN, MK_LBUTTON, 0);
  PostMessage(Handle, WM_LBUTTONUP, MK_LBUTTON, 0);
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base