VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Demo: Popup Window (like menu or drop-down windows) (No hooks)

by James Vincent Carnicelli (21 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

One of the most common types of a focus-only popup window is the menu. A drop-down list is another example. Both disappear when they lose focus.

Here's a demonstration of how to do that. It doesn't rely on the LostFocus event, which only works within that form's scope. Switch to a different application and your popup would still be visible. Instead, it uses a timer and an API call to check to see if the popup still has global focus. If not, it self-unloads.

While it does act essentially like menu-style popup windows, it's not exactly the same. To do that, I think it's necessary to use an API call to hook into some Windows event that detects a change in overall focus. This technique relies on constantly polling the OS. It also means the form that uses the popup will technically lose focus (big deal). It's generally a little klunky. Still, it works very well.

Thanks go out to MrGTI (www.Pharfruminsain.com) for advice on the basic technique. I encourage anyone who knows the "right" way of doing this to let me know.

Please vote for this code if you like it.

Rate Demo: Popup Window (like menu or drop-down windows) (No hooks)

Download Demo: Popup Window (like menu or drop-down windows) (No hooks)

Download Demo: Popup Window (like menu or drop-down windows) (No hooks) (2 KB)

Demo: Popup Window (like menu or drop-down windows) (No hooks) Comments

No comments have been posted about Demo: Popup Window (like menu or drop-down windows) (No hooks). Why not be the first to post a comment about Demo: Popup Window (like menu or drop-down windows) (No hooks).

Post your comment

Subject:
Message:
0/1000 characters