How can I hide a pop-up menu?

I can call "Popup" to bring up a pop-up menu. Then how can I hide the pop-up menu using any method or function?

Notice: I didn't like it cause the pop-up menu disapears to simulate a user clicks mouse.
DantryAsked:
Who is Participating?
 
rwilson032697Connect With a Mentor Commented:
How about sending the popup an ESC char, like this:

SendMessage(Popup.handle, WM_CHAR, VK_ESC, 0);

(or should that be ..., 0, VK_ESC) ? )

Cheers,

Raymond.
0
 
johnwaCommented:
you can just set all the items's Visible property of the popmenu  to false.
0
 
jeurkCommented:
Hello, I don't understand what you want.
Is your problem maybe related with the popup menu of a tray icon ?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ITugayCommented:

procedure HidePopUpMenu(PP : TPopupMenu);
begin
      Popuplist.Remove(PP);
      PopupList.Add(PP);
end;

Best regards,
Igor.
0
 
DantryAuthor Commented:
Hello Johnwa!

I couldn't set all the items's Visible property of the popmenu to false because every item has own status about visible or disvisible.

And your advice is very cockamamie when the menu has many items and the operator about setting popup or hiding is frequent.

Thanks for helping me! I hope to see you again in the experts-exchange.
0
 
DantryAuthor Commented:
All above answers couldn't help me.

If you try the first method of set all menuitems' visible property equate FALSE, you will find although all menuitems disapear some small popup menu still exist. Please try!

The ITugay's method I couldn't go deep into understanding. In Delphi 3.0, the Remove method can be used by the TList, TMenuItem and TThreadItem objects. All of them refuse the TPopupMenu Parameter.

Thanks for your help. But I don't gain a feasible method.
0
 
DantryAuthor Commented:
Raymond:

Hi! You give me a good suggestion to use API. I already try but the popup menu seem not to receive the message.

Please confirm the second parameter. Oh, can do you help me again? It is my expectancy.

When I scan your profile, I very glad to find a eldership in GIS and GPS. Can I record your address and bother you sometimes?

                        friendly,
                         Dantry
               
0
 
ITugayCommented:
to Dantry,

There is difficulties. Popupmenu1.Popup(X,Y) is working like ShowModal.

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
   Popupmenu1.Popup(100,100);
   Application.ProcessMessages; // set breakpoint here and see what happen
end;

My solution is working when Popup(X,Y) and HidePopUpMenu is called from different threads. I'm not sure that it will work in D3. Is it possible to show code you use to check our samples.

About my method:

------------- Delphi help --------------
Use PopupList to access all the popup menus in the application or access the window handle of the window that responds to popup menu messages. PopupList maintains a list of all the popup menu components created in an application. It holds the handle of a hidden window that centralizes the processing of Windows messages directed at these popup menus.
------------

If you remove PopupMenu from PopupList, it MUST close popup menu window. May be it help somebody to make solution for you.

Cheers,
Igor.

PS: PopupList inherits from TList.
0
 
DantryAuthor Commented:
Hi, my friends, I already find a easy way to disappear a pop-up menu. Let us share the result.

When the pop-up menu in the main form:
    PostMessage(Handle, WM_KEYDOWN, VK_ESCAPE, 0);

I must thank Raymond again for his(her) idea. But it is noticed that the escape message have to the parent of the pop-up menu. In the example, the first parameter is the main form's handle because it is the pop-up menu's parent.

Please try again, you will accept the result.

0
 
DantryAuthor Commented:
Raymond:

Hello!
Thanks. Hope meet you again.

friendly,
Dantry
0
 
ITugayCommented:
it look like points for Raymond;-)
0
 
DantryAuthor Commented:
Oh, I'm mazed by the experts-exchange.
Why it display 'Points: 10' in the end?
How many points did I give Raymond?
Why do I have 115 points?

Help! ITugay, are you tell me the detail rules about the game? Can I dispatch the points to several men?
0
 
ITugayCommented:
10 points * 4(A excelent) = 40
                * 3(B good) = 30 to Raymond.
etc.  

To tell you trust, it must be approx from 50 to 150 points for you question (not 10).

To dispatch points to Raymond you need ask a question: "points to rwilson".
Then Raymond send comments (Hello!), and you accept comments as answer.

Cheers,
Igor.

0
 
ITugayCommented:
I miss something, it was 100 points at first (not 10, sorry) and 10 points on the end. It is remaining price of you question after it answered.


Igor.
0
 
rwilson032697Commented:
Hi Dantry,

Thanks for the points. My email address is raymond.wilson@trimble.co.nz, or ripplesoftware@hotmail.com.

Cheers,

Raymond.
0
All Courses

From novice to tech pro — start learning today.