void CXTPSkinObjectFrame::UpdateFrameRegion(CSize szFrameRegion)
{
    if (m_bInUpdateRegion)
        return;

    m_bInUpdateRegion = TRUE;

    if (m_bRegionChanged && !HasCaption())
    {
        SetWindowRgn(NULL, TRUE);
        m_bRegionChanged = FALSE;
    }
//  DWORD dwStyle = GetStyle();

    if (HasCaption() && (m_szFrameRegion != szFrameRegion))
    {
        if (GetSkinManager()->IsEnabled() && GetSkinManager()->GetApplyOptions() & xtpSkinApplyFrame)
        {
            HRGN hRgn = GetSchema()->CalcFrameRegion(this, szFrameRegion);

            SetWindowRgn(hRgn, TRUE);
            m_bRegionChanged = TRUE;
        }
        else if (m_bRegionChanged)
        {
            SetWindowRgn(NULL, TRUE);
            m_bRegionChanged = FALSE;
        }

        m_szFrameRegion = szFrameRegion;
    }

    m_bInUpdateRegion = FALSE;
}
示例#2
0
void ThumbItem::InitCaption(bool get_caption)
{
    if (!HasCaption() && get_caption)
        SetCaption(GalleryUtil::GetCaption(m_path));
    if (!HasCaption())
        SetCaption(m_name);
}
void CXTPSkinObjectFrame::ResizeFrame()
{
    if (HasCaption() && m_pManager->IsEnabled())
    {
        CXTPWindowRect rc(this);

        DWORD dwStyle = GetStyle();
        DWORD dwExStyle = GetExStyle();

        if ((m_pManager->GetApplyOptions() & xtpSkinApplyMetrics) && ((dwStyle & WS_CHILD) == 0))
        {
            CRect rcWindow(rc);
            AdjustWindowRectEx(rcWindow, dwStyle, FALSE, dwExStyle);

            CRect rcSysWindow(rc);
            CXTPSkinManagerApiHook::AdjustWindowRectExOrig(rcSysWindow, dwStyle, FALSE, dwExStyle);

            rc.bottom -= rcSysWindow.Height() - rcWindow.Height();
            rc.right -= rcSysWindow.Width() - rcWindow.Width();

            MoveWindow(rc, FALSE);

        }

        UpdateFrameRegion(rc.Size());
    }
}
LRESULT VirtualDimension::OnDestroy(HWND /*hWnd*/, UINT /*message*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	RECT pos;
	Settings settings;

	// Before exiting, save the window position
	pos.left = m_location.x;
	pos.top = m_location.y;
	pos.right = m_location.x + deskMan->GetWindowWidth();
	pos.bottom = m_location.y + deskMan->GetWindowHeight();
	settings.SaveSetting(Settings::WindowPosition, &pos);
	settings.SaveSetting(Settings::DockedBorders, m_dockedBorders);

	//Save the snap size
	settings.SaveSetting(Settings::SnapSize, m_snapSize);

	//Save the auto-hide delay
	settings.SaveSetting(Settings::AutoHideDelay, m_autoHideDelay);

	//Save the visibility state of the window before it is hidden
	settings.SaveSetting(Settings::ShowWindow, m_isWndVisible);

	//Save the locking state of the window
	settings.SaveSetting(Settings::LockPreviewWindow, IsPreviewWindowLocked());

	//Save the visibility state of the title bar
	settings.SaveSetting(Settings::HasCaption, HasCaption());

	// Remove the tray icon
	delete trayIcon;

	// Cleanup transparency
	settings.SaveSetting(Settings::TransparencyLevel, transp->GetTransparencyLevel());
	delete transp;

	// Cleanup always on top state
	settings.SaveSetting(Settings::AlwaysOnTop, ontop->IsAlwaysOnTop());
	delete ontop;

	// Destroy the tooltip
	delete tooltip;

	// Destroy the mouse warp
	delete mousewarp;

	// Destroy the desktop manager
	delete deskMan;

	// Destroy the windows manager
	delete winMan;

	// Destroy the tray icons manager
	delete trayManager;

	PostQuitMessage(0);

	return 0;
}
void CXTPSkinObjectFrame::UpdateButtons()
{
    DWORD dwExStyle = GetExStyle();
    DWORD dwStyle = GetStyle();

    if (m_dwStyle == dwStyle && m_dwExStyle == dwExStyle)
        return;

    m_dwExStyle = dwExStyle;
    m_dwStyle = dwStyle;

    RemoveButtons();

    if (HasCaption())
    {
        BOOL bToolWindow = (dwExStyle & WS_EX_TOOLWINDOW) == WS_EX_TOOLWINDOW;
        BOOL bMaximized = (dwStyle & WS_MAXIMIZE) == WS_MAXIMIZE;
        BOOL bMinimized = (dwStyle & WS_MINIMIZE) == WS_MINIMIZE;

        BOOL bSysMenu = (dwStyle & WS_SYSMENU);
        BOOL bDialogFrame = (dwStyle & WS_DLGFRAME || dwExStyle & WS_EX_DLGMODALFRAME);

        BOOL bEnableClose = TRUE;
        BOOL bEnabledMaximize = ((dwStyle & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX);
        BOOL bEnabledMinimize = ((dwStyle & WS_MINIMIZEBOX) == WS_MINIMIZEBOX);
        BOOL bShowMinMaxButtons = !bToolWindow && bSysMenu && (bEnabledMaximize || bEnabledMinimize);

        if (bSysMenu && !bToolWindow && ((m_dwExStyle & WS_EX_MDICHILD) == 0))
        {
            HMENU hMenu = ::GetSystemMenu(m_hWnd, FALSE);
            if (::GetMenuState(hMenu, SC_CLOSE, MF_BYCOMMAND) & (MF_DISABLED | MF_GRAYED)) bEnableClose = FALSE;
        }

        UpdateButton(SC_CLOSE, !bDialogFrame || bSysMenu,
                     bEnableClose, HTCLOSE, bToolWindow? WP_SMALLCLOSEBUTTON: WP_CLOSEBUTTON);

        UpdateButton(SC_MAXIMIZE, !bMaximized && bShowMinMaxButtons,
                     bEnabledMaximize, HTMAXBUTTON, WP_MAXBUTTON);

        if (bMinimized)
        {
            UpdateButton(SC_RESTORE, bShowMinMaxButtons,
                         bEnabledMinimize, HTMINBUTTON, WP_RESTOREBUTTON);
        }
        else
        {
            UpdateButton(SC_RESTORE,  bMaximized && bShowMinMaxButtons,
                         bEnabledMaximize, HTMAXBUTTON, WP_RESTOREBUTTON);

            UpdateButton(SC_MINIMIZE, bShowMinMaxButtons,
                         bEnabledMinimize, HTMINBUTTON, WP_MINBUTTON);
        }

        UpdateButton(SC_CONTEXTHELP, ((dwExStyle & WS_EX_CONTEXTHELP) == WS_EX_CONTEXTHELP) && !bToolWindow && bSysMenu,
                     TRUE, HTHELP, WP_HELPBUTTON);
    }

}
void CXTPSkinObjectFrame::OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
{
    CXTPSkinObject::OnStyleChanged(nStyleType, lpStyleStruct);

    m_rcBorders = GetSchema()->CalcFrameBorders(this);

    if (((lpStyleStruct->styleNew ^ lpStyleStruct->styleOld) & (WS_EX_TOOLWINDOW | WS_BORDER | WS_DLGFRAME | WS_THICKFRAME)))
    {
        CXTPWindowRect rc(this);
        m_szFrameRegion = CSize(0);
        UpdateFrameRegion(rc.Size());

    }
    if (HasCaption()) PostMessage(WM_NCPAINT);

}
void CXTPSkinObjectFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
    CXTPSkinObject::OnGetMinMaxInfo(lpMMI);

    if (m_pManager->HasApplyOptions(xtpSkinApplyFrame) && HasCaption())
    {
        int yMin = m_rcBorders.top + m_rcBorders.bottom;
        int xMin = (int)m_arrButtons.GetSize() * m_rcBorders.top;

        xMin += GetSystemMetrics(SM_CYSIZE) + 2 * GetSystemMetrics(SM_CXEDGE);

        lpMMI->ptMinTrackSize.x = max(lpMMI->ptMinTrackSize.x, xMin);
        lpMMI->ptMinTrackSize.y = max(lpMMI->ptMinTrackSize.y, yMin);
    }

    if (m_pManager->HasApplyOptions(xtpSkinApplyFrame | xtpSkinApplyMetrics) && ((GetExStyle() & WS_EX_MDICHILD) == WS_EX_MDICHILD))
    {

        int nDelta = m_rcBorders.top + lpMMI->ptMaxPosition.y;
        lpMMI->ptMaxPosition.y -= nDelta;
        lpMMI->ptMaxSize.y += nDelta;
    }
}
BOOL CXTPSkinObjectFrame::OnNcActivate(BOOL bActive)
{
    if (HasCaption())
    {
        CallDefDlgProc(WM_NCACTIVATE, (WPARAM)bActive, 0);

        if (!bActive)
        {
            CWnd* pWnd = CWnd::FromHandlePermanent(m_hWnd);
            // Mimic MFC kludge to stay active if WF_STAYACTIVE bit is on
            //
            if (pWnd && pWnd->m_nFlags & WF_STAYACTIVE)
                bActive = TRUE;

            if (!IsWindowEnabled())
                bActive = FALSE;
        }


        HWND hWndClient = FindMDIClient();
        HWND hWndActive = hWndClient ? (HWND)::SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0) : NULL;

        if (hWndActive != m_hWnd && hWndActive)
        {
            ::SendMessage(hWndActive, WM_NCACTIVATE, bActive, 0);
            ::SendMessage(hWndActive, WM_NCPAINT, 0, 0);
        }

        m_bActive = bActive;            // update state

        RedrawFrame();
        return TRUE;
    }

    return CXTPSkinObject::OnNcActivate(bActive);
}
LRESULT VirtualDimension::OnCmdShowCaption(HWND /*hWnd*/, UINT /*message*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	ShowCaption(!HasCaption());

	return 0;
}