Example #1
0
void CMedicineSearchDlg::OnCbnDropdownComboVendor()
{
	// TODO: 在此添加控件通知处理程序代码
	CVendorDB vendorDB;
	vector<Vendor*> vctVendor;
	DWORD dwTotalPage, dwTotalNum;
	CString csMsg;
	CSize   sz;
	int     dx = 0;
	TEXTMETRIC   tm;
	CDC*    pDC = m_comboVendor.GetDC();
	CFont*  pFont = m_comboVendor.GetFont();
	CFont* pOldFont = pDC->SelectObject(pFont);
	pDC->GetTextMetrics(&tm);

	for (int i = m_comboVendor.GetCount() - 1; i >= 0; i--)
	{
		m_comboVendor.DeleteString(i);
	}

	ERRCODE errRet = vendorDB.GetVendors(0, 50, dwTotalPage, dwTotalNum, vctVendor, m_csMatchStr.GetBuffer());
	if (errRet != err_OK)
	{
		return;
	}

	for (int i = 0; i < (int)vctVendor.size(); i++)
	{
		csMsg.Format(_T("%s-%s"), vctVendor[i]->csID.GetBuffer(), vctVendor[i]->csName.GetBuffer());
		m_comboVendor.AddString(csMsg);

		sz = pDC->GetTextExtent(csMsg);
		sz.cx += tm.tmAveCharWidth;
		if (sz.cx > dx)
			dx = sz.cx;

		delete vctVendor[i];
		vctVendor[i] = NULL;
	}
	vctVendor.clear();

	pDC->SelectObject(pOldFont);
	m_comboVendor.ReleaseDC(pDC);
	dx += ::GetSystemMetrics(SM_CXVSCROLL) + 2*::GetSystemMetrics(SM_CXEDGE);
	m_comboVendor.SetDroppedWidth(dx);

	m_csMatchStr = _T("");
}
Example #2
0
void CUnitDlgListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
  {
  ASSERT(lpMeasureItemStruct->CtlType == ODT_LISTBOX);
  LPCTSTR lpszText = (LPCTSTR) lpMeasureItemStruct->itemData;
  ASSERT(lpszText != NULL);
  CSize   sz;
  CDC*    pDC = GetDC();

  sz = pDC->GetTextExtent(lpszText);

  ReleaseDC(pDC);

  lpMeasureItemStruct->itemHeight = 2*sz.cy;

  //CListBox::MeasureItem(lpMeasureItemStruct);
  };
