I’m trying to reize a PictureBox and going around in circles and not getting very far.
I’m designing the app for portait only, so the width (set at 80% in the IDE) will need to be the same for the height which I obviously need to change at runtime for different screen sizes.
From the documentation I’ve found and placed this code in my form, but it refuses to play ball… Any help?
Function frmSubmitScores_onshow()
Dim actualHeight = PictureBox1.getBoundingClientRect().height
Dim actualWidth = PictureBox1.getBoundingClientRect().width
PictureBox1["height"] = actualWidth
PictureBox1["width"] = actualWidth
End Function
I’m sure I tried that with no luck, I have just retried it and still not playing ball.
I had a thought that it was not firing because I also needed it in the On_Resize function too since I’m running in browser and then trying different phone sizes, so I now have in both OnLoad and OnResize:
Function Form1_onresize()
Dim actualHeight = picScore.getBoundingClientRect().height
Dim actualWidth = picScore.getBoundingClientRect().width
' actualWidth = picScore.width
picScore.height = actualWidth
picScore.width = actualWidth
MsgBox (actualWidth)
End Function
If I run this and resize, I get a message box with nothing printed in it - actualWidth has no value, (is Null?). When I uncomment line 3 in the Function I get a result of 0.
Interestingly, when I type picScore. I do not see “height” in the autofill dropdown lists, almost like there is no such property.
Running latest version of NS Basic, Windows 64x, Chrome. I’m using the Bootstrap 4 Camera if that makes any difference.
So after these changes, I see no picture after choosing one, it’s obviusly resizing the PictureBox to 0,0
thanks @silvercoder - I’ll have a go at this later today (being 2am now). Have you tried this code on a phone or just in a browser? My gut feeling is that the resize event won’t be called on a phone because it’s not actually getting resized?
Actually, I put the code in a function called in the onshow and resize events. Works on phone and desktop. Relating the size to the dimensions of a form (or, maybe, a container) is the only way I ever found of doing this.