Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to control a dialog's property value . It has a property named TopMost. The values type of Property are true and false.
I have two dialog, one,screen, is to display DTV, another one is to control the screen's mode.
I want to make the screen dialog's Z-Order up to the TopMost.
How can I do to get the dialog property?

Could you give me some suggestion.
Thank you a lot.
Posted
Updated 4-Jul-12 21:12pm
v3

Assuming you are using Win32 then you need to set and unset the dialog's WS_EX_TOPMOST style as described here[^].
 
Share this answer
 
Comments
fashionable0910 8-Jul-12 9:11am    
Thanks for your answer. It's useful.
In fact,I need to add a button to control the screen status.
I don't know how to set the class wizard...
Richard MacCutchan 8-Jul-12 9:23am    
In fact,I need to add a button to control the screen status. OK, add a button to the dialog and connect it to a handler.

I don't know how to set the class wizard. Sorry, I don't understand, the class wizard is invoked from the Visual Studio IDE, it has nothing to do with the way your dialog operates.
To change the z-order at runtime, use the SetWindowPos[^] function.
 
Share this answer
 
Comments
fashionable0910 8-Jul-12 9:25am    
I used the function.

The following is my code.

bool _Status=false;
BOOL screen::CheckScreenZOrder(bool _status=false)
{
if(_status==_Status)
{
_status=true;
CWnd::SetWindowPos(
&wndTopMost,
gcProgInfoPool.Video_Size.Video_X,
gcProgInfoPool.Video_Size.Video_Y,
gcProgInfoPool.Video_Size.VideoWidth,
gcProgInfoPool.Video_Size.VideoHeight,
SWP_SHOWWINDOW
);
return _status;
}
if(_status!=_Status)
{
_status=false;
CWnd::SetWindowPos(
&wndNoTopMost,
gcProgInfoPool.Video_Size.Video_X,
gcProgInfoPool.Video_Size.Video_Y,
gcProgInfoPool.Video_Size.VideoWidth,
gcProgInfoPool.Video_Size.VideoHeight,
SWP_SHOWWINDOW
);
return _status;
}

}

But I don't know how to add the code into a button.
Then make it work.
«_Superman_» 8-Jul-12 9:36am    
Add the code to the BN_CLICKED notification handler. You can add the handler for BN_CLICKED using the class wizard. If you're using an MFC project, simply double clicking on the button will create the handler for you.
fashionable0910 8-Jul-12 10:39am    
If I use the following code. The button can work

sc.SetWindowPos(&wndTopMost,
NULL,NULL,
/* gcProgInfoPool.Video_Size.Video_X,
gcProgInfoPool.Video_Size.Video_Y,
gcProgInfoPool.Video_Size.VideoWidth,
gcProgInfoPool.Video_Size.VideoHeight*/
NULL,
NULL,
SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE
);
But when I use the following code. The button can't work.

bool _status=false;
void CHitop_appDlg::OnBnClickedButton2()
{
if(_status=false){

sc.SetWindowPos(&wndTopMost,
NULL,NULL,
/* gcProgInfoPool.Video_Size.Video_X,
gcProgInfoPool.Video_Size.Video_Y,
gcProgInfoPool.Video_Size.VideoWidth,
gcProgInfoPool.Video_Size.VideoHeight*/
NULL,
NULL,
SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE
);
_status=true;
}
else if(_status==true)
{
sc.SetWindowPos(&wndNoTopMost,
NULL,NULL,
//gcProgInfoPool.Video_Size.Video_X,
//gcProgInfoPool.Video_Size.Video_Y,
//gcProgInfoPool.Video_Size.VideoWidth,
//gcProgInfoPool.Video_Size.VideoHeight
NULL,
NULL,
SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE
);
_status=false;
}
}
I don't understand the question. But if you want to show your window on top of other ones, then you need to call BringWindowToTop. If you want to bring the window to top and make it active, you should call SetForegroundWindow instead.
If you want to change the top most attribute, then you have to get it by GetWindowLong and set by SetWindowLong. Read more about windows styles and extended styles.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900