Results 1 to 9 of 9

Thread: Resizing code...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    What's some good code that makes a form resizable in width but not in height ???

    I don't like code like:
    Code:
    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...

  2. #2
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    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)


  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    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...

  5. #5
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    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

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Take alook at this Example

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

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819


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

  7. #7
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    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.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    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).]

  9. #9
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    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..
    Code:
    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).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width