PDA

Click to See Complete Forum and Search --> : Resizing code...


Inhumanoid
Nov 30th, 1999, 07:49 PM
What's some good code that makes a form resizable in width but not in height ???

I don't like code like:

If Form1.Height > 3255 Then Form1.Height = 3255
If Form1.Height < 3255 Then Form1.Height = 3255


Cause that hasn't got a neet result. In this example the form can't be bigger or smaller than 3255. While you resize it looks like you can...

funkheads
Nov 30th, 1999, 08:07 PM
maybe you need to put this tidbit of code into a timer so that it checks the size every 10 ms and resizes it back to the "unsizable" size if it is bigger or smaller. get it? i hope i mad sense there.

--michael

Inhumanoid
Nov 30th, 1999, 08:13 PM
You make sense...

However this is not what we want...

It results the same as putting the code in the resize or paint event of the form....

The problem is that is IS possible to go under or above 3255 (it just gets resized to 3255 again)...

There should be a way so that a form can be resized in width but can't be resized in height...

An example of a form like this is the MS find files or folders dialog (winkey+f)

Inhumanoid
Nov 30th, 1999, 08:24 PM
Well Mark,

Your code is shorter.... However the result is the same .... You can still size it above or under 3255 and it jumps back again....

Wich is not what we want...

Mark Sreeves
Nov 30th, 1999, 08:28 PM
Yeah I know what you mean. I deleted my posting because it reset height wether it needed it or not.



------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

Serge
Nov 30th, 1999, 08:36 PM
Take alook at this Example (http://www.mvps.org/vbnet/code/subclass/minmaxinfo.htm)

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)


[This message has been edited by Serge (edited 12-01-1999).]

funkheads
Nov 30th, 1999, 08:45 PM
mark -

that definitely works, but now we need a way to kill the mouse if the user attempted to resize the form height. only because the code you used, mark, leaves us with a nasty flashing outline if we keep the mouse down. BUT even better would be able to somehow write a code that would disable the mouse if it were over the bottom border of the form. but who knows. and thanks a lot inhumanoid...you have me really curious about how to do this now.

--michael

ps - is it poossible to disable the mouse in VB? just curious.

Inhumanoid
Nov 30th, 1999, 08:52 PM
Hehe Your welcome...

However I am not sure if we should kill the mouse... If we go over or under the form's height with are cursor,the mouse should not be killed because we would still want the form's width to be handled..

Notice how the API-viewer made a similar mistake..
Try resizing the api-viewer to a smaller size than it's original width and/or height...

Nasty... Ain't it

[This message has been edited by Inhumanoid (edited 12-01-1999).]

Aaron Young
Nov 30th, 1999, 08:53 PM
If you don't want to resort to Subclassing the Form(s), you could use a Fixed Single Border and Manually allow Resizing of the Forms Width.

Something like this maybe..

Private bDragging As Boolean
Private oX As Single

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton And (X > (ScaleWidth - 50) And X < Width) Then
bDragging = True
oX = X
MousePointer = vbSizeWE
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton And bDragging And X > 0 Then
Width = (Width - ScaleWidth) + oX + (X - oX)
oX = X
Else
MousePointer = IIf(X > (ScaleWidth - 50) And X < Width, vbSizeWE, vbNormal)
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
bDragging = False
MousePointer = vbNormal
End If
End Sub

This only allows Sizing from the Right Side of the Form, but I'm sure you could modify it to allow Sizing from the Left if it's absolutely neccessary.

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net


[This message has been edited by Aaron Young (edited 12-01-1999).]