In Erel'sB4X] B4XPages + B4XDrawer tutorial, the sample code does not completely set the "Random Background" color when the form is resized using the mouse. I have tried various code modifications in B4J but to no avail. How could I do it Erel or anyone? Thanks.
I got what you mean.
You just need to set the color of panel1. In B4XPage3
B4X:
Sub B4XPage_MenuClick (Tag As String)
Dim rc As Int= Rnd(xui.Color_Black, xui.Color_White)
If Tag = "Random Background" Then
Panel1.Color=rc
cvs.DrawRect(cvs.TargetRect,rc, True, 0)
cvs.Invalidate
End If
End Sub
In B4XPage2
B4X:
Private Sub B4XPage_Resize (Width As Int, Height As Int)
If Page3.Panel1.IsInitialized Then
ImageView1.Parent.Color = Page3.Panel1.Color
Drawer.Resize(Width, Height)
End If
End Sub
Sub UpdateImage
If Page3.Panel1.IsInitialized Then
ImageView1.Parent.Color = Page3.Panel1.Color
ImageView1.SetBitmap(Page3.cvs.CreateBitmap)
End If
End Sub
Yes, and after my Page2 form background color "was copied" from Page 3, but it does not resize as I resize page 2. I get the White Edges around the random color. So seems like I get the same result as you.
Yes, and after my Page2 form background color "was copied" from Page 3, but it does not resize as I resize page 2. I get the White Edges around the random color. So seems like I get the same result as you.
Second, the issue is whether you have resized Page 3, after you closed it and you open it again, the window size is back to original size which is 600 X 600.
Third, Page 2 is using an ImageView to load the "saved" image "converted" from Page 3's Canvas.
Thanks aeric, upon setting the canvas color randomly in Page3
B4X:
Sub B4XPage_MenuClick (Tag As String)
If Tag = "Random Background" Then
cvs.DrawRect(cvs.TargetRect, Rnd(xui.Color_Black, xui.Color_White), True, 0)
cvs.Invalidate
End If
End Sub
I intend to use that color as Page2 background color such that any Page2 form size would have that color.