Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Closing a menu popup

Posted on 1998-09-17
12
Medium Priority
?
300 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 800 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 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