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. Text drawing is not getting properly

Text drawing is not getting properly

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphics
5 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
    Amrit Agr
    wrote on last edited by
    #1

    Hi Developers, I want to draw text(number of recorded symptoms) at OnPaint() This is a Dialog Bar in which i have handled OnPaint() as well. Here the code: CString strClipCount; CRect rcClipBoard; m_stClipMind.GetWindowRect( rcClipBoard ); ScreenToClient(rcClipBoard); strClipCount.Format( _T("%3d"), theApp.m_MentalClipbrd.GetCount() ); CPaintDC paintDC(this); paintDC.Rectangle(rcClipBoard); //COLORREF color = paintDC.SetBkColor(RGB(255,255,255)); paintDC.SelectObject(theApp.pCtrlFont); paintDC.SetTextColor(RGB(0,0,0)); paintDC.TextOut( rcClipBoard.left, rcClipBoard.top, strClipCount, strlen(strClipCount) ); The problem is that the painting is not getting properly i.e. Whenever a msg box get shown at click of it's OK button it display the text for a while & after that it gets disappeared. Can anyone help me out. Thanks. Amrit Agrawal Software Developer

    A X 2 Replies Last reply
    0
    • A Amrit Agr

      Hi Developers, I want to draw text(number of recorded symptoms) at OnPaint() This is a Dialog Bar in which i have handled OnPaint() as well. Here the code: CString strClipCount; CRect rcClipBoard; m_stClipMind.GetWindowRect( rcClipBoard ); ScreenToClient(rcClipBoard); strClipCount.Format( _T("%3d"), theApp.m_MentalClipbrd.GetCount() ); CPaintDC paintDC(this); paintDC.Rectangle(rcClipBoard); //COLORREF color = paintDC.SetBkColor(RGB(255,255,255)); paintDC.SelectObject(theApp.pCtrlFont); paintDC.SetTextColor(RGB(0,0,0)); paintDC.TextOut( rcClipBoard.left, rcClipBoard.top, strClipCount, strlen(strClipCount) ); The problem is that the painting is not getting properly i.e. Whenever a msg box get shown at click of it's OK button it display the text for a while & after that it gets disappeared. Can anyone help me out. Thanks. Amrit Agrawal Software Developer

      A Offline
      A Offline
      Alan Balkany
      wrote on last edited by
      #2

      Use Invalidate () to make the framework invoke your OnPaint handler to update the screen.

      1 Reply Last reply
      0
      • A Amrit Agr

        Hi Developers, I want to draw text(number of recorded symptoms) at OnPaint() This is a Dialog Bar in which i have handled OnPaint() as well. Here the code: CString strClipCount; CRect rcClipBoard; m_stClipMind.GetWindowRect( rcClipBoard ); ScreenToClient(rcClipBoard); strClipCount.Format( _T("%3d"), theApp.m_MentalClipbrd.GetCount() ); CPaintDC paintDC(this); paintDC.Rectangle(rcClipBoard); //COLORREF color = paintDC.SetBkColor(RGB(255,255,255)); paintDC.SelectObject(theApp.pCtrlFont); paintDC.SetTextColor(RGB(0,0,0)); paintDC.TextOut( rcClipBoard.left, rcClipBoard.top, strClipCount, strlen(strClipCount) ); The problem is that the painting is not getting properly i.e. Whenever a msg box get shown at click of it's OK button it display the text for a while & after that it gets disappeared. Can anyone help me out. Thanks. Amrit Agrawal Software Developer

        X Offline
        X Offline
        xrg_soft 163 com
        wrote on last edited by
        #3

        If I understood you correctly, the m_stClipMind is a place holder CStatic? If so, the problem is after your paint on the rect, when m_stClipMind refresh itself, your text will get erased. two way to fix: 1) remove the WS_VISIBLE style for the m_stClipMind 2) using m_stClipMind.SetWindowText

        A 1 Reply Last reply
        0
        • X xrg_soft 163 com

          If I understood you correctly, the m_stClipMind is a place holder CStatic? If so, the problem is after your paint on the rect, when m_stClipMind refresh itself, your text will get erased. two way to fix: 1) remove the WS_VISIBLE style for the m_stClipMind 2) using m_stClipMind.SetWindowText

          A Offline
          A Offline
          Amrit Agr
          wrote on last edited by
          #4

          Thanks my friend, Now it's getting properly painted. Can you help me at one more issue. There is some other windows in which symptoms of a patient is listed. If I am double clicked on any symptom, on the respective clipboard the count should be updated. The clip board is a dialog bar. In that dialog bar in OnPaint() is am painting that count on the area of static text (so it will be update on the fly). After recording a symptom it is not getting painted that count, but if Invalidate() get called implicitly, like switched to another window. the count get updated( painted ). How can I invalidate that dialog bar from other window. Thanks In Advance. Amrit Agrawal Software Developer

          X 1 Reply Last reply
          0
          • A Amrit Agr

            Thanks my friend, Now it's getting properly painted. Can you help me at one more issue. There is some other windows in which symptoms of a patient is listed. If I am double clicked on any symptom, on the respective clipboard the count should be updated. The clip board is a dialog bar. In that dialog bar in OnPaint() is am painting that count on the area of static text (so it will be update on the fly). After recording a symptom it is not getting painted that count, but if Invalidate() get called implicitly, like switched to another window. the count get updated( painted ). How can I invalidate that dialog bar from other window. Thanks In Advance. Amrit Agrawal Software Developer

            X Offline
            X Offline
            xrg_soft 163 com
            wrote on last edited by
            #5

            After you create the dialog bar, try to passing its window handle to other window. and when update needed, in the other window, call InvalidateRect(hWndDialogBar

            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