Help: CFontDialog 
Author Message
 Help: CFontDialog

Dear All,

Maybe it is quite simple, but how can I construct a
CFontDialog with the current font of my control?  I know
how to specify a font (such as "Arial") before I call
DoModal(), but I do not know how to make the current font
to be selected upon loading up the dialog.

Thank you very much in advance.

Lee



Sat, 20 Mar 2004 00:10:11 GMT  
 Help: CFontDialog
Try this Q+D code (extra error handling would be advised):

CWnd*    pControl = GetDlgItem(ID_MY_CONTROL);    // get control
CFont*    pFont = pControl->GetFont();    // get font for control
LOGFONT    lf;    logical font structure
pFont->GetLogFont(&lf);    // fill structure from control's font
CFontDialog    dlg(&lf, ....);    // instantiate font dialog with LOGFONT,
etc.
if (dlg.DoModal() == IDOK)    // run dialog
{
    // yadda, yadda, yadda

Quote:
}

TFM3

Note: Spam-resistant e-mail address


Quote:
> Dear All,

> Maybe it is quite simple, but how can I construct a
> CFontDialog with the current font of my control?  I know
> how to specify a font (such as "Arial") before I call
> DoModal(), but I do not know how to make the current font
> to be selected upon loading up the dialog.

> Thank you very much in advance.

> Lee



Sat, 20 Mar 2004 00:26:04 GMT  
 Help: CFontDialog
Thanks a lot, Tom.

Quote:
>-----Original Message-----
>Try this Q+D code (extra error handling would be advised):

>CWnd*    pControl = GetDlgItem(ID_MY_CONTROL);    // get
control
>CFont*    pFont = pControl->GetFont();    // get font for
control
>LOGFONT    lf;    logical font structure
>pFont->GetLogFont(&lf);    // fill structure from
control's font
>CFontDialog    dlg(&lf, ....);    // instantiate font

dialog with LOGFONT,
Quote:
>etc.
>if (dlg.DoModal() == IDOK)    // run dialog
>{
>    // yadda, yadda, yadda
>}

>TFM3



Sat, 20 Mar 2004 01:41:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Newbie, help with custom CFontDialog

2. Newbie, help setting default values to a custom CFontDialog

3. CFontDialog Help

4. Pulling my hair out with CFontDialog (Help)

5. Custom CFontDialog - Need help!

6. Newbie, help with custom CFontDialog

7. Newbie, help setting default values for a custom CFontDialog

8. Modeless CFontDialog??

9. How to make a Modeless CFontDialog?

10. CPropertySheet CFontDialog

11. CFontDialog Init problem

12. CFontDialog sets initial font color to black

 

 
Powered by phpBB® Forum Software