 |
|
 |
Hi !
Great class simplifies things a bit.
How do you use the SetFontColor method you seem to need to set the current DC ?
Whats that all about?
Chris
|
|
|
|
 |
|
 |
Colour is handled separately. You need the DC to set the colour.
|
|
|
|
 |
|
 |
OK, I'm currently working on the update to this class, and have implemented most of what you all have suggested. I'm extremely busy of late (thus the long delay in doing all this), but I wanted to assure you that an update IS coming. Thanks for the patience!
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
 |
|
 |
Hi Jamie,
Thanks for your interesting article. Have you finished/posted your update somewhere on the net ? (this article on codeproject hasn't changed for some time...)
Peter
|
|
|
|
 |
|
 |
First off, this is a great class, really useful.
I had a problem, though, that vexed me for a while: I was storing the string generated by ContractFont in a document, but was losing the string if I made any other document changes and re-saved.
Here's the issue: ExtractFont passes the string by reference. It was eating up my string when I called it!
So I removed the reference operators (&) from the function definition and implementation and now all is fine.
I suppose that if somebody didn't want to monkey with the class, they could always copy their string to a dummy string and pass *that* to the function.
Thanks for the class.
Tim
|
|
|
|
 |
|
 |
Thanks for the info, Tim. One of these eons (hopefully soon) I need to update this thing and repost it. I'll probably have time in a couple weeks (I have my black belt test this weekend, so I'll try for next).
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
 |
|
 |
.. is to do at first
CString strWork(str);
and then use strWork with GetToken() ...
cr97
|
|
|
|
 |
|
 |
Great code, but you need to change GetOrientation so that it returns lfOrientation and not lfEscapement.
In other words, it should look like:
LONG CAutoFont::GetOrientation()
{
return lf.lfOrientation;
}
|
|
|
|
 |
|
 |
Hello.
This class is simple, and useful. But The point size of a font is useful too. If you need it, create a member function with the following contain :
return (-MulDiv (Font.GetHeight(), 72, GetDeviceCaps (GetDC()->GetSafeHdc(), LOGPIXELSY))) ;
It returns the height of a font int point size.
Have a good day.
Jonny
|
|
|
|
 |
|
 |
How to handle the printing in any MFC MDI Application using the Autofont in OnDraw
if I select a font and size, go to a print preview the font ist realy small.
Do anyone have any idea's how to get the real font size for printing?
Thanks Marcus
PS: By the way it's a realy nice class.
|
|
|
|
 |
|
 |
This snippet will compute a font height for the printer that has the same proportions of the font as it appears on screen. (However, I believe this is only true if the printer has the same values for both LOGPIXELSY and LOGPIXELSX.)
if ( pDC->IsPrinting )
{
CAutoFont myFont;
int nPrintHeight = MulDiv(myFont.GetHeight(), pDC->GetDeviceCaps(LOGPIXELSY),96);
myFont.SetHeight( nHeightDPI );
// ... do some rendering here
}
|
|
|
|
 |
|
 |
lf.lfWidth always equals to 0...How to get its real value?
|
|
|
|
 |
|
 |
It would be nice to have a function SetSize to set the point size, because it is very difficult to calculate the height and width from the point size
|
|
|
|
 |
|
 |
The CAutoFont class is a very useful class, which makes the font-handling quite easy.
|
|
|
|
 |
|
 |
Can anyone help me to extract Color from color combo in CFontDialog box when apply button is pressed.When I tried to use CFHookProc but was not successful.Some code piece will be of great use.
|
|
|
|
 |
|
|
 |
|
 |
Thanks for the encouraging word, Jason! :
|
|
|
|
 |
|
 |
Hi Jamie,
I have extended your class--which BTW is very helpful--by some functions to get Windows standard fonts, such as menu font and so on:BOOL CAutoFont::CreateMenuFont()
{
NONCLIENTMETRICS ncm = {0};
ncm.cbSize = sizeof( NONCLIENTMETRICS );
if (!SystemParametersInfo( SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0 ))
return FALSE;
DeleteObject();
return CreateFontIndirect( &ncm.lfMenuFont );
}
BOOL CAutoFont::CreateMessageFont()
{
NONCLIENTMETRICS ncm = {0};
ncm.cbSize = sizeof( NONCLIENTMETRICS );
if (!SystemParametersInfo( SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0 ))
return FALSE;
DeleteObject();
return CreateFontIndirect( &ncm.lfMessageFont );
}
BOOL CAutoFont::CreateStatusFont()
{
NONCLIENTMETRICS ncm = {0};
ncm.cbSize = sizeof( NONCLIENTMETRICS );
if (!SystemParametersInfo( SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0 ))
return FALSE;
DeleteObject();
return CreateFontIndirect( &ncm.lfStatusFont );
}
|
|
|
|
 |
|
 |
> This message was created automatically by mail delivery software.
>
> A message that you sent could not be delivered to all of its recipients. The
> following address(es) failed:
>
> nordyj@gte.net:
> SMTP error from remote mailer after RCPT TO:
> :
> host mtapop3pub.gte.net [206.46.170.36]:
> 550 Invalid recipient:
>
|
|
|
|
 |
|
 |
I'm trying to get that fixed right now, but unfortunately, I can't change my records for some reason.
The correct address to be mailing to is:
jamie.nordmeyer@mcgnw.com
|
|
|
|
 |
|
 |
Cool! I am dire need of updating the control (been busy on other projects), so I'll include this in the next release (with proper representation, of course)
|
|
|
|
 |
|
 |
Cool! I am dire need of updating the control (been busy on other projects), so I'll include this in the next release (with proper representation, of course)
|
|
|
|
 |
|
 |
If you create a font using CreateFontIndirect() you must call DeleteObject() in the destructor of your class.
CAutoFont::~CAutoFont()
{
// SSK - must delete the object
DeleteObject();
}
|
|
|
|
 |
|
 |
Ah, good point. Thanks for reminding me
|
|
|
|
 |
|
 |
This is not necessary in VC++ v6.0. If you use the CreateFontIndirect method of CFont that is. CFont is derived from CGdiObject and its destructor calls DeleteObject so it is already taken care of.
The Ten Commandments For C Programmers
|
|
|
|
 |