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. Drawing a Caption using CDC Class

Drawing a Caption using CDC Class

Scheduled Pinned Locked Moved C / C++ / MFC
graphics
3 Posts 2 Posters 3 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi I am trying to write a caption to my modeless dialog box I did a getwindowrect and screen to client as the negative "y" coordinates would be where I would want to place my text did dc->Setcolor to blue got my text extents from CDC When I did a dc->textout nothing happened I also noticed Cwnd has DrawCaption but doesnt take a parameter for Text. DrawText however has a DT_TEXT flag but where does it pick up the text Can you write a caption using a device context Thanks

    G 1 Reply Last reply
    0
    • F ForNow

      Hi I am trying to write a caption to my modeless dialog box I did a getwindowrect and screen to client as the negative "y" coordinates would be where I would want to place my text did dc->Setcolor to blue got my text extents from CDC When I did a dc->textout nothing happened I also noticed Cwnd has DrawCaption but doesnt take a parameter for Text. DrawText however has a DT_TEXT flag but where does it pick up the text Can you write a caption using a device context Thanks

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      It sounds like you are trying to write in the title bar of the window - is that right? The easy way is to call SetWindowText() on the dialog box HWND (or do whatever the MFC equivalent is) and let the default dialog proc handle drawing your text. Otherwise you would have to draw in the non-client area, which has its own WM_NCPAINT message to handle.

      F 1 Reply Last reply
      0
      • G Graham Breach

        It sounds like you are trying to write in the title bar of the window - is that right? The easy way is to call SetWindowText() on the dialog box HWND (or do whatever the MFC equivalent is) and let the default dialog proc handle drawing your text. Otherwise you would have to draw in the non-client area, which has its own WM_NCPAINT message to handle.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        thanks I choose the later NC_CLIENT might I ask you a few follow up questions 1) is there a way to determine the NC area,like GetWindowNCRect. In Additon TextOut is giving me issues would I be better off using DrawText would it need to be preceded by DrawCaption Not sure as if you could steer me the right direction would appreciate it

        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