?
Solved

LockSetForegroundWindow - Keep the darn window visible no matter what

Posted on 2004-11-05
3
Medium Priority
?
1,263 Views
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!!!
BOOL
WINAPI
AllowSetForegroundWindow(
    DWORD dwProcessId);

#define ASFW_ANY    ((DWORD)-1)

WINUSERAPI
BOOL
WINAPI
LockSetForegroundWindow(
    UINT uLockCode);

#define LSFW_LOCK       1
#define LSFW_UNLOCK     2

#endif /* _WIN32_WINNT >= 0x0500 */
0
Comment
Question by:sandbar
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 12508535
>>There has to be a better way!!!

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

Expert Comment

by:jkr
ID: 12508553
BTW, see also http://support.microsoft.com/default.aspx?scid=kb;en-us;108315 ("How To Keep an MDI Window Always on Top") if we're talking MDI...
0
 

Author Comment

by:sandbar
ID: 12523146
Thank you jkr - I know it would be simple, but then everything is somple once you find it!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
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.
Suggested Courses

809 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