LockSetForegroundWindow - Keep the darn window visible no matter what

Posted on 2004-11-05
Last Modified: 2008-01-09
I have to keep a dialog box visible until I take action to remove it. I have a full screen window with a couple of other dialog boxes on top. One of the dialoga is a child of the full screen window and behaves pretty well. The other is NOT a child of the full screen and ends up getting lost in the Z order. I can, and do, send messages to the creating thread to redisplay the dialog when I do something to hide it but it's a pain. I have to think there is a way to force a window to stay on top no matter what.
I really thought that LockSetForegroundWindow would do it but it doesn't.
Same general topic - When I came upon LockSet....... in the documentation I tried it but the compile failed. Couldn't seem to find the function or the defines that go with it. They are in WinUser.h as:
#if(_WIN32_WINNT >= 0x0500)     // I had to manually #define this thing to get it to work.
WINUSERAPI                                // There has to be a better way!!!
    DWORD dwProcessId);

#define ASFW_ANY    ((DWORD)-1)

    UINT uLockCode);

#define LSFW_LOCK       1
#define LSFW_UNLOCK     2

#endif /* _WIN32_WINNT >= 0x0500 */
Question by:sandbar
    LVL 86

    Accepted Solution

    >>There has to be a better way!!!

    The easiest way is to set the 'WS_EX_TOPMOST' style bit for that window.
    LVL 86

    Expert Comment

    BTW, see also;en-us;108315 ("How To Keep an MDI Window Always on Top") if we're talking MDI...

    Author Comment

    Thank you jkr - I know it would be simple, but then everything is somple once you find it!

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now