Hi I have a class derived from CStatic. And here OnPaint method override the. And let there by a small computational examples to draw lines. Now I've noticed that the lines Control hinausgezeichnet be the above. This is by coordinates quite ok but this area I will not even show. I knew already a solution ... CRect clientRect; GetClientRect (clientRect) then check which are distinguished from the Linen And to. But there is not there a simpler solution?
Hi Yes, exactly ... Code: void CMonitor:: OnPaint () ( CPaintDC dc ( this ); / / device context for painting CRect clientRect; GetClientRect (clientRect); CBrush bckGrndBrush; bckGrndBrush.CreateSolidBrush (m_ColorBkGnd); dc.FillRect (& clientRect, & bckGrndBrush) .... .... for ( int x = 0, x <m_cPos; x + +) ( dc.MoveTo (...); dc.LineTo (...); ) ... Something like ... got it now and briefly cut out, because I as pretty much herumbaue and nothing is done. But I sign as any mathematical functions into halt. What does "only"? one else should do it?
Code: IntersectClipRect (dc, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom); I'm now also the still installed. Thus it seems to work ...
As long as you have a CPaintDC it is impossible to draw outside the client area. The IntersectClipRect is unnecessary.
Hmm ? But that is my problem, just that the field is drawn on. I have derived from CStatic. .. In which I add the IntersectClipRect (..) is not drawn on the field ... If the subject the base class?
No! A CClientDC and CPaintDC is geclipt principle. Do you use somewhere in your character stuff is another CDC?
Nope that is a very small test program. Since I do not do much. Except a bit of drawing Code: / / Monitor.h ----------------------------------- class Monitor: public CStatic ( DECLARE_DYNAMIC (Monitor) public : Monitor () virtual ~ Monitor (); protected : afx_msg void OnPaint (); DECLARE_MESSAGE_MAP () ); Code: / / Monitor.cpp -------------------------------------- IMPLEMENT_DYNAMIC (monitor, CStatic) Monitor :: Monitor () ( ) Monitor:: ~ Monitor () ( ) BEGIN_MESSAGE_MAP (monitor, CStatic) ON_WM_PAINT () END_MESSAGE_MAP () void Monitor:: OnPaint () ( CPaintDC dc ( this ); clientRect CRect, GetClientRect (clientRect); CBrush bckGrndBrush; bckGrndBrush.CreateSolidBrush (RGB (0,100,0)); dc.FillRect (& clientRect, & bckGrndBrush); CPen penColorLine (PS_SOLID, 1, RGB (255,100,0)); dc.SelectObject (& penColorLine); dc.MoveTo ( 10, -600); / / here will rausgezeichnet " dc.LineTo (10.600); ) and in the example I can not IntersectClipRect (dc, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom); definitely draw on the field. ... And with Linto, MoveTo I draw just my sinus functions or grid or something ... Or even what I was doing wrong??