|
-
September 22nd, 1999, 10:56 AM
#1
GetTextExtent
In the following code, all works well. But the width of the text obtained by GetTextExtent seems to be more that the actual text width.
Any reason for this?
BOOL CWarnListDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CClientDC dc(this);
int n, nTextWidth, nMaxTextWidth = 0;
for(n = 0; n < m_ErrorList.GetSize(); n++)
{
m_WarnList.AddString(m_ErrorList[n]);
nTextWidth = dc.GetTextExtent(m_ErrorList[n]).cx;
if(nTextWidth > nMaxTextWidth)
nMaxTextWidth = nTextWidth;
}
// set horizontal bar extent
m_WarnList.SetHorizontalExtent(nMaxTextWidth);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Hope you can help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|