Solved

how to put my dialog top of all windows

Posted on 2000-04-22
5
383 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

680 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