Solved

how to put my dialog top of all windows

Posted on 2000-04-22
5
380 Views
Last Modified: 2008-02-01
I have a thread to monitor a special event. if the event happens, the thread will send a message to my main program.
Then the program will creat a modal dialog. I hope this dialog displays at the top of all windows. I learned SetForegroundWindows can do it. I put this function in the dialog class( in OnInitdialog),but it can't work. What's wrong?
0
Comment
Question by:seuwind
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2741311
SetForegroundwindow works on a window which is already showing. I suspect that your problem is a timing issue more than anything else. I'd suggest you make the same call after trapping the Wm_Show message of the dialog. Otherwise, launch the form and make the call a second or so afterwards. (perhaps using a timer)


Good luck!!  
0
 
LVL 1

Accepted Solution

by:
Rheingold earned 50 total points
ID: 2741440
Hi

did you try SetWindowPos with the HWND_TOPMOST flag? This makes appear a window in front of all other windows on the screen, nevertheless if they are created by the calling thread or not.

Regards
0
 

Author Comment

by:seuwind
ID: 2741511
Thanks, DrDelphi and Rheinqold
I do as you told me, but it still doesn't work. I wonder where should I call the SetWindowPos. Is it true to call it in OnInitDialog?
0
 

Author Comment

by:seuwind
ID: 2741530
Oh, I success
It is true to call SetWindowPos in OnInitDialog. I made a mistake just now.Now it works properly.But I still want to know why SetForegroundWindow doesn't work. If you know,pleas tell me.
Thank you.

Regards
0
 
LVL 1

Expert Comment

by:Rheingold
ID: 2741680
Thanx for the points, but I'm sorry that I don't know why SetForegroundWindow didn't work.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

920 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

17 Experts available now in Live!

Get 1:1 Help Now