/******************************************************************************
  Function Name    :  OnInitDialog

  Input(s)         :
  Output           :
  Functionality    :  Initialze the contents of List box
  Member of        :  CFlexRayDatabaseDissociateDlg
  Friend of        :      -

  Author(s)        :  Ashwin R Uchil
  Date Created     :  05.04.2013
  Modifications    :
******************************************************************************/
BOOL CFlexRayDatabaseDissociateDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    //do initialization below
    m_omDissociateDbLst.ResetContent();
    CStringArray aomstrTempDBFiles;
    //(*(CMsgSignal**)(m_sDbParams.m_ppvImportedDBs))->vGetDataBaseNames(&aomstrTempDBFiles);
    //int nDB = (sizeof(m_sFibexParams.m_acConfigFileName)/sizeof(string));
    //for(int nCnt =0; nCnt < nDB; nCnt++)
    //{
    //  CString         omstrData;
    //  omstrData = (m_sFibexParams.m_acConfigFileName[nCnt]).c_str();
    //  if(omstrData != "")
    //  {
    //      aomstrTempDBFiles.Add(omstrData);
    //  }
    //}
    CString omstrData;
    omstrData = (m_sFibexParams.m_acConfigFileName[0]).c_str();
    if(omstrData != "")
    {
        aomstrTempDBFiles.Add(omstrData);
    }

    int nFileCount = aomstrTempDBFiles.GetSize();
    CSize   sz;
    CString omStrText;
    CDC*  pDC = m_omDissociateDbLst.GetDC();
    int nDx = 0;
    for(int nCount = 0; nCount < nFileCount; nCount++)
    {
        omStrText = aomstrTempDBFiles.GetAt(nCount);
        m_omDissociateDbLst.AddString(omStrText);
        sz = pDC->GetTextExtent(omStrText);

        if (sz.cx > nDx)
        {
            nDx = sz.cx;
        }
    }

    m_omDissociateDbLst.ReleaseDC(pDC);
    // Set the horizontal extent so every character of all strings
    // can be scrolled to.
    m_omDissociateDbLst.SetHorizontalExtent(nDx);
    return TRUE;
}
void CLineNumberStatic::OnPaint()
{
	CPaintDC dcPaint( this );

	CRect rect;
	GetClientRect( &rect );

	// We double buffer the drawing -
	// preparing the memory CDC
	CDC dc;
	dc.CreateCompatibleDC( &dcPaint );
	int saved = dc.SaveDC();

	// Create GDI and select objects
	CBitmap bmp;
	CPen pen;
	bmp.CreateCompatibleBitmap( &dcPaint, rect.Width(), rect.Height() );
	pen.CreatePen( PS_SOLID, 1, m_fgcol );
	dc.SelectObject( &bmp );
	dc.SelectObject( &pen );

	// Painting the background
	dc.FillSolidRect( &rect, m_bgcol );
	dc.MoveTo( rect.right - 1, 0 );
	dc.LineTo( rect.right - 1, rect.bottom );

	// Setting other attributes
	dc.SetTextColor( m_fgcol );
	dc.SetBkColor( m_bgcol );
	dc.SelectObject( GetParent()->GetFont() );

	// Output the line numbers
	if( m_bottomline )
	{
		int lineheight = dc.GetTextExtent( _T( "0" ) ).cy;
		for( int t = m_topline ; t < m_bottomline ; t++ )
		{
			CString output;
			output.Format( m_format, t );
			int topposition = m_topmargin + lineheight * ( t - m_topline );
			dc.TextOut( 2, topposition, output );
		}
	}

	dcPaint.BitBlt( 0, 0, rect. right, rect.bottom, &dc, 0, 0, SRCCOPY );
	dc.RestoreDC( saved );
}
Example #5
0
// Set the axes and origin values.
void MyGraph::SetupAxes(CDC& dc)
{
	VALIDATE;
	ASSERT_VALID(&dc);

	// Since pie has no axis lines, set to full size minus GAP_PIXELS on each
	// side.  These are needed for legend to plot itself.
	if (MyGraph::PieChart == m_eGraphType) {
		m_nXAxisWidth = m_rcGraph.Width() - (GAP_PIXELS * 2);
		m_nYAxisHeight = m_rcGraph.Height() - m_rcTitle.bottom;
		m_ptOrigin.x = GAP_PIXELS;
		m_ptOrigin.y = m_rcGraph.Height() - GAP_PIXELS;
	}
	else {
		// Bar and Line graphs.

		// Need to find out how wide the biggest Y-axis tick label is

		// Get and store height of axis label font.
		m_nAxisLabelHeight = max(m_rcGraph.Height() / Y_AXIS_LABEL_DIVISOR, MIN_FONT_SIZE);
		// Get and store height of tick label font.
		m_nAxisTickLabelHeight = max(int(m_nAxisLabelHeight*0.8), MIN_FONT_SIZE);

		CFont fontTickLabels;
		VERIFY(fontTickLabels.CreatePointFont(m_nAxisTickLabelHeight, _T("Arial"), &dc));
		// Select font and store the old.
		CFont* pFontOld = dc.SelectObject(&fontTickLabels);
		ASSERT_VALID(pFontOld);

		// Obtain tick label dimensions.
		CString sTickLabel;
		sTickLabel.Format(_T("%d"), GetMaxDataValue());
		CSize sizTickLabel(dc.GetTextExtent(sTickLabel));

		// Set old font object again and delete temporary font object.
		VERIFY(dc.SelectObject(pFontOld));
		fontTickLabels.DeleteObject();

		// Determine axis specifications.
		m_ptOrigin.x = m_rcGraph.left + m_nAxisLabelHeight/10 + 2*GAP_PIXELS
			+ sizTickLabel.cx + GAP_PIXELS + TICK_PIXELS;
		m_ptOrigin.y = m_rcGraph.bottom - m_nAxisLabelHeight/10 - 2*GAP_PIXELS -
			sizTickLabel.cy - GAP_PIXELS - TICK_PIXELS;
		m_nYAxisHeight = m_ptOrigin.y - m_rcTitle.bottom - (2 * GAP_PIXELS);
		m_nXAxisWidth = (m_rcGraph.Width() - GAP_PIXELS) - m_ptOrigin.x;
	}
}
Example #6
0
void CDockingBar::CalcWidth(std::vector<CTab>& tabs, CDC& dc, CRect wnd_rect)
{
	int GAP= wnd_rect.Height() / 2;
	int ICON= 20; // icon width plus space
	CPoint start= wnd_rect.TopLeft();
	start.x += GAP;

	for (int i= 0; i < tabs.size(); ++i)
	{
		CTab& tab= tabs[i];
		CSize text_size= dc.GetTextExtent(tab.name_);
		int width= ICON + text_size.cx;
		tab.location_rect_.SetRect(start.x, start.y, start.x + width, wnd_rect.bottom);

		start.x += width + GAP;
	}
}
Example #7
0
void CHeadingStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CFont *pOldFont = pDC->SelectObject(&m_Font);

	pDC->FillSolidRect(&lpDrawItemStruct->rcItem, RGB(0xa8,0xc7,0xef));

	pDC->SetTextColor(RGB(79, 129, 189));

	CSize s = pDC->GetTextExtent(L"The  Guide");
	CRect r(lpDrawItemStruct->rcItem);
	int remainX = r.Width()-s.cy;
	int remainY = r.Height()-s.cx;
	pDC->TextOut(remainX/2, r.bottom-remainY/2, L"The Guide");

	pDC->SelectObject(pOldFont);
}
void fsODMenu::OnMeasureItem(LPMEASUREITEMSTRUCT pmis)
{
	SIZE sz = {0, 0};
	fsODMenuItemData *pData = (fsODMenuItemData*) pmis->itemData;

	
	if (pData->strMenuText.GetLength () == 0)
	{
		pmis->itemWidth  = 0;
		pmis->itemHeight = 5;
		return;
	}

	CDC* dc = AfxGetApp ()->m_pMainWnd->GetDC ();
	CFont *oldfont = dc->SelectObject (pData->bBold ? &m_fontBold : &m_font);

	sz = dc->GetTextExtent (pData->strMenuText);

	pmis->itemWidth  = sz.cx;
	pmis->itemHeight = sz.cy;

	if (pData->bMenuBar == FALSE)
	{
		pmis->itemWidth += m_cxIcon + 6 + 10;  

		UINT mincy = m_cyIcon + 6;
		if (pmis->itemHeight < mincy)
			pmis->itemHeight = mincy;

		if (strchr (pData->strMenuText, '\t') != NULL)
			pmis->itemWidth += 15;
	}
	else
	{
		pmis->itemWidth -= 3;
		UINT temp = GetSystemMetrics (SM_CYMENU);
		pmis->itemHeight = temp > m_cyIcon + 8 ? temp : m_cyIcon + 7;
    
		if(pmis->itemHeight < (UINT)sz.cy)
			pmis->itemHeight = sz.cy;
	}

	dc->SelectObject (oldfont);
	AfxGetApp ()->m_pMainWnd->ReleaseDC (dc);
}
Example #9
0
void CStaticHyperLink::PositionWindow()
{
	if (!::IsWindow(GetSafeHwnd()) || !m_bAdjustToFit) 
		return;

	CRect WndRect, ClientRect;
	GetWindowRect(WndRect);
	GetClientRect(ClientRect);

	ClientToScreen(ClientRect);

	CWnd* pParent = GetParent();
	if (pParent)
	{
		pParent->ScreenToClient(WndRect);
		pParent->ScreenToClient(ClientRect);
	}

	CString strWndText;
	GetWindowText(strWndText.GetBuffer(MAX_PATH), MAX_PATH);
	strWndText.ReleaseBuffer();
	strWndText.Trim();

	CDC* pDC = GetDC();
	CSize Extent = pDC->GetTextExtent(strWndText, strWndText.GetLength());
	ReleaseDC(pDC);

	Extent.cx += WndRect.Width() - ClientRect.Width();
	Extent.cy += WndRect.Height() - ClientRect.Height(); 

	DWORD dwStyle = GetStyle();
	if (dwStyle & SS_CENTERIMAGE)
		WndRect.DeflateRect(0, (WndRect.Height() - Extent.cy)/2);
	else
		WndRect.bottom = WndRect.top + Extent.cy;

	if (dwStyle & SS_CENTER)   
		WndRect.DeflateRect((WndRect.Width() - Extent.cx)/2, 0);
	else if (dwStyle & SS_RIGHT) 
		WndRect.left  = WndRect.right - Extent.cx;
	else
		WndRect.right = WndRect.left + Extent.cx;

	SetWindowPos(NULL, WndRect.left, WndRect.top, WndRect.Width(), WndRect.Height(), SWP_NOZORDER);
}
Example #10
0
void CGameDlg::DrawGameTime(void)
{

	CDC* pDC = GetDC();
	CFont font;
	font.CreatePointFont(150, _T("Courier New"));
	CFont* oldFont = pDC->SelectObject(&font);

	pDC->SetBkColor(RGB(255,255,255));
	pDC->SetTextColor(RGB(255,0,0));

	CString strTime;
	strTime.Format(_T("Time Left: %3d"),m_GameProgress.GetPos());
	CSize size = pDC->GetTextExtent(strTime, strTime.GetLength());
	pDC->TextOutW(500,485, strTime);


}
Example #11
0
void CCoolBarItem::SetText(LPCTSTR lpszText)
{
	if ( this == NULL ) return;
	if ( m_sText == lpszText ) return;

	m_sText		= lpszText;
	m_bDirty	= TRUE;

	CDC dc;
	dc.Attach( ::GetDC( 0 ) );

	CFont* pOld = (CFont*)dc.SelectObject( m_pBar->m_bBold ? &CoolInterface.m_fntBold : &CoolInterface.m_fntNormal );
	m_nWidth = BUTTON_WIDTH + dc.GetTextExtent( m_sText ).cx;
	if ( m_nImage >= 0 ) m_nWidth += IMAGE_WIDTH + TEXT_GAP;
	dc.SelectObject( pOld );

	::ReleaseDC( 0, dc.Detach() );
}
Example #12
0
void CFaceViewConsole::AddString(LPCTSTR str)
{
	m_plist->AddString(str);
	int nline=m_plist->GetCount();
	m_plist->SetCurSel(nline-1);
	if (strlen(str) > m_maxstring) {
		m_maxstring=strlen(str);
		CDC *pDC = GetDC();
		CSize size;
		CFont* pOldFont = pDC->SelectObject(&m_font);
	    size = pDC->GetTextExtent(str, (int) _tcslen(str));
	    size.cx += 3;
		pDC->SelectObject(pOldFont);
		ReleaseDC(pDC);
		m_plist->SetHorizontalExtent(size.cx);
	}
	m_plist->UpdateWindow();
}
Example #13
0
void CRulerBar::DrawNumbers(CDC& dc, int nInc, int nTPU)
{
    int nPageWidth = PrintWidth();
    int nPageEdge = nPageWidth + m_rectMargin.right;
    TCHAR buf[10];

    int nTwips, nPixel, nLen;

    for (nTwips = nInc; nTwips < nPageEdge; nTwips += nInc)
    {
        if (nTwips == nPageWidth)
            continue;
        nPixel = XTwipsToRuler(nTwips);
        _stprintf_s(buf, 10, _T("%d"), nTwips/nTPU);
        nLen = lstrlen(buf);
        CSize sz = dc.GetTextExtent(buf, nLen);
        dc.ExtTextOut(nPixel - sz.cx/2, HEIGHT/2 - sz.cy/2, 0, NULL, buf, nLen, NULL);
    }
}
Example #14
0
void DlgRecent::SetHScroll()
{
	CDC* dc = GetDC();
	SIZE s;
	int index;
	CString str;
	long temp;
	for(index= 0; index< m_List.GetCount(); index++)
	{
		m_List.GetText(index,str);
		s = dc->GetTextExtent(str,str.GetLength()+1);  
		temp = (long)SendDlgItemMessage(IDC_LBRECENT, LB_GETHORIZONTALEXTENT, 0, 0);
		if (s.cx > temp)  
		{
			SendDlgItemMessage(IDC_LBRECENT, LB_SETHORIZONTALEXTENT, (WPARAM)s.cx, 0);
		}
	}
	ReleaseDC(dc);
}
Example #15
0
CSize CMainDlg::LoadMyBitmap(CImageList *imgList, UINT nID)//使bmp图片透明
{
	CDC * pDC = GetDC();
	CDC m_MemDC;
	m_MemDC.CreateCompatibleDC(pDC);
	CSize m_Size = pDC->GetTextExtent("刷新");
	ReleaseDC(pDC);
	CRect rect(0,0,60,32);
	CBitmap *pBitmap, *pOldBitmap;
	pBitmap = new CBitmap;
	pBitmap->LoadBitmap(nID);
	pOldBitmap = m_MemDC.SelectObject(pBitmap);
	TransParentDC(rect,&m_MemDC);
	m_MemDC.SelectObject(pOldBitmap);
	imgList->Add(pBitmap,GetSysColor(COLOR_MENU));
	pBitmap->DeleteObject();
	delete pBitmap;
	return m_Size;
}
Example #16
0
// Add a column to the control
//
// lpszColumnHeading - pointer to the column heading text
//
// return: TRUE if successful
BOOL CColumnCtrl::AddColumn ( LPCTSTR lpszColumnHeading, uint32 dwSortMethod, int nPercentWidth )
{
	// Number of columns must be positive
	ASSERT ( nColumns >= 0 );

	// Must be a know sort method
	if ( dwSortMethod <= SORT_MIN || dwSortMethod >= SORT_MAX )
	{
		ASSERT(FALSE);
		return FALSE;
	}	

	// Width of the column
	int nWidth;

	// If nPercentWidth < 0 then find a suitable width in pixels
	if ( nPercentWidth < 0 )
	{
		CDC dc;

		dc.CreateCompatibleDC(NULL);

		CSize csWidth=dc.GetTextExtent(lpszColumnHeading, strlen(lpszColumnHeading));
		nWidth=csWidth.cx + 15; // Adding some padding to both sides
	}
	else
	{
		CRect rClient;
		GetClientRect(rClient);

		nWidth=(nPercentWidth*rClient.Width())/100;	// The width is a percent of the total client area
	}

	if ( InsertColumn ( nColumns, lpszColumnHeading, LVCFMT_LEFT, nWidth ) == -1 )
	{
		// InsertColumn failed
		return FALSE;
	}

	dwSortArray.Add(dwSortMethod);
	nColumns++;
	return TRUE;
}
Example #17
0
int GraphicsMisc::GetTextWidth(const CString& sText, CWnd& wndRef, CFont* pRefFont)
{
	CDC* pDC = wndRef.GetDC();
	ASSERT(pDC);

	if (!pDC)
		return -1;
	
	if (pRefFont == NULL)
		pRefFont = wndRef.GetFont();

	CFont* pOldFont = pDC->SelectObject(pRefFont);
	int nLength = pDC->GetTextExtent(sText).cx;

	pDC->SelectObject(pOldFont);
	wndRef.ReleaseDC(pDC);

	return nLength;
}
Example #18
0
void CHyperLink::PositionWindow()
{
    if (!::IsWindow(GetSafeHwnd()) || !m_bAdjustToFit) 
        return;

    // Get the current window position
    CRect rect;
    GetWindowRect(rect);

    CWnd* pParent = GetParent();
    if (pParent)
        pParent->ScreenToClient(rect);

    // Get the size of the window text
    CString strWndText;
    GetWindowText(strWndText);

    CDC* pDC = GetDC();
    CFont* pOldFont = pDC->SelectObject(&m_Font);
    CSize Extent = pDC->GetTextExtent(strWndText);
    pDC->SelectObject(pOldFont);
    ReleaseDC(pDC);

    // Get the text justification via the window style
    DWORD dwStyle = GetStyle();

    // Recalc the window size and position based on the text justification
    if (dwStyle & SS_CENTERIMAGE)
        rect.DeflateRect(0, (rect.Height() - Extent.cy)/2);
    else
        rect.bottom = rect.top + Extent.cy;

    if (dwStyle & SS_CENTER)   
        rect.DeflateRect((rect.Width() - Extent.cx)/2, 0);
    else if (dwStyle & SS_RIGHT) 
        rect.left  = rect.right - Extent.cx;
    else // SS_LEFT = 0, so we can't test for it explicitly 
        rect.right = rect.left + Extent.cx;

    // Move the window
    SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
}
Example #19
0
CSize CGumpStatic::GetTextExtend() const
{
	CGumpEditorDoc* pDoc = GfxGetGumpDocument();
	ASSERT(pDoc);

	CWnd* pWnd = AfxGetMainWnd(); //pDoc->FindView(RUNTIME_CLASS(CGumpEditorView));

	CDC* pDC = pWnd->GetDC();

	CFont* pFont = pDoc->GetFont(m_fontId);
	CFont* pOld = pDC->SelectObject(pFont);

	pDC->SelectObject(pFont);

	CSize size = pDC->GetTextExtent(GetTitle());

	pDC->SelectObject(pOld);

	return size;
}
Example #20
0
void CPlayerInfoBar::Relayout()
{
	CRect r;
	GetParent()->GetClientRect(&r);

	int w = m_nFirstColWidth, h = 17, y = 2;

	for(size_t i = 0; i < m_label.GetCount(); i++) {
		CDC* pDC = m_label[i]->GetDC();
		CString str;
		m_label[i]->GetWindowText(str);
		w = max(w, pDC->GetTextExtent(str).cx);
		m_label[i]->ReleaseDC(pDC);
	}

	for(size_t i = 0; i < m_label.GetCount(); i++, y += h) {
		m_label[i]->MoveWindow(1, y, w - 10, h);
		m_info[i]->MoveWindow(w + 10, y, r.Width()-(w+10)-1, h);
	}
}
Example #21
0
//-----------------------------------------------------------------------------
// Purpose: Sets the text to display in the window. The window size is recalculated
//			to ensure that the text fits.
// Input  : pszTitle - Text to display in the window.
//-----------------------------------------------------------------------------
void CTitleWnd::SetTitle(LPCTSTR pszTitle)
{
	ASSERT(pszTitle != NULL);
	if (pszTitle != NULL)
	{
		strcpy(m_szTitle, pszTitle);
		if (::IsWindow(m_hWnd))
		{
			CDC *pDC = GetDC();
			if (pDC != NULL)
			{
				pDC->SelectObject(&m_FontActive);
				CSize TextSize = pDC->GetTextExtent(m_szTitle, strlen(m_szTitle));
				SetWindowPos(NULL, 0, 0, TextSize.cx, TextSize.cy, SWP_NOMOVE | SWP_NOZORDER);
				Invalidate();
				UpdateWindow();
			}
		}
	}
}
Example #22
0
void JMenuEx::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
	// TODO:  添加您的代码以确定指定项的大小
	PJMENUITEM pJMenuItem = (PJMENUITEM)lpMeasureItemStruct->itemData;
	CDC* pDC = AfxGetMainWnd()->GetDC();
	CSize size = pDC->GetTextExtent(pJMenuItem->strText);
	if(pJMenuItem->uID == 0)
	{
		lpMeasureItemStruct->itemHeight = SEPLIT_STATUS_MENUE;
		lpMeasureItemStruct->itemWidth = size.cx;
	}
	else
	{
		lpMeasureItemStruct->itemWidth = size.cx + LEFT_BORDER_MENUE;
		lpMeasureItemStruct->itemHeight = size.cy;
	}

	//OutputDebugString(pJMenuItem->strText);
	AfxGetMainWnd()->ReleaseDC(pDC);
}
Example #23
0
void CAnimationEngine::DrawTextItem( CDC& dc, CAnimationItem& item, int nDrawFlags, BOOL bShow )
{
	CRect rect;
	CPoint pt = item.m_pt;

	if ( bShow )
		dc.SetTextColor( item.m_rgbTextColorCurrent );
	else
		dc.SetTextColor( m_rgbBackground );

	CSize size = dc.GetTextExtent( item.m_csText );
	int nBottom = pt.y + size.cy * 2 + 1;
	if ( item.m_nEffects & item.AF_AlignCenter )
		rect.SetRect( pt.x-size.cx/2, pt.y, pt.x+size.cx/2+2, nBottom );
	else if ( item.m_nEffects & item.AF_AlignRight )
		rect.SetRect( pt.x-size.cx-1, pt.y, pt.x, nBottom );
	else
		rect.SetRect( pt.x, pt.y, pt.x+size.cx+1, nBottom );
	dc.DrawText( item.m_csText, &rect, nDrawFlags );
}
Example #24
0
/***************************************************
DoesTextFit
	The tooltips for this cell 
	show the subject line if it
	did not fit in the cell.  This
	helper function checks if a given
	mailItem has a subject line which
	would fit in the given column of
	the grid, taking into account the 
	size of the icons used by the item,
	and the font it would be drawn in.
Params:
	item	- the mail item to measure
	col		- the index of the column to measure for
Return
	a bool to indicate if text will fit or not
****************************************************/
bool CUGCTMail::DoesTextFit(mailItem item, int col)
{
	CDC dc;
	dc.CreateCompatibleDC(NULL);

	CFont * pOldFont = dc.SelectObject(&m_fontNormal);
	CSize szText = dc.GetTextExtent(item.subject);
	dc.SelectObject(pOldFont);

	int width = m_ctrl->GetColWidth(0) - 10;

	IMAGEINFO ii;
	m_leftImages.GetImageInfo(item.leftIcon, &ii);
	width -= (ii.rcImage.right - ii.rcImage.left + leftIconLeftMargin + leftIconRightMargin);

	m_rightImages.GetImageInfo(item.rightIcon, &ii);
	width -= (ii.rcImage.right - ii.rcImage.left);

	return width >= szText.cx;
}
Example #25
0
CListBox* CPlayerListCtrl::ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel)
{
    CRect rect;
    if (!PrepareInPlaceControl(nItem, nCol, rect)) {
        return nullptr;
    }

    DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL/*|WS_HSCROLL*/ | LBS_NOTIFY;
    CListBox* pListBox = DEBUG_NEW CInPlaceListBox(nItem, nCol, lstItems, nSel);
    pListBox->Create(dwStyle, rect, this, IDC_LIST1);

    CRect ir;
    GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);

    pListBox->SetItemHeight(-1, ir.Height());

    CDC* pDC = pListBox->GetDC();
    CFont* pWndFont = GetFont();
    pDC->SelectObject(pWndFont);
    int width = GetColumnWidth(nCol);
    POSITION pos = lstItems.GetHeadPosition();
    while (pos) {
        int w = pDC->GetTextExtent(lstItems.GetNext(pos)).cx + 16;
        if (width < w) {
            width = w;
        }
    }
    ReleaseDC(pDC);

    CRect r;
    pListBox->GetWindowRect(r);
    ScreenToClient(r);
    r.top = ir.bottom;
    r.bottom = r.top + pListBox->GetItemHeight(0) * (pListBox->GetCount() + 1);
    r.right = r.left + width;
    pListBox->MoveWindow(r);

    m_fInPlaceDirty = false;

    return pListBox;
}
Example #26
0
void COptionsDlgSelector::OnDropdownDocOne() 
{
	int iMaxWidth	= 0;

	for (int i=0; i<m_cboDocumentOne.GetCount(); i++)
	{
		CSize	czText;
		CString csText;
		CDC *pDC = GetDC();

		m_cboDocumentOne.GetLBText(i, csText);
		czText = pDC->GetTextExtent(csText);

		if (czText.cx > iMaxWidth)
			iMaxWidth = czText.cx;

		ReleaseDC(pDC);
	}

	m_cboDocumentOne.SetDroppedWidth((int)(iMaxWidth * 0.8));
}
Example #27
0
//根据ITEM的长度,设置横向滚动条
void CMyListBox::SetHScroll()
{
	
	CString str;
	CSize   sz;
	int     dx=0;
	CDC*    pDC = this->GetDC();
	for (int i=0;i < this->GetCount();i++)
	{
	  this->GetText( i, str );
	  sz = pDC->GetTextExtent(str);

	  if (sz.cx > dx)
		dx = sz.cx;
	}
	this->ReleaseDC(pDC);

	// Set the horizontal extent so every character of all strings 
	// can be scrolled to.
	this->SetHorizontalExtent(dx);
}
Example #28
0
void CTTCheckBtnGroup::SetProperWidth(int maxWidth)
{
	if (GetSafeHwnd() == NULL)
		return;

	CDC* pDC = GetDC();
	int totalWidth = 0;
	for (int btnId = 0; btnId < m_Buttons.size(); ++btnId)
	{
		int textExt = pDC->GetTextExtent(m_Buttons[btnId].m_text).cx + 10;
		int desiredWidth = max(textExt, m_defaultButtonWidth);
		totalWidth += desiredWidth;
	}

	CRect clientRect;
	GetClientRect(clientRect);

	int newWidth = min(maxWidth, totalWidth);
	SetWindowPos(NULL, 0, 0, newWidth, clientRect.Height(), SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
	Invalidate();
}
/////////////////////////////////////////////////////////////////////////////
// CHScrollListBox message handlers
///////////////////////////////////////////////////////////////////////////////
int CHScrollListBox::GetTextLen(LPCTSTR lpszText)
{
	ASSERT(AfxIsValidString(lpszText));

	CDC *pDC = GetDC();
    ASSERT(pDC);
	CSize size;

    if ( pDC )
	{
		CFont* pOldFont = pDC->SelectObject(GetFont());
		if ( pOldFont ) 
		{
			size = pDC->GetTextExtent(lpszText, (int) _tcslen(lpszText));
			pDC->SelectObject(pOldFont);
		}
		ReleaseDC(pDC);
	}

	return size.cx +5; // add some whitespace
}
Example #30
0
long CRTabsCtrl::CalcWidestWord() 
{
	// Find the length of the longest word and put in widest
	int y;
	char word[30];
	long widest=0;
	int start;
	char* text;
	int width;
	CDC* pdc;
	pdc=GetDC();
    CFont* pOldFont;
	if (m_hWnd) pOldFont = pdc->SelectObject((CFont*)this->GetParent()->SendMessage(WM_GETGLOBALFONT,m_FontNum,NULL));
	else pOldFont = pdc->GetCurrentFont();
	POSITION position = m_textList.GetHeadPosition();
	for (int x=0;x<m_textList.GetCount();x++)
	{
		text=m_textList.GetNext(position);
		// split into component words
		start=0;
		for (y=0;y<(int)strlen(text)+1;y++) // includes terminating null character
		{
			if (text[y]==' ' || text[y]==NULL)
			{
				strncpy(word,text+start,min(y-start+1,30));
				word[min(y-start+1,30)]=NULL;
				start=y+1;
				width=pdc->GetTextExtent(word).cx+15;
				if (width>widest) widest=width;
			}
		}
	}
	pdc->SelectObject(pOldFont);
	ReleaseDC(pdc);
	widest+=15; // width of end bit of tab
	CRect rect;
	this->GetParent()->GetClientRect(rect);
	if (widest>rect.Width()/2) widest=rect.Width()/2;
	return widest;
}