Link to home
Start Free TrialLog in
Avatar of Dantry
Dantry

asked on

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.
Avatar of johnwa
johnwa

you can just set all the items's Visible property of the popmenu  to false.
Hello, I don't understand what you want.
Is your problem maybe related with the popup menu of a tray icon ?

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

Best regards,
Igor.
Avatar of Dantry

ASKER

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.
Avatar of Dantry

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dantry

ASKER

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
               
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.
Avatar of Dantry

ASKER

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.

Avatar of Dantry

ASKER

Raymond:

Hello!
Thanks. Hope meet you again.

friendly,
Dantry
it look like points for Raymond;-)
Avatar of Dantry

ASKER

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?
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.

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.
Hi Dantry,

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

Cheers,

Raymond.