Making your dialog stay on top
Haven't you seen programs which have an "always-stay-on-top" option? Well the unbelievable thing is that you can make your dialog stay on top with just one line of code. Simply put the following line in your dialog class's OnInitDialog() function.
SetWindowPos(&this->wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
Basically what we are doing is to use the SetWindowPos function to change the Z-order of our dialog window. We make our dialog stay on top of all other windows by moving it to the top of the Z-order. Now even when you activate some other window, our window will stay on top. But I'd advise you to make sure you know exactly what you are doing when you do this, for it might annoy people if they can't get your window out of the way when they want to do that.
本文介绍了一种简单的方法,只需一行代码即可使Windows应用程序中的对话框始终保持在所有其他窗口之上。通过调整窗口的Z顺序使用SetWindowPos函数实现这一功能。
3471

被折叠的 条评论
为什么被折叠?



