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 change font on CButton?

How to change font on CButton?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
1 Posts 1 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.
  • S Offline
    S Offline
    Sampath579
    wrote on last edited by
    #1

    Hi. I created a CButton on a window and want to change the font of text on CButton. I tried as follows but dint work.

    CFont m_Font;

    LOGFONT lf;
    memset(&lf, 0, sizeof(LOGFONT)); // zero out structure
    lf.lfHeight = 12;  // request a 12-pixel-height font
    strcpy((char\*)lf.lfFaceName, "Arial"); // request a face name "Arial"
    VERIFY(m\_Font.CreateFontIndirect(&lf));  // create the font
    
    m\_but.Create(\_T("Sheet1"), BS\_PUSHBUTTON, CRect(0, 0, 70, 30), this, 101);
    m\_but.SetFont(&m\_Font);
    m\_but.ShowWindow(SW\_SHOW);
    

    May i know what i am missing?

    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