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 CXTPDockingPaneSidePanel::OnNcHitTest(CPoint point)
{
	if (m_bCollapsed && !m_bExpanded)
		return HTCLIENT;

	CXTPWindowRect rcWindow(this);
	CRect rcBorders = rcWindow;
	rcBorders.DeflateRect(3, 3);

	if (rcWindow.PtInRect(point) && !rcBorders.PtInRect(point))
	{
		rcBorders.DeflateRect(8, 8);

		int ht = 0;

		if (point.y < rcBorders.top && IsResizable(HTTOP))
			ht = (HTTOP - HTSIZEFIRST + 1);
		else if (point.y >= rcBorders.bottom  && IsResizable(HTBOTTOM))
			ht = (HTBOTTOM - HTSIZEFIRST + 1);

		if (point.x < rcBorders.left && IsResizable(HTLEFT))
			ht += (HTLEFT - HTSIZEFIRST + 1);
		else if (point.x >= rcBorders.right  && IsResizable(HTRIGHT))
			ht += (HTRIGHT - HTSIZEFIRST + 1);

		return (LRESULT)(ht + HTSIZEFIRST - 1);
	}

	return HTCLIENT;
}
Example #3
0
void CXTPEditListBox::Initialize(bool bAutoFont/*= true*/)
{
	CXTPListBox::Initialize(bAutoFont);

	// get a pointer to the parent window.
	m_pParentWnd = GetParent();
	ASSERT_VALID(m_pParentWnd); // must be valid.

	// Create the edit toolbar group.
	if (!HasToolbar())
		return;

	// Create the toolbar.
	if (!CreateEditGroup(bAutoFont))
		return;

	// Resize the edit list which will also cause WM_WINDOWPOSCHANGED
	// to be called to position the toolbar.
	CXTPWindowRect rcWindow(this);
	rcWindow.top += BTN_OFFSET + ::GetSystemMetrics(SM_CXEDGE);
	m_pParentWnd->ScreenToClient(&rcWindow);

	::SetWindowPos(GetSafeHwnd(), NULL, rcWindow.left, rcWindow.top,
		rcWindow.Width(), rcWindow.Height(), SWP_FRAMECHANGED | SWP_NOZORDER);
}
Example #4
0
BOOL CSettingsSheet::SkinMe(LPCTSTR pszSkin, UINT nIcon, BOOL bLanguage)
{
	EnableBanner( FALSE );

	m_szPages.cx = m_szPages.cy = 0;

	for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ )
	{
		CSettingsPage* pPage = GetPage( nPage );
		CDialogTemplate pTemplate;

		if ( pPage->GetTemplateName() == NULL )  continue;

		if ( pTemplate.Load( pPage->GetTemplateName() ) )
		{
			CSize size;
			pTemplate.GetSizeInPixels( &size );
			m_szPages.cx = max( m_szPages.cx, size.cx );
			m_szPages.cy = max( m_szPages.cy, size.cy );
		}
	}

	CRect rcWindow(
		0,
		0,
		m_szPages.cx + m_nListWidth + m_nListMargin,
		m_szPages.cy + + m_nButtonHeight + 8 + 8 + 2 );
	CalcWindowRect( &rcWindow );
	SetWindowPos( &wndTop, 0, 0, rcWindow.Width(), rcWindow.Height(),
		SWP_NOMOVE|SWP_NOZORDER );

	CRect rcTree(
		0,
		2,
		m_nListWidth,
		2 + m_szPages.cy );
	m_wndTree.MoveWindow( &rcTree );

	CRect rcButton(
		8,
		2 + m_szPages.cy + 8,
		8 + m_nButtonWidth,
		2 + m_szPages.cy + 8 + m_nButtonHeight );
	m_wndOK.MoveWindow( &rcButton );
	rcButton.OffsetRect( rcButton.Width() + 8, 0 );
	m_wndCancel.MoveWindow( &rcButton );
	rcButton.OffsetRect( rcButton.Width() + 8, 0 );
	m_wndApply.MoveWindow( &rcButton );

	CenterWindow();

	SetActivePage( m_pPage ? m_pPage : m_pFirst );

	return CSkinDialog::SkinMe( pszSkin, nIcon, bLanguage );
}
Example #5
0
void CSizableReBar::OnNcCalcSize( BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp )
{
    CControlBar::OnNcCalcSize( bCalcValidRects, lpncsp );

    CRect rcWindow( lpncsp->rgrc[ 0 ] );
    CRect rcClient( rcWindow );
    CRect rcEdge;
    if ( GetSizingEdgeRect( rcWindow, rcEdge, GetSizingEdgeHitCode() ) )
    {
        if ( rcClient.SubtractRect( rcWindow, rcEdge ) )
        {
            lpncsp->rgrc[ 0 ] = rcClient;
        }
    }
}
Example #6
0
void CXTPEditListBox::RecalcLayout()
{
	if (HasToolbar() && ::IsWindow(m_editGroup.m_hWnd))
	{
		ASSERT_VALID(m_pParentWnd); // must be valid.

		CXTPWindowRect rcWindow(this);
		m_pParentWnd->ScreenToClient(&rcWindow);

		// move the group edit control.
		rcWindow.top -= BTN_OFFSET;
		rcWindow.bottom = rcWindow.top + BTN_OFFSET;

		::SetWindowPos(m_editGroup.m_hWnd, NULL, rcWindow.left, rcWindow.top,
			rcWindow.Width(), rcWindow.Height(), SWP_FRAMECHANGED);
	}
}
Example #7
0
BOOL CXTPHeaderCtrl::RecalcLayout()
{
	if (!::IsWindow(m_hWnd))
		return FALSE;

	HD_LAYOUT hdl;

	CXTPClientRect rcClient(this);
	hdl.prc = &rcClient;

	WINDOWPOS wp;
	ZeroMemory(&wp, sizeof(WINDOWPOS));
	hdl.pwpos = &wp;

	if (!Header_Layout(m_hWnd, &hdl))
		return FALSE;

	// Set the size, position, and visibility of the header window.
	::SetWindowPos(m_hWnd, wp.hwndInsertAfter, wp.x, wp.y,
		wp.cx, wp.cy, wp.flags | SWP_FRAMECHANGED);

	CWnd* pWndParent = GetParent();
	if (!::IsWindow(pWndParent->GetSafeHwnd()))
		return FALSE;

	// Force list control to recalculate it's layout.
	CXTPWindowRect rcWindow(pWndParent);

	const int cx = rcWindow.Width();
	const int cy = rcWindow.Height();

	pWndParent->SetWindowPos(NULL, 0, 0, cx, cy+1,
		SWP_NOMOVE | SWP_FRAMECHANGED);

	pWndParent->SetWindowPos(NULL, 0, 0, cx, cy,
		SWP_NOMOVE | SWP_FRAMECHANGED);

	return TRUE;
}
void CXTPColorDialog::CalculateRects()
{
	CRect rcBtnOK;
	CRect rcBtnCancel;
	CRect rcTabCtrl;
	CRect rcItem;

	// get the tab control size.
	CTabCtrl* pTabCtrl = GetTabControl();
	pTabCtrl->GetWindowRect(&rcTabCtrl);
	ScreenToClient(&rcTabCtrl);

	// get the size of the first tab item.
	pTabCtrl->GetItemRect(0, &rcItem);

	// get the OK button size.
	CButton* pBtnOK = (CButton*)GetDlgItem(IDOK);
	pBtnOK->GetWindowRect(&rcBtnOK);
	ScreenToClient(&rcBtnOK);

	// get the Cancel button size.
	CButton* pBtnCancel = (CButton*)GetDlgItem(IDCANCEL);
	pBtnCancel->GetWindowRect(&rcBtnCancel);
	ScreenToClient(&rcBtnCancel);
	rcBtnCancel.OffsetRect(-15, 0);

	// resize the tab control
	rcTabCtrl.right = rcBtnCancel.left - 5;
	rcTabCtrl.bottom = rcBtnCancel.top - 15;
	pTabCtrl->MoveWindow(&rcTabCtrl);

	// reposition the OK button.
	rcBtnOK = rcBtnCancel;
	rcBtnOK.top = rcTabCtrl.top + rcItem.Height() + 1;
	rcBtnOK.bottom = rcBtnOK.top + rcBtnCancel.Height();
	pBtnOK->MoveWindow(&rcBtnOK);

	// reposition the Cancel button.
	rcBtnCancel = rcBtnOK;
	rcBtnCancel.top = rcBtnOK.bottom + 5;
	rcBtnCancel.bottom = rcBtnCancel.top + rcBtnOK.Height();
	pBtnCancel->MoveWindow(&rcBtnCancel);

	// reposition the hex display
	if (::IsWindow(m_wndHexEdit.m_hWnd))
	{
		CRect rcWnd;
		rcWnd = rcBtnCancel;
		rcWnd.top = rcBtnCancel.bottom + 5;
		rcWnd.bottom = rcWnd.top + 18;
		m_wndHexEdit.MoveWindow(&rcWnd);
	}

	// reposition the eye dropper.
	if (::IsWindow(m_wndEyeDropper.m_hWnd))
	{
		CRect rcWnd;
		m_wndEyeDropper.GetWindowRect(&rcWnd);

		CSize size = rcWnd.Size();
		rcWnd.right = rcBtnOK.right;
		rcWnd.left = rcBtnOK.right - size.cx;
		rcWnd.bottom = rcTabCtrl.bottom;
		rcWnd.top = rcTabCtrl.bottom - size.cy;

		m_wndEyeDropper.MoveWindow(&rcWnd);
	}

	// resize the property sheet.
	CXTPWindowRect rcWindow(this);
	ClientToScreen(&rcTabCtrl);
	rcWindow.bottom = rcTabCtrl.bottom + 10;
	rcWindow.right -= 15;
	MoveWindow(&rcWindow);
}
void CXTPDockingPaneSidePanel::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
	if (nHitTest >= HTSIZEFIRST && nHitTest <= HTSIZELAST)
	{
		_RestoreFocus();
		Expand();
		SetCapture();
		m_pLayout->MoveToTail(this);

		CXTPWindowRect rcWindow(this);

		CRect rcClient(GetDockingPaneManager()->GetClientPane()->GetPaneWindowRect());
		rcClient.DeflateRect(GetDockingPaneManager()->GetSideDockingMargin());

		rcWindow.OffsetRect(-rcClient.TopLeft());


		MINMAXINFO mmi;
		GetMinMaxInfo(&mmi);

		BOOL bResizeTop = nHitTest == HTTOP || nHitTest == HTTOPLEFT || nHitTest == HTTOPRIGHT;
		BOOL bResizeBottom = nHitTest == HTBOTTOM || nHitTest == HTBOTTOMLEFT || nHitTest == HTBOTTOMRIGHT;
		BOOL bResizeRight = nHitTest == HTRIGHT || nHitTest == HTTOPRIGHT || nHitTest == HTBOTTOMRIGHT;
		BOOL bResizeLeft = nHitTest == HTLEFT || nHitTest == HTTOPLEFT || nHitTest == HTBOTTOMLEFT;

		while (::GetCapture() == m_hWnd)
		{
			MSG msg;

			if (!GetMessage(&msg, NULL, 0, 0))
				break;

			if (msg.message == WM_MOUSEMOVE)
			{
				CPoint pt = CPoint(msg.lParam);
				ClientToScreen(&pt);

				CPoint ptOffset = pt - point;
				point = pt;

				if (bResizeTop) rcWindow.top += ptOffset.y;
				if (bResizeBottom) rcWindow.bottom += ptOffset.y;
				if (bResizeRight) rcWindow.right += ptOffset.x;
				if (bResizeLeft) rcWindow.left += ptOffset.x;

				m_rcWindow = rcWindow;

				if (m_rcWindow.Height() > mmi.ptMaxTrackSize.y)
				{
					if (bResizeTop) m_rcWindow.top = m_rcWindow.bottom - mmi.ptMaxTrackSize.y; else m_rcWindow.bottom = m_rcWindow.top + mmi.ptMaxTrackSize.y;
				}
				if (m_rcWindow.Height() < mmi.ptMinTrackSize.y)
				{
					if (bResizeTop) m_rcWindow.top = m_rcWindow.bottom - mmi.ptMinTrackSize.y; else m_rcWindow.bottom = m_rcWindow.top + mmi.ptMinTrackSize.y;
				}

				if (m_rcWindow.Width() > mmi.ptMaxTrackSize.x)
				{
					if (bResizeLeft) m_rcWindow.left = m_rcWindow.right - mmi.ptMaxTrackSize.x; else m_rcWindow.right = m_rcWindow.left + mmi.ptMaxTrackSize.x;
				}
				if (m_rcWindow.Width() < mmi.ptMinTrackSize.x)
				{
					if (bResizeLeft) m_rcWindow.left = m_rcWindow.right - mmi.ptMinTrackSize.x; else m_rcWindow.right = m_rcWindow.left + mmi.ptMinTrackSize.x;
				}

				RecalcLayout(FALSE);
			}
			else if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) break;
			else if (msg.message == WM_LBUTTONUP) break;
			else ::DispatchMessage(&msg);
		}

		if (CWnd::GetCapture() == this) ReleaseCapture();
	}
}
void CRichToolTipCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
  LPNMTTCUSTOMDRAW lpttcd = (LPNMTTCUSTOMDRAW)pNMHDR;
  *pResult = CDRF_DODEFAULT;

  if (! ::IsWindow(m_edit.m_hWnd))
    return; // can't do it!

  switch (lpttcd->nmcd.dwDrawStage)
  {
  case CDDS_PREPAINT:
    *pResult = CDRF_NOTIFYPOSTPAINT;	// we want post-paint notifications
    break;

  case CDDS_POSTPAINT:
    {
      // paint the whole window with the system tool-tip background colour
      CRect rcWindow(lpttcd->nmcd.rc);
      SendMessage(TTM_ADJUSTRECT, TRUE, (LPARAM)&rcWindow); // need to get the tip's window rect
      CDC* pDC = CDC::FromHandle(lpttcd->nmcd.hdc);

      // if we're using themes, paint the background with the theme's tooltip background
      BOOL bPainted = FALSE;
      if (s_xpStyle.IsAppXPStyled())
      {
	HTHEME hTheme = s_xpStyle.OpenThemeData(NULL, L"TOOLTIP");
	if (hTheme != NULL)
	{
	  if (s_xpStyle.IsThemeBackgroundPartiallyTransparent(hTheme, TTP_STANDARD, TTSS_NORMAL))
	    s_xpStyle.DrawThemeParentBackground(m_hWnd, lpttcd->nmcd.hdc, &rcWindow);
	  bPainted = (s_xpStyle.DrawThemeBackground(hTheme, lpttcd->nmcd.hdc, TTP_STANDARD, TTSS_NORMAL, &rcWindow) == S_OK);
	}
      }
      if (! bPainted) // not painted using theme, so paint with tool-tip colour
	pDC->FillSolidRect(&rcWindow, GetTipBkColor());

      // FormatRange needs its rect in twips
      // a twip is 1/20 of a printer's point (1,440 twips equal one inch)
      int nLogPixelsX = ::GetDeviceCaps(lpttcd->nmcd.hdc, LOGPIXELSX);
      int nLogPixelsY = ::GetDeviceCaps(lpttcd->nmcd.hdc, LOGPIXELSY);

      // get the drawing rect, and convert to twips
      CRect rc(lpttcd->nmcd.rc);
      rc.DeflateRect(1, 1, 1, 1); // give it a small margin
      rc.left = MulDiv(rc.left, 1440, nLogPixelsX);
      rc.right = MulDiv(rc.right, 1440, nLogPixelsX);
      rc.top = MulDiv(rc.top, 1440, nLogPixelsY);
      rc.bottom = MulDiv(rc.bottom, 1440, nLogPixelsY);

      // use the rich edit control to draw to our device context
      FORMATRANGE fr;
      fr.hdc = lpttcd->nmcd.hdc;
      fr.hdcTarget = lpttcd->nmcd.hdc;
      fr.chrg.cpMin = 0;
      fr.chrg.cpMax = -1;
      fr.rc = rc; // in twips
      fr.rcPage = fr.rc;
      m_edit.FormatRange(&fr, TRUE);
      m_edit.DisplayBand(&rc);
      m_edit.FormatRange(NULL, FALSE);	// get the control to free its cached info

      *pResult = CDRF_SKIPDEFAULT;  // we don't want the default drawing
    }
    break;
  }
}
Example #11
0
// Updates the window position.  A DC is needed to calculate the size of the text
void CPopupNoteDlg::UpdateWindowPos(CDC *pDC)
{
	if (!pDC)
	{
		ASSERT(FALSE);
		return;
	}

	// Select the new font
	CFont *pOldFont=pDC->SelectObject(&m_font);

	// Calculate how big the window needs to be based on its width
	CRect rcTextRect(0,0, m_nDialogWidth, 0);
	pDC->DrawText(m_sNoteText, &rcTextRect, DT_CALCRECT | DT_LEFT | DT_WORDBREAK);

	// Make the window slightly larger than just the text
	int nBorderSize=m_nBorderSize;
	
	// Move the window up to the left a little bit
	CRect rcWindow(m_initialCursorPos.x, m_initialCursorPos.y, m_initialCursorPos.x+rcTextRect.Width()+(nBorderSize*2), m_initialCursorPos.y+rcTextRect.Height()+(nBorderSize*2));
	if (rcWindow.left > 25)
	{
		rcWindow.OffsetRect(-20, 0);
	}
	if (rcWindow.top > 25)
	{
		rcWindow.OffsetRect(0,-20);
	}

	// Make sure that the window isn't going off of the bottom of the main window
	CRect rcMainWindow;
	AfxGetMainWnd()->GetWindowRect(rcMainWindow);

	// Check to see if it extends past the bottom
	if (rcWindow.bottom > rcMainWindow.bottom)
	{
		// Move the window up
		rcWindow.OffsetRect(0, rcMainWindow.bottom-rcWindow.bottom-5);

		// Make sure we didn't go off of the top of the screen
		if (rcWindow.bottom < 0)
		{
			rcWindow.OffsetRect(0, (-1)*rcWindow.bottom);
		}
	}

	// Check to see if it extends past the right side of the screen
	if (rcWindow.right > rcMainWindow.right)
	{
		// Move the window to the left
		rcWindow.OffsetRect(rcMainWindow.right-rcWindow.right-5, 0);

		// Make sure we didn't go off of the left of the screen
		if (rcWindow.left < 0)
		{
			rcWindow.OffsetRect((-1)*rcWindow.left, 0);
		}
	}

	MoveWindow(rcWindow);

	// Select the old font
	pDC->SelectObject(pOldFont);
}
Example #12
0
//初始化消息
BOOL CHintMsgBox::OnInitDialog()
{
	__super::OnInitDialog();

	//设置标题
	SetWindowText(m_strCaption);

	//关闭按钮
	if((m_uType&MB_DEFBUTTON2)!=0)m_cbButtonState[BST_CLOSE]&=(~BUT_EXIST);
	else m_cbButtonState[BST_CLOSE]|=BUT_EXIST;

	//按钮区域
	CreateBoxButton();
	INT nButtonAreaHeight=SMB_BUTTON_HEIGHT+SMB_BUTTON_TOP+SMB_BUTTON_BUTTOM;
	INT nButtonAreaWidth=m_nBtCount*SMB_BUTTON_WIDTH+(m_nBtCount+1)*SMB_BUTTON_SPACE+SMB_BUTTON_LEFT+SMB_BUTTON_RIGHT;

	//字符空间
	CClientDC ClientDC(this);
	CRect rcString(0,0,SMB_STRING_WIDTH,SMB_STRING_HEIGHT);
	ClientDC.SelectObject(CSkinResourceManager::GetDefaultFont());
	ClientDC.DrawText(m_strString,rcString,DT_CALCRECT|DT_EXPANDTABS|DT_NOCLIP|DT_WORD_ELLIPSIS);

	//字符区域
	INT nStringAreaHeight=rcString.Height()+SMB_STRING_TOP;
	INT nStringAreaWidth=rcString.Width()+SMB_ICON_LEFT+SMB_ICON_WIDTH+SMB_STRING_LEFT+SMB_STRING_RIGHT;

	//窗口区域
	INT nWindowAreaHeight=nStringAreaHeight+nButtonAreaHeight;
	INT nWindowAreaWidth=__max(SMB_WINDOW_WIDTH,__max(nStringAreaWidth,nButtonAreaWidth));

	//输出位置
	if (nWindowAreaWidth>nStringAreaWidth)
	{
		m_rcString.top=m_SkinAttribute.m_nCaptionHeigth+SMB_STRING_TOP;
		m_rcString.left=GetXBorder()+SMB_ICON_LEFT+SMB_ICON_WIDTH+SMB_STRING_LEFT+(nWindowAreaWidth-nStringAreaWidth)/2;
		m_rcString.right=m_rcString.left+rcString.Width();
		m_rcString.bottom=m_rcString.top+rcString.Height();
	}
	else
	{
		m_rcString.top=m_SkinAttribute.m_nCaptionHeigth+SMB_STRING_TOP;
		m_rcString.left=GetXBorder()+SMB_ICON_LEFT+SMB_ICON_WIDTH+SMB_STRING_LEFT;
		m_rcString.right=m_rcString.left+rcString.Width();
		m_rcString.bottom=m_rcString.top+rcString.Height();
	}

	//调整窗口
	CRect rcWindow(0,0,0,0);
	rcWindow.right=nWindowAreaWidth+GetXBorder()*2;
	rcWindow.bottom=nWindowAreaHeight+m_SkinAttribute.m_nCaptionHeigth+GetYBorder();
	SetWindowPos(NULL,0,0,rcWindow.Width(),rcWindow.Height(),SWP_NOMOVE|SWP_NOZORDER);

	//调整按钮
	INT nYButton=m_SkinAttribute.m_nCaptionHeigth+nWindowAreaHeight-SMB_BUTTON_BUTTOM-SMB_BUTTON_HEIGHT;
	INT nXButton=GetXBorder()+(nWindowAreaWidth-m_nBtCount*SMB_BUTTON_WIDTH-(m_nBtCount+1)*SMB_BUTTON_SPACE)/2+SMB_BUTTON_SPACE;
	for (UINT i=0;i<m_nBtCount;i++)
	{
		m_btButton[i].SetWindowPos(NULL,nXButton,nYButton,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW);
		nXButton+=SMB_BUTTON_SPACE+SMB_BUTTON_WIDTH;
	}

	//默认按钮
	UINT uDefaultIndex=(m_uType&MB_DEFMASK)>>8;
	if (uDefaultIndex>=m_nBtCount) uDefaultIndex=0;
	m_btButton[uDefaultIndex].SetFocus();
	m_btButton[uDefaultIndex].SetButtonStyle(m_btButton[uDefaultIndex].GetButtonStyle()|BS_DEFPUSHBUTTON);

	//居中窗口
	CenterWindow(GetParent());

	//设置时间
	if (m_nElapse!=0) SetTimer(IDI_MESSAGE,1000,NULL);

	return FALSE;
}