I all,
I admit I've done much more difficult things, but I'm stuck here.
I need to make sure that when resizing the form (so even the Canvas that fit it), the 2 pixel wide red border is always shown, as in the first image attached, but without deleting the current content.
I've tried various ways but without success.
Does anyone understand how to do it?
Here is my simple code
Note, here the mainPnl is a panel on the designer, it fits the window and canvas is initialized to it.
Many thanks for help.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I admit I've done much more difficult things, but I'm stuck here.
I need to make sure that when resizing the form (so even the Canvas that fit it), the 2 pixel wide red border is always shown, as in the first image attached, but without deleting the current content.
I've tried various ways but without success.
Does anyone understand how to do it?
Here is my simple code
Note, here the mainPnl is a panel on the designer, it fits the window and canvas is initialized to it.
Many thanks for help.
			
				B4X:
			
		
		
		Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
 
    Dim cvs As B4XCanvas
    Private mainPnl As Pane
    Private fnt As Font
End Sub
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
 
    fnt = fx.CreateFont("Monospace",12,True,False)
    cvs.Initialize(mainPnl)
    Clear
    cvs.DrawText("I have to stay here when the canvas changes size", 50, 200, fx.CreateFont("Monospace",18,True,False), xui.Color_Cyan, "LEFT")
End Sub
Sub MainForm_Resize (Width As Double, Height As Double)
    cvs.Resize(Width,Height)
    ShowScreenDimensions
    ShowBorders
End Sub
Sub Clear
    Dim rect As B4XRect
    rect.Initialize(0, 0, cvs.TargetRect.Width, cvs.TargetRect.Height)
    cvs.DrawRect(rect, xui.Color_Black, True, 1)
End Sub
Sub ShowScreenDimensions
    Dim rect As B4XRect
    rect.Initialize(1, 1, 130dip, 80dip)
    cvs.DrawRect(rect, xui.Color_Black, True, 1)
 
    cvs.DrawText("DPI:    " & (96*Density), 20dip, 25dip, fnt, xui.Color_White, "LEFT")
    cvs.DrawText("Scale:  " & Density, 20dip, 38dip, fnt, xui.Color_White, "LEFT")
    cvs.DrawText("Width:  " & mainPnl.Width,20dip, 51dip, fnt, xui.Color_Yellow, "LEFT")
    cvs.DrawText("Height: " & mainPnl.Height,20dip, 64dip, fnt, xui.Color_Yellow, "LEFT")
    cvs.Invalidate
End Sub
Sub ShowBorders
'    Clear
    Dim rect As B4XRect
    rect.Initialize(1, 1, 1+cvs.TargetRect.Width-2, 1+cvs.TargetRect.Height-2)
'    cvs.DrawRect(rect, xui.Color_Black,False,2)
    cvs.DrawRect(rect, xui.Color_Red,False,2)
    cvs.Invalidate
End SubAttachments
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
	
								
							
							 
				 
 
		 
			 
			 
 
		 
 
		 
 
		 
 
		