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. CPen

CPen

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 3 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.
  • A Offline
    A Offline
    Ahmad99
    wrote on last edited by
    #1

    I want to write Bold data (28 points) on a Dialog...against a buutton click here is code snippet { CPen pen; pen.CreatePen(PS_SOLID,28,RGB(255,0,0)); CDC* pDC=GetDC(); pDC->SelectObject(&pen); pDC->TextOut("Computer is the killer of nature"); } it writes data but not bold and Selected color.. Can any one tell where I am doing wrong

    J 1 Reply Last reply
    0
    • A Ahmad99

      I want to write Bold data (28 points) on a Dialog...against a buutton click here is code snippet { CPen pen; pen.CreatePen(PS_SOLID,28,RGB(255,0,0)); CDC* pDC=GetDC(); pDC->SelectObject(&pen); pDC->TextOut("Computer is the killer of nature"); } it writes data but not bold and Selected color.. Can any one tell where I am doing wrong

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      It is not the pen you should change, but the font. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      A 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        It is not the pen you should change, but the font. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        A Offline
        A Offline
        Ahmad99
        wrote on last edited by
        #3

        how I change? tell me....

        M 1 Reply Last reply
        0
        • A Ahmad99

          how I change? tell me....

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          for example :

          // m_Font is a class member of a dialog.

          m_Font.CreateFont( 15, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0,
          DEFAULT_CHARSET, OUT_CHARACTER_PRECIS,
          CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,
          DEFAULT_PITCH | FF_DONTCARE, _T("Arial") );
          ...
          // somewhere in the paint.
          HFONT hfontOld;
          hfontOld = (HFONT)SelectObject(dc.m_hDC, m_Font);
          // do something... with the DC ( draw the text.
          ::SelectObject(dc.m_hDC, hfontOld);
          ...

          Also, you can maybe search and enumerate the font name just in case "Arial" does not exists. Max.

          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