Solved

How to hide a popupmenu with a code?

Posted on 1998-04-11
5
252 Views
Last Modified: 2011-09-20
There are methods for destroying
the menu, but how to just hide it?
0
Comment
Question by:raunol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

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

Author Comment

by:raunol
ID: 1361405
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
ID: 1361406
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
ID: 1361407
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
ID: 1361408
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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