1.自绘标题,保留系统按钮
窗口style需要是WS_OVERLAPPEDWINDOW
我之前用了WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_BORDER|WS_CAPTION;没有WS_THICKFRAME,开启Aero时,界面启动后会有一个白边框,刷新后正常。
2.aero时窗口的透明效果在激活和非激活时是不同的,如果你的界面要保留这种效果,就要让系统处理wm_ncpaint消息。
3.系统按钮区域有子窗口时,怎样显示系统按钮。
一般来说,很多界面都会自己绘制系统按钮,当切换到aero效果时,自绘的按钮窗口将会遮盖住系统按钮。
有两种方法可以解决这个问题:
1)在子窗口的wm_mousemove消息里,模拟消息发送给框架窗口
void CSystembarCtrl::OnMouseMove( WPARAM wParam, LPARAM lParam )
{
if (_bDrawVistaEffects)
{
POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
HWND hFrame = GetAncestor( m_hWnd, GA_ROOT );
if (hFrame)
{
POINT ptScreen = point;
ClientToScreen(m_hWnd, &ptScreen);
DWORD dwPos = MAKELONG(ptScreen.x, ptScreen.y);
int nHittest = SendMessage(hFrame, WM_NCHITTEST, 0, dwPos);
PostMessage(hFrame, WM_NCMOUSEMOVE, nHittest, dwPos);
}
}
}
2)在子窗口的wm_nchittest消息里,调用DwmDefWindowProc
LRESULT CMFCRibbonBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (_bDrawVistaEffects)
{
if (message == WM_NCHITTEST)
{
LRESULT lResult = DwmDefWindowProc(GetParent()->GetSafeHwnd(), message, wParam, lParam);
if (lResult == HTCLOSE || lResult == HTMINBUTTON || lResult == HTMAXBUTTON)
{
return HTTRANSPARENT;
}
}
}
DefWindowProc();
}