Click here to Skip to main content
15,917,481 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalconcat strings to hold int data types Pin
elephantstar20-Oct-04 11:07
elephantstar20-Oct-04 11:07 
GeneralRe: concat strings to hold int data types Pin
V.20-Oct-04 21:55
professionalV.20-Oct-04 21:55 
GeneralRe: concat strings to hold int data types Pin
David Crow21-Oct-04 3:02
David Crow21-Oct-04 3:02 
GeneralRe: concat strings to hold int data types Pin
elephantstar21-Oct-04 6:09
elephantstar21-Oct-04 6:09 
GeneralExpand/Collapse Customization of the CFileDialog Pin
BAmity20-Oct-04 10:12
BAmity20-Oct-04 10:12 
GeneralWindow Resizing to Fit the Font Pin
Ali Niaz20-Oct-04 9:55
Ali Niaz20-Oct-04 9:55 
GeneralRe: Window Resizing to Fit the Font Pin
PJ Arends20-Oct-04 10:14
professionalPJ Arends20-Oct-04 10:14 
GeneralRe: Window Resizing to Fit the Font Pin
Ali Niaz20-Oct-04 10:44
Ali Niaz20-Oct-04 10:44 
I was just testing to see what font is currently stored in CDC object and it turns out that it is totally different from the font of the window. Why is that? and how do I change the font of CDC object as there is no setFont function there.

the code is below:

//set the font of the window text
CWnd* pCtrlWnd = GetDlgItem(id);
CFont * oldFont = pCtrlWnd->GetFont();
LOGFONT* pLogFont = new LOGFONT;
oldFont->GetLogFont(pLogFont);
CString fontName = pLogFont->lfFaceName;
CFont * font = new CFont;
font->CreateFont(newFontSize,0,0,0,700,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, fontName);

//get the draw context of window

pCtrlWnd->SetFont(font);
//resize the window
CDC* pDC = pCtrlWnd->GetDC();
CString text;
pCtrlWnd->GetWindowText(text);

//get the textExtent
CSize stringSize = pDC->GetTextExtent(text);
pCtrlWnd->SetWindowPos(NULL, 0, 0, stringSize.cx * 1.4 , stringSize.cy * 1.45, SWP_NOMOVE|SWP_NOZORDER|SWP_NOREPOSITION);
}

A
GeneralRe: Window Resizing to Fit the Font Pin
PJ Arends20-Oct-04 20:03
professionalPJ Arends20-Oct-04 20:03 
Generalsorry its ERROR_ACCESS_DENIED Pin
Ann6620-Oct-04 9:28
sussAnn6620-Oct-04 9:28 
Generalport open problem Pin
Ann6620-Oct-04 9:26
sussAnn6620-Oct-04 9:26 
GeneralRe: port open problem Pin
David Crow20-Oct-04 10:00
David Crow20-Oct-04 10:00 
GeneralRe: port open problem Pin
Ann6620-Oct-04 10:03
sussAnn6620-Oct-04 10:03 
GeneralRe: port open problem Pin
Ted Ferenc20-Oct-04 21:35
Ted Ferenc20-Oct-04 21:35 
Generalchange icon of an exe file Pin
includeh1020-Oct-04 8:30
includeh1020-Oct-04 8:30 
GeneralRe: change icon of an exe file Pin
Joaquín M López Muñoz20-Oct-04 9:11
Joaquín M López Muñoz20-Oct-04 9:11 
GeneralRe: change icon of an exe file Pin
includeh1021-Oct-04 3:12
includeh1021-Oct-04 3:12 
GeneralCString Pin
Kehllendros20-Oct-04 8:28
Kehllendros20-Oct-04 8:28 
GeneralRe: CString Pin
Michael Dunn20-Oct-04 9:08
sitebuilderMichael Dunn20-Oct-04 9:08 
GeneralRe: CString Pin
peterchen20-Oct-04 10:20
peterchen20-Oct-04 10:20 
GeneralWindows Forms App in VC++ .NET Pin
NietzscheDisciple20-Oct-04 7:38
NietzscheDisciple20-Oct-04 7:38 
GeneralGetting the Items Pin
purshi20-Oct-04 7:32
purshi20-Oct-04 7:32 
GeneralUnknown error Pin
Rassul Yunussov20-Oct-04 7:28
Rassul Yunussov20-Oct-04 7:28 
GeneralRe: Unknown error Pin
Jim Crafton20-Oct-04 7:40
Jim Crafton20-Oct-04 7:40 
GeneralRe: Unknown error Pin
Rassul Yunussov20-Oct-04 17:16
Rassul Yunussov20-Oct-04 17:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.