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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. use GdiPlus :: Font to SetFont of a static text control or convert GdiPlus :: Font to CFont

use GdiPlus :: Font to SetFont of a static text control or convert GdiPlus :: Font to CFont

Scheduled Pinned Locked Moved C / C++ / MFC
help
2 Posts 2 Posters 1 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.
  • _ Offline
    _ Offline
    _T No name
    wrote on last edited by
    #1

    i want to setFont of a CStatic text control. i have GdiPlus::Font i want to use that.. or it will do if i will be able to convert it to same CFont. any help thanx

    N 1 Reply Last reply
    0
    • _ _T No name

      i want to setFont of a CStatic text control. i have GdiPlus::Font i want to use that.. or it will do if i will be able to convert it to same CFont. any help thanx

      N Offline
      N Offline
      Nuri Ismail
      wrote on last edited by
      #2

      Here is some code for the conversion:

          // You need a Graphics object for the conversion.
          // If you have CDC or Graphics object, use them.
          // If you don't such an objects below is a **sample** code for their creation
          CDC\* pDC = CDC::FromHandle(::GetDC(NULL));
          Gdiplus::Graphics g(pDC->m\_hDC);
         
          // Here is the GDI+ Font
          Gdiplus::Font gdipFont(L"Arial", (REAL)8);
      
          // We will use a LOGFONT structure for the conversion
          LOGFONT lf;
          
          // Get the LOGFONT from the GDI+ Font
      

      #ifdef _UNICODE
      gdipFont.GetLogFontW(&g, &lf);
      #else
      gdipFont.GetLogFontA(&g, &lf);
      #endif

          // Create the font object
      CFont font;
      font.CreateFontIndirect(&lf);
      

      Hope this helps! :)

      modified on Tuesday, February 17, 2009 9:25 AM

      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