Solved

How to hide a popupmenu with a code?

Posted on 1998-04-11
5
247 Views
Last Modified: 2011-09-20
There are methods for destroying
the menu, but how to just hide it?
0
Comment
Question by:raunol
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:inter
Comment Utility
Hi,
Let pm be a tpopupmenu, does the following work?
  ShowWindow(pm.handle, SW_HIDE);
Igor
0
 

Author Comment

by:raunol
Comment Utility
No, Igor, it doesen't. I have tried that.
I want to hide open popupmenu in OnTimer -event.
If I use menu.free or menu.destroy functions the
menu do disapear but destroing the same.

Is there any way only hide it? Perhaps some code
could imitate mouse or keyboard-Click so that the
menu hides like normally?

But if there's not, it is welcome wice too,
how to bild fully functional identical menu
again, after destroying.

- Rauno
0
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
Comment Utility
Please insert the following in your timer routine:

  PostMessage(Handle, WM_LBUTTONDOWN,MK_LBUTTON,0);
  PostMessage(Handle, WM_LBUTTONUP,MK_LBUTTON,0);

The problem is that popup menu is tracked with TrackPopupMenu which doesnot return until a menu is selected, clicked on other components or a special key is pressed

Regards,
Igor
0
 
LVL 1

Expert Comment

by:pjdb
Comment Utility
I suggest to send an escape key with the following code

keybd_event(vk_escape, $45, keyeventf_extendedkey or 0, 0);
keybd_event(vk_escape, $45, keyeventf_extendedkey or keyeventf_keyup, 0);

I think it's better since the click can occur on any control and can cause an undesired action.

JDB
0
 

Author Comment

by:raunol
Comment Utility
Thank's Igor and JDB.

Both solutions are very good.
I should like to grade half of points for both of
You, but I don't know how this system works, I have
used this a short time. It seems to give me a
possibility to grade only the first answer.

But - If I may to put them the order - Postmessage
seems a little bit better for my meanings in this
time, because keaboard action - for some reasons -
causes the menu quicly flash ones, before it disapear,
but Postmessage don't. And also, JDB, postmessage-click
occurs only the handle points and in this case it
causes any problems for me.

However, Thanks wery much you too, JDB. Also Your
solution was good and works. I'm sorry about points.

BTW, I Should want to delete my difficult
Opendialog-Handle guestion and "save" my few
points ;-)
But I don't find any options to do so. Have
You any adwices about that?

Regards

- Rauno

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now