question

JeanLucCoudret-9280 avatar image
0 Votes"
JeanLucCoudret-9280 asked JeanLucCoudret-9280 commented

OnResize method not fully working in VB.net

Hi,

I am trying to resize a frame (via a class who inherit PictureBox) in aPictureBox containig an Image, but I have few issues with the method OnResize.
1- I can move this frame (red rectangle) via OnMove method (no problem)
2- I can resize this frame only with the corner bottom-right, which keep the ratio of the frame to 1.5 (landscape) or 0.66 (Portrait)
3- When I am resizing the frame, the resizing action should stop when it touch the right or bottom side, but it is working only partially.
4- To see the issue you have to move the red frame close to the right side or the bottom side and then try to increase the frame.

I tried various code options, but I can't find the solution.
Below is the code of the OnResize method, but to fully understand the problem, you can follow this link (Google Drive) which will give you a short version/application of what I am doing with the issue.

Any ideas are obviously welcome.

Thanks,
JLuc

 Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
         ' To redraw the whole image based on Glass window
         Try
             ' Minimum limits of Glass window
             If Me.Width < 40 Then Me.Width = CInt(40 * Form1.dRatioImageWH)
             If Me.Height < 40 Then Me.Height = CInt(40 / Form1.dRatioImageWH)
             ' Effect on Resize event
             If Me.Width > Form1.PictureBox1.Width - Me.Location.X Then Me.Width = Form1.PictureBox1.Width - Me.Location.X
             If Me.Height > Form1.PictureBox1.Height - Me.Location.Y Then Me.Height = Form1.PictureBox1.Height - Me.Location.Y
             If Form1.dRatioImageWH > 1 Then Me.Height = CInt(Me.Width / Form1.dRatioImageWH)
             If Form1.dRatioImageWH < 1 Then Me.Width = CInt(Me.Height * Form1.dRatioImageWH)
             ' Control to be redrawn
             Me.Invalidate()
             ' Raise the Resize event
             MyBase.OnResize(e)
         Catch ex As Exception
             MsgBox(ex.Message)
         End Try
     End Sub


dotnet-visual-basic
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JeanLucCoudret-9280 ,
Unfortunately, I cannot access the link (Google Drive) you shared. It reminds me that I need to apply for permission.
Try modifying its access so that others can download and test the project.
We are waiting for your update.

0 Votes 0 ·

Sorry for this link access. This one shouldn't have any restriction: LINK.

0 Votes 0 ·

You really should use GitHub rather than Google as GitHub also is source control. Also, those who are interested in helping can open your project easier with GitHub.

0 Votes 0 ·
Show more comments

0 Answers