Link to home
Start Free TrialLog in
Avatar of seuwind
seuwind

asked on

how to put my dialog top of all windows

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?
Avatar of DrDelphi
DrDelphi

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!!  
ASKER CERTIFIED SOLUTION
Avatar of Rheingold
Rheingold

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of seuwind

ASKER

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?
Avatar of seuwind

ASKER

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
Thanx for the points, but I'm sorry that I don't know why SetForegroundWindow didn't work.