Solved

how to put my dialog top of all windows

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 62
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 471
How to split this in C++ 4 106
Beginner to Unreal Engine 4 5 94
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

839 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