CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Font Dialog...

  1. #1
    Xeon's Avatar
    Xeon is offline Want me to ban you?! Power Poster
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    4,195

    Font Dialog...

    Hi there! Can anyone tel me how do I "PRESERVE" the CFontDialog settings after the user has closed it after editing the font styles and later when he open it for the 2nd time, the same settings will appear again? Thanks!(I've an SDI PROGRAM)
    THanks!
    Xeon

    "Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria

    "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria

  2. #2
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: Font Dialog...

    You can save CFontDialog::m_cf and for 2nd time use it before DoModal(). I don't suggest to copy it directly. You have to decide by yourself, which fields to copy.


  3. #3
    Xeon's Avatar
    Xeon is offline Want me to ban you?! Power Poster
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    4,195

    Hi IgBrus!

    Hi thanks! I know the steps u mentioned, but how what kinda variable can I use to save the CFontDialog::m_cf?
    I code something like belowin an SDI program)

    //this code is coded in the WM_COMMAND message handler of one of the toolbar button to show the CFontDialog.

    CFontDialog fontDialog;
    fontDialog.m_cf.lLogFont = m_StoredFont; //m_StoredFont is of type LOGFONT declared in the class definiton.
    if(fontDialog.DoModal()==IDOK)
    {
    //...apply the changes....
    m_StoredFont = fontDialog.m_cf.lLogFont;
    }


    As you can see, I always get an error or 2, and the thing doesn't work. Thanks!!!(I wanted to save the settings of the m_cf.lLogFont member)



    "Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria

    "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria

  4. #4
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: Hi IgBrus!

    m_cf hasn't LOGFONT field, bat has pointer to logfont field. So I suggest something as

    CFontDialog fontDialog;
    fontDialog.m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
    fontDialog.m_cf.lpLogFont = new LOGFONT;
    *(fontDialog.m_cf.lpLogFont) = m_StoredFont; //m_StoredFont is of type LOGFONT declared in the class definiton.
    if(fontDialog.DoModal()==IDOK)
    {
    //...apply the changes....
    m_StoredFont = *(fontDialog.m_cf.lpLogFont);
    }
    delete fontDialog.m_cf.lpLogFont;







  5. #5
    Xeon's Avatar
    Xeon is offline Want me to ban you?! Power Poster
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    4,195

    Thanks a lot!

    Hi there! I've rated u 2 EXCELLENTS for each of ya' help. But here's a question for the current post:
    *(fontDialog.m_cf.lpLogFont) = m_StoredFont;
    What is the '*' doing here? Thanks!(help me & you'll get another EXCELLENT!)

    "Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria

    "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria

  6. #6
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: Thanks a lot!

    1.Thanks for rating, but you know: we are here for the help, not for rating. Friends haven't to pay to friends. Anyway thanks oncemore for your evaluation of my efforts.
    2. Because m_cf.lpLogFont is pointer to LOGFONT object and m_StoredFont is LOGFONT, we apply * and default assignment operator. It has the same effect as

    memcpy(fontDialog.m_cf.lpLogFont, &m_StoredFont, sizeof(LOGFONT));





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured