So I am trying to hide a pop up menu when another dialog appears. I tried destroying the pop up menu but that is too destructive and that disables the pop up menu all together. I simple want to force the menu back down and hide until the user clicks on the menu again.
I tried forced a phantom screen tap to make the popup menu disappear. But I realized there are too many active areas on the screen and I might initiate an invalid command on the dialog.
Does anyone know how to force a popup menu to go back down?
If you want to try to simulate a keyboard event without accidentally pressing something, try this...
keybd_event(VK_ATTN, 0, KEYEVENTF_SILENT, 0);
Not sure if that will do the job or not. I use that for keeping the screen from dimming during long operations in my software.
You might also try finding the handle of that menu and sending it a message. Use Remote Spy to see what the class name or window name is, then put a FindWindow call in your code to get the handle to that window. Not sure if a popup menu will respond to WM_CLOSE, but it's worth a shot.
Interestingly enough, I tried that yesterday and it didn't seem to work. I tried simulating an "esc" key press. But the problem seems to be that the dialog is not listen anymore.
In my program, I have the threads runnning. One thread is the program itself, while another thread communicates with devices. When a device is disconnected, the communication thread brings up a disconnection dialog and makes that dialog active.
But I then need to tell the main program thread to close the popup menu that is in the application dialog. But since the program dialog is no longer active, the request to close the popup menu doesn't seem to be going through.
Maybe I don't have the correct handle.
Is there a universal call to close all popup menus? Regardless of who owns it?
Thanks for the help though! :)