Solved

Closing a menu popup

Posted on 1998-09-17
12
296 Views
Last Modified: 2013-12-03
I am using C++Builder

I am disabling a menu on a timer. If the popup is active at
this time though it is not closed. I cannot seem to get the
popup to close whatever I do. I have tried sending several messages but to no avail ...

I only have access to the TMenu item (I even have it's HMENU), but that is not for the popup that appears when clicking on the menu.

Any suggestions
0
Comment
Question by:gysbert1
[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
  • 6
  • 6
12 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1414505
gysbert1,

I'm using Delphi but I think the components are almost the same. So I guess you use TPopupMenu. What does you mean with having only access to the TMenu item?

I think you should be able to do something like that:

DestroyWindow(popup1.windowHandle);

Hope this helps...

Regards, Madshi.
0
 
LVL 2

Author Comment

by:gysbert1
ID: 1414506
That is exactly my problem !

I am using a TMainMenu. It pops up a popup menu when you choose one of the main items listing the sub items. It is this menu I need to close. The popup is created dynamically.

    --------------
    |  File     |   <- Main Menu that was Clicked
    =========
    ||  Open      ||   <- Popup that I need to kill when I disable the File Menu
    ||  Close      ||
    ||--------------- ||
    ||  Print       ||
    ||  Options  ||
    =========

Exuse the skew art but it will give you an Idea.

If I can get the handle to the Popup I will be able to kill it, but how do I get that ?

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1414507
gysbert1,

do the following:

  EnableWindow(handle,false); EnableWindow(handle,true);

This will close the menu. It's a little bit tricky but works (at least with Delphi).

Regards, Madshi.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 2

Author Comment

by:gysbert1
ID: 1414508
Sorry !

That is exactly what the problem is !

How do I get the handle that I can pass to EnableWindow in order to close the menu window ? Actually I do not only want to disable the input to the window, I want to close it as well (as in CloseWindow(handle); ), but I WILL need the handle to do that.

The menu has a WindowHandle property, but that is the command handling entity's handle and not the Menu Window itself ...

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1414509
The TMainMenu component belongs to a form, doesn't it? Then just give the handle of the form in EnableWindow(...).
0
 
LVL 2

Author Comment

by:gysbert1
ID: 1414510
What good will that do ?

I want the form to keep on working and still be displayed. I want the thingy drawn above in my comment that pops up when you click on file in my application to dissapear without any action from the user.

Closing the form or disabling input to the form will prevent the user to access the Login menu that still has to be active in order for the user to gain full access again ...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1414511
Have you read my whole comment?

I wrote:

EnableWindow(handle,false); EnableWindow(handle,true);

That means, your form is disabled for about 0.00000000000000000001 seconds. You won't even see that.

AND the menu is closed with these two function calls. Just what you wanted. Please try it out!
0
 
LVL 2

Author Comment

by:gysbert1
ID: 1414512
WOW !!!

I am real stupid today ...

Sorry but I completely misunderstood your answer ... Should have commented first, I know ...

Bonus for you, in apology I adjusted the points. Please post an answer ...

0
 
LVL 20

Accepted Solution

by:
Madshi earned 200 total points
ID: 1414513
gysbert1,

no problem.   :-)
Thanx for the bonus points.

Regards, Madshi.

P.S: That means it works now?
0
 
LVL 2

Author Comment

by:gysbert1
ID: 1414514
Hows that for a bonus, twice what it was !!

Thanx for the help, not quite what I expected though ...


0
 
LVL 20

Expert Comment

by:Madshi
ID: 1414515
gysbert1,

  keybd_event(VK_ESCAPE,0,0,              0);
  keybd_event(VK_ESCAPE,0,KEYEVENTF_KEYUP,0);

is that better? This code simulates an escape key click.

Ok, both variants are not nice. Normally C++ Builder should close the popup for you. But since it doesn't you'll have to hack a little bit... I found no "normal" way to close that popup menu.   :-(

Regards, Madshi.
0
 
LVL 2

Author Comment

by:gysbert1
ID: 1414516
Aha !

That was what I thought would work. I cannot decide which would be best though :^(

I also would have liked the popup to be disabled automatically but it is not to be.

Thanx for the help !




0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Example of WebAPI 7 35
Download a file from microsoft that contains all hotfixes and updates 9 76
Post a good COM tutorial 1 66
What is MicroStrategy.NET? 2 80
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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