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. draw on a dialog

draw on a dialog

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelp
3 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.
  • J Offline
    J Offline
    John Oliver
    wrote on last edited by
    #1

    Hello, I'm trying to draw on a dialog but I'm having no luck with the following code. It's my first time doing any gdi/device context stuff. I know there's better ways to display info than writing directly to a dialog but it's a bit of a hack. If anybody can help, thank-you. John //in oninitdialog CPaintDC dc(this); // device context for painting CPen* oldPen; CPen pen(PS_SOLID, 1, RGB(0,0,0)); oldPen = dc.SelectObject(&pen); dc.TextOut(20,20,"Mean Flow Velocity (m/s)"); dc.SelectObject(oldPen);

    P 1 Reply Last reply
    0
    • J John Oliver

      Hello, I'm trying to draw on a dialog but I'm having no luck with the following code. It's my first time doing any gdi/device context stuff. I know there's better ways to display info than writing directly to a dialog but it's a bit of a hack. If anybody can help, thank-you. John //in oninitdialog CPaintDC dc(this); // device context for painting CPen* oldPen; CPen pen(PS_SOLID, 1, RGB(0,0,0)); oldPen = dc.SelectObject(&pen); dc.TextOut(20,20,"Mean Flow Velocity (m/s)"); dc.SelectObject(oldPen);

      P Offline
      P Offline
      Prem Kumar
      wrote on last edited by
      #2

      Hi, You r not supposed to use the drawing code in OnInitDialog and more over CPaintDC should be used only when processing the WM_PAINT msg i.e only in OnPaint.(How abt brushing up a bit on the documentation ?) So move you code to OnPaint.

      J 1 Reply Last reply
      0
      • P Prem Kumar

        Hi, You r not supposed to use the drawing code in OnInitDialog and more over CPaintDC should be used only when processing the WM_PAINT msg i.e only in OnPaint.(How abt brushing up a bit on the documentation ?) So move you code to OnPaint.

        J Offline
        J Offline
        John Oliver
        wrote on last edited by
        #3

        Thanks Prem It works now. I'm using the following in OnPaint... CFont* pFont; CFont* pOrigFont; pFont= GetFont(); pOrigFont = pdc->SelectObject(pFont); pdc->SetBkColor(GetSysColor(COLOR_BTNFACE)); pdc->TextOut(40,40,"Mean Flow Velocity (m/s)");

        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