Link to home
Start Free TrialLog in
Avatar of raunol
raunolFlag for Finland

asked on

How to hide a popupmenu with a code?

There are methods for destroying
the menu, but how to just hide it?
Avatar of inter
inter
Flag of Türkiye image

Hi,
Let pm be a tpopupmenu, does the following work?
  ShowWindow(pm.handle, SW_HIDE);
Igor
Avatar of raunol

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of inter
inter
Flag of Türkiye image

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 pjdb
pjdb

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
Avatar of raunol

ASKER

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