Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Why CreateFont()


Hi,

What is the difference between CreateFont() and CreateFontIndirect()? I noticed that CreateFontIndirect has less lines of code. So, why use CreateFont()?

Thanks for your help.
Jikko

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    :
    : Hi,
    :
    : What is the difference between CreateFont() and CreateFontIndirect()? I noticed that CreateFontIndirect has less lines of code. So, why use CreateFont()?
    :
    : Thanks for your help.
    : Jikko
    :
    [blue]No difference. Indirect creation uses LOGFONT structure and this structure is easy to save to a file (one WriteFile), so it may be restored later - when the program needs font settings.[/blue]
  • toddlerasimtoddlerasim Posts: 93Member
    : :
    : : Hi,
    : :
    : : What is the difference between CreateFont() and CreateFontIndirect()? I noticed that CreateFontIndirect has less lines of code. So, why use CreateFont()?
    : :
    : : Thanks for your help.
    : : Jikko
    : :
    : [blue]No difference. Indirect creation uses LOGFONT structure and this structure is easy to save to a file (one WriteFile), so it may be restored later - when the program needs font settings.[/blue]
    :
    : :
    : very true asmguru62, but the mental satisfaction one gets out of using createfont() is not matched by createfontindirect(). It is a piece of cake compared to the former. we are using the inbuilt font dialogbox in indirect whereas creating our own for nearly all the 18 parameters of the former is mindblowing.
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [blue]Which dialog box?
    Below I created a font in 4 lines (and I can save/restore it to disk!):
    [/blue]
    [code]
    LOGFONT lf = {0};

    strcpy (lf.lfFaceName, "Verdana");
    lf.lfHeight = -22;
    lf.lfWeight = FW_NORMAL;
    HFONT hFont = CreateFontIndirect (&lf);
    [/code]

  • toddlerasimtoddlerasim Posts: 93Member
    : [blue]Which dialog box?
    : Below I created a font in 4 lines (and I can save/restore it to disk!):
    : [/blue]
    : [code]
    : LOGFONT lf = {0};
    :
    : strcpy (lf.lfFaceName, "Verdana");
    : lf.lfHeight = -22;
    : lf.lfWeight = FW_NORMAL;
    : HFONT hFont = CreateFontIndirect (&lf);
    : [/code]
    :
    : asmguru62, apparently i blundered rather badly in understanding the indirect function. i was reffering to the common font dialogbox. regrets and thanks for pulling me up. it sure helps.

Sign In or Register to comment.