Click here to Skip to main content
15,910,878 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: using SAFEARRAY Pin
KASR112-Dec-08 3:23
KASR112-Dec-08 3:23 
AnswerRe: using SAFEARRAY Pin
KASR112-Dec-08 3:24
KASR112-Dec-08 3:24 
QuestionSize of memory pointed to by void * pointer. Pin
VC++Maniac12-Dec-08 1:00
VC++Maniac12-Dec-08 1:00 
AnswerRe: Size of memory pointed to by void * pointer. Pin
Naveen12-Dec-08 1:16
Naveen12-Dec-08 1:16 
AnswerRe: Size of memory pointed to by void * pointer. Pin
Jijo.Raj12-Dec-08 1:18
Jijo.Raj12-Dec-08 1:18 
GeneralRe: Size of memory pointed to by void * pointer. Pin
VC++Maniac12-Dec-08 1:38
VC++Maniac12-Dec-08 1:38 
GeneralRe: Size of memory pointed to by void * pointer. Pin
Jijo.Raj12-Dec-08 2:08
Jijo.Raj12-Dec-08 2:08 
GeneralRe: Size of memory pointed to by void * pointer. Pin
VC++Maniac12-Dec-08 2:14
VC++Maniac12-Dec-08 2:14 
QuestionHow to write BITMAP structure to xml file? Pin
VC++Maniac12-Dec-08 0:57
VC++Maniac12-Dec-08 0:57 
AnswerRe: How to write BITMAP structure to xml file? Pin
enhzflep12-Dec-08 14:17
enhzflep12-Dec-08 14:17 
GeneralRe: How to write BITMAP structure to xml file? Pin
VC++Maniac12-Dec-08 17:40
VC++Maniac12-Dec-08 17:40 
QuestionFont problem Pin
trioum12-Dec-08 0:53
trioum12-Dec-08 0:53 
QuestionRe: Font problem Pin
CPallini12-Dec-08 0:58
mveCPallini12-Dec-08 0:58 
AnswerRe: Font problem Pin
trioum12-Dec-08 1:17
trioum12-Dec-08 1:17 
GeneralRe: Font problem Pin
CPallini12-Dec-08 1:49
mveCPallini12-Dec-08 1:49 
GeneralRe: Font problem Pin
trioum14-Dec-08 18:04
trioum14-Dec-08 18:04 
GeneralRe: Font problem Pin
trioum14-Dec-08 18:26
trioum14-Dec-08 18:26 
GeneralRe: Font problem Pin
Hans Dietrich15-Dec-08 6:23
mentorHans Dietrich15-Dec-08 6:23 
trioum wrote:
lf.lfHeight giving the arbitrary wrong negative values


As MSDN tells you, you can use the following formula to specify a height for a font with a specified point size:
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);

So you can use a simple function like the following to get the (positive) point size (which is what the font dialog displays) from the LOGFONT height:
int GetFontPointSize(int nHeight)
{
    HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
    ASSERT(hdc);
    int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
    ::DeleteDC(hdc);
    int nPointSize = MulDiv(nHeight, 72, cyPixelsPerInch);
    if (nPointSize < 0)
        nPointSize = -nPointSize;
    return nPointSize;
}

Note that you must use logical units for the lfHeight parameter in the LOGFONT struct. To get logical units from point size, you can use following function:
int GetFontHeight(int nPointSize)
{
	HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
	ASSERT(hdc);
	int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
	::DeleteDC(hdc);
	int nHeight = -MulDiv(nPointSize, cyPixelsPerInch, 72);
	return nHeight;
}



QuestionProgress bar ctrl question Pin
josip cagalj12-Dec-08 0:50
josip cagalj12-Dec-08 0:50 
AnswerRe: Progress bar ctrl question Pin
Iain Clarke, Warrior Programmer12-Dec-08 2:50
Iain Clarke, Warrior Programmer12-Dec-08 2:50 
GeneralRe: Progress bar ctrl question Pin
josip cagalj12-Dec-08 3:23
josip cagalj12-Dec-08 3:23 
GeneralRe: Progress bar ctrl question Pin
Iain Clarke, Warrior Programmer12-Dec-08 3:35
Iain Clarke, Warrior Programmer12-Dec-08 3:35 
GeneralRe: Progress bar ctrl question Pin
josip cagalj12-Dec-08 3:42
josip cagalj12-Dec-08 3:42 
GeneralRe: Progress bar ctrl question Pin
josip cagalj14-Dec-08 23:04
josip cagalj14-Dec-08 23:04 
QuestionGet a HBITMAP from a BITMAP structure. Pin
VC++Maniac12-Dec-08 0:24
VC++Maniac12-Dec-08 0:24 

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.