[RESOLVED] Setting Form Size to Anything Smaller Than 132 x 38
How do we set a form size smaller than 132 x 38 pixels?
I would prefer any native vb.net way (if possible) over use of any windows API.
Re: Setting Form Size to Anything Smaller Than 132 x 38
try removing the titlebar
edit: + the controlbox + set borderstyle to none
Re: Setting Form Size to Anything Smaller Than 132 x 38
There is no Title Bar. But I'm not able to set the size smaller than this. When I do, it simply ignores it and resizes to this value. It looks like this is the minimum size we can set. Or I think I'm missing something.
Re: Setting Form Size to Anything Smaller Than 132 x 38
Re: Setting Form Size to Anything Smaller Than 132 x 38
OK.. I think I got it. Setting the FormBorderStyle to None does it. But I need the borders (Fixed Single). So?
Re: Setting Form Size to Anything Smaller Than 132 x 38
Have you set the BorderStyle to none?
Edit: Damn!!! I need to refresh before posting :lol: Sorry was testing it...
Re: Setting Form Size to Anything Smaller Than 132 x 38
Why do you need the form smaller then that? There might be an easier work around.
Re: Setting Form Size to Anything Smaller Than 132 x 38
Set control box to false and text to blank
I placed a small button top left of the form with this code I was using the toolwindow border style but it should work with other styles as well.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.Width > 200 Then
Me.Width = 50
Me.Height = 15
Else
Me.Width = 520
Me.Height = 225
End If
End Sub
Re: Setting Form Size to Anything Smaller Than 132 x 38
vb Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = ""
Me.ControlBox = False
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim r As Rectangle = Me.ClientRectangle
r.Height -= 1
ControlPaint.DrawBorder(e.Graphics, r, Color.Black, ButtonBorderStyle.Solid)
End Sub
End Class
Re: Setting Form Size to Anything Smaller Than 132 x 38
I did a few more tests and the code I posted above does not work with the fixed single border style but does work fine with the FixedToolWindow style
Re: Setting Form Size to Anything Smaller Than 132 x 38
Setting it to FixedToolWindow gives me the effect I was looking for. :)
I really didn't want to mess around with the Paint event, since the form is doing a few weird things and would start having refresh issues.