Text drawing is not getting properly
-
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
-
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
Use Invalidate () to make the framework invoke your OnPaint handler to update the screen.
-
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
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
-
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
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
-
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
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