Solved

how to put my dialog top of all windows

Posted on 2000-04-22
5
379 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanx for the points, but I'm sorry that I don't know why SetForegroundWindow didn't work.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

771 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

12 Experts available now in Live!

Get 1:1 Help Now