说明:
以下函数对于POPUP窗口有效,对于子窗口好像不行。
//最小化按钮有效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) | WS_MINIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//最小化按钮无效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) &~WS_MINIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//最大化按钮有效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) | WS_MAXIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//最大化按钮无效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) &~WS_MAXIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//关闭按钮有效
::EnableMenuItem(::GetSystemMenu(m_hWnd,false),SC_CLOSE,MF_BYCOMMAND | MF_GRAYED);
//关闭按钮无效
::EnableMenuItem(::GetSystemMenu(m_hWnd,false),SC_CLOSE,MF_BYCOMMAND | MF_ENABLED);
//工具栏窗口。在任务栏上没有程序显示,需要添加在OnInitDialog()里
::SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(m_hWnd,GWL_EXSTYLE)
&~WS_EX_APPWINDOW|WS_EX_TOOLWINDOW );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
//添加标题栏
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
| WS_CAPTION );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//取消标题栏
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//取消标题栏,保留3d边框,可调整窗口大小
::SetWindowLong(m_hWnd,GWL_STYLE, GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION | WS_THICKFRAME );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); //一定要加这句设置才会立即生效
//取消标题栏和3d边框,保留一个线条的细边框,不能调整窗口大小
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION & ~WS_THICKFRAME | WS_BORDER );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//如果有WS_EX_DLGMODALFRAME还要取消WS_EX_DLGMODALFRAME
// ::SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(m_hWnd,GWL_EXSTYLE)
// & ~WS_EX_DLGMODALFRAME);
// ::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
//取消所有边框
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION & ~WS_THICKFRAME );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
// //如果有WS_EX_DLGMODALFRAME还要取消WS_EX_DLGMODALFRAME
// ::SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(m_hWnd,GWL_EXSTYLE)
// & ~WS_EX_DLGMODALFRAME);
// ::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
VC++6.0 如何去掉MFC向导生成的SDI程序中视图边框的3D效果2010-03-24 17:48先要去掉view的边框,代码如下:
BOOL CSDIView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &=~WS_BORDER;//加入的代码
return CFormView::PreCreateWindow(cs);
}
然后在去掉外部Frame的客户区边框,代码如下:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.dwExStyle&=~WS_EX_CLIENTEDGE;//加入的代码,一定要在CFrameWnd::PreCreateWindow(cs)之后执行
return TRUE;
}
http://blog.csdn.net/qing666888/article/details/49683023
时间: 2024-10-15 01:16:34