Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to set the default font name when I call ChooseFont(..) ?

How to set the default font name when I call ChooseFont(..) ?

Scheduled Pinned Locked Moved C / C++ / MFC
delphitutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wangningyu
    wrote on last edited by
    #1

    Hello Everybody ! when I call the system font dialog like this,how to set the default font name and size ?

    HFONT FAR PASCAL MyCreateFont( void )
    {
    CHOOSEFONT cf;
    LOGFONT lf;
    HFONT hfont;

    // Initialize members of the CHOOSEFONT structure.  
    cf.lStructSize = sizeof(CHOOSEFONT); 
    cf.hwndOwner = (HWND)NULL; 
    cf.hDC = (HDC)NULL; 
    cf.lpLogFont = &lf; 
    cf.iPointSize = 0; 
    cf.Flags = CF\_SCREENFONTS; 
    cf.rgbColors = RGB(0,0,0); 
    cf.lCustData = 0L; 
    cf.lpfnHook = (LPCFHOOKPROC)NULL; 
    cf.lpTemplateName = (LPSTR)NULL; 
    cf.hInstance = (HINSTANCE) NULL; 
    cf.lpszStyle = (LPSTR)NULL; 
    cf.nFontType = SCREEN\_FONTTYPE; 
    cf.nSizeMin = 0; 
    cf.nSizeMax = 0; 
    
    
    // Display the CHOOSEFONT common-dialog box.  
    // How to set the defalut font name or size before call this function??? 
    ChooseFont(&cf); 
    
    
    // Create a logical font based on the user's  
    // selection and return a handle identifying  
    // that font.   
    hfont = CreateFontIndirect(cf.lpLogFont); 
    return (hfont); 
    

    }

    Thanks for your reply ! Best Regards !

    L 1 Reply Last reply
    0
    • W wangningyu

      Hello Everybody ! when I call the system font dialog like this,how to set the default font name and size ?

      HFONT FAR PASCAL MyCreateFont( void )
      {
      CHOOSEFONT cf;
      LOGFONT lf;
      HFONT hfont;

      // Initialize members of the CHOOSEFONT structure.  
      cf.lStructSize = sizeof(CHOOSEFONT); 
      cf.hwndOwner = (HWND)NULL; 
      cf.hDC = (HDC)NULL; 
      cf.lpLogFont = &lf; 
      cf.iPointSize = 0; 
      cf.Flags = CF\_SCREENFONTS; 
      cf.rgbColors = RGB(0,0,0); 
      cf.lCustData = 0L; 
      cf.lpfnHook = (LPCFHOOKPROC)NULL; 
      cf.lpTemplateName = (LPSTR)NULL; 
      cf.hInstance = (HINSTANCE) NULL; 
      cf.lpszStyle = (LPSTR)NULL; 
      cf.nFontType = SCREEN\_FONTTYPE; 
      cf.nSizeMin = 0; 
      cf.nSizeMax = 0; 
      
      
      // Display the CHOOSEFONT common-dialog box.  
      // How to set the defalut font name or size before call this function??? 
      ChooseFont(&cf); 
      
      
      // Create a logical font based on the user's  
      // selection and return a handle identifying  
      // that font.   
      hfont = CreateFontIndirect(cf.lpLogFont); 
      return (hfont); 
      

      }

      Thanks for your reply ! Best Regards !

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      It took me 10 seconds to google one word and find the answer, in the form of this sentence: If you set the ... flag in the Flags member and initialize the other members, the ChooseFont function initializes the dialog box with a font that matches ... :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      W 1 Reply Last reply
      0
      • L Luc Pattyn

        It took me 10 seconds to google one word and find the answer, in the form of this sentence: If you set the ... flag in the Flags member and initialize the other members, the ChooseFont function initializes the dialog box with a font that matches ... :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        W Offline
        W Offline
        wangningyu
        wrote on last edited by
        #3

        :~ I'm sorry... thanks !

        L 1 Reply Last reply
        0
        • W wangningyu

          :~ I'm sorry... thanks !

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          No problem. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups