Solved

Closing a menu popup

Posted on 1998-09-17
12
298 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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