Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: Get a HBITMAP from a BITMAP structure. Pin
Nishad S12-Dec-08 1:38
Nishad S12-Dec-08 1:38 
GeneralRe: Get a HBITMAP from a BITMAP structure. Pin
VC++Maniac12-Dec-08 1:39
VC++Maniac12-Dec-08 1:39 
GeneralRe: Get a HBITMAP from a BITMAP structure. Pin
Nishad S12-Dec-08 1:44
Nishad S12-Dec-08 1:44 
QuestionCom is not opening correctly, is any dll missing? Pin
shir_k12-Dec-08 0:11
shir_k12-Dec-08 0:11 
QuestionRe: Com is not opening correctly, is any dll missing? Pin
CPallini12-Dec-08 0:14
mveCPallini12-Dec-08 0:14 
AnswerRe: Com is not opening correctly, is any dll missing? Pin
shir_k12-Dec-08 1:27
shir_k12-Dec-08 1:27 
GeneralRe: Com is not opening correctly, is any dll missing? Pin
CPallini12-Dec-08 1:43
mveCPallini12-Dec-08 1:43 
QuestionError 10038 , at receive on serbver side Pin
singh_nav11-Dec-08 23:32
singh_nav11-Dec-08 23:32 
AnswerRe: Error 10038 , at receive on serbver side Pin
Code-o-mat12-Dec-08 1:48
Code-o-mat12-Dec-08 1:48 
QuestionShell Extension to Change the File Type Text Pin
Steve Thresher11-Dec-08 22:39
Steve Thresher11-Dec-08 22:39 

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.