1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

control records outside the range

Discussion in 'MFC' started by inspiration, May 28, 2010.

  1. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    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?:confused:
     
  2. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    Pointer times as you. You take the only sure CPaintDC?
     
  3. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  4. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    IntersectClipRect (dc, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom);
    I'm now also the still installed.
    Thus it seems to work ...
     
  5. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    As long as you have a CPaintDC it is impossible to draw outside the client area. The IntersectClipRect is unnecessary.
     
  6. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    Hmm ? :confused::confused:
    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?
     
  7. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    No! A CClientDC and CPaintDC is geclipt principle.

    Do you use somewhere in your character stuff is another CDC?
     
  8. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    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??
     

Share This Page