Bellow is code where I drawing rectangles for my app.
Sub bellow is called from Canvas.Paint, where g is sent from Canvas.Paint as its Graphics.
rct() is declared as Graphics.
I am creating clip for each rectangle I draw.
Canvas object in window is resized to Window.height-15 and Window.width-15 and there is small label as status bar in bottom of window with height=15.
My problem is, when I resize window size (Canvas is also sized after resize), then my drawings is not ending at Canvas end but is overlapping to end of window and over label object.
As I understand drawings should ends at border of Canvas.
Here is screenshot how my rectangles are painted over label and out of Canvas.
[code]Sub DrawGuardOutline(i as integer, g as Graphics)
rct(i)=g.clip(OvwData(i).X,OvwData(i).Y,ClipWidth,ClipHeight)//Create Clip
rct(i).PenHeight=2
rct(i).PenWidth=2
rct(i).ForeColor=EventColor
rct(i).DrawRoundRect(0,0,rct(i).Width,rct(i).Height,7,7)//Draw Outline
rct(i).PenHeight=1
rct(i).PenWidth=1
rct(i).FillRoundRect(2,2,rct(i).Width-4,rct(i).Height-4,7,7)//Fill Rect
End Sub
[/code]
I had unchecked this, but enable of locks did not help.
I am resizing Canvas on each resize of parent window by code.
Weird is, but when I create non-resizeable small canvas 100x100 pixels I got entire rectangles painted outside of Canvas.
It looks like my rectangles are painted on Window background.
But Window.Paint method is empty.
You are right.
When I pass Graphics.Clip as parameter to Sub then Paint is done on Window background.
I recode it to not use CLIPs and rectangles are now correctly inside Canvas.
Reason why I used clips is, that I pass various objects and texts into rectangles and it was easier for coding to use coordinates of clip.
E.g. draw from position 0,0 etc…Now I will also need to refine code for checking of text length, because I have resizeable rectangles and longer text is outside of rectangle and clip solves it automatcally. (text was trimmed at clip edges)
Btw I think it should work also for clips. So maybe it is bug.