Results 1 to 12 of 12

Thread: Shrink wrap form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    Funny name huh?

    Anyway, I know there is a method of resizing a control (such as a text box) to the client size of a form. I need to resize the form so it's client size is the size of a control.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    Me.Width = Control.Width
    Me.Height = Control.Height
    Is that what you were looking for?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    you mean like this?

    Code:
    Private Sub Form_Resize()
        On Error Resume Next
    
        Text1.Left = 0
        Text1.Top = 0
        Text1.Width = Me.Width
        Text1.Height = Me.Height
    End Sub

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    neither of those would work. the first would make the outside of the form the same size as the form. need to set just the client area.

    the second resizes the control. I need to resize the form.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    If you have listbox and you wanted the form to be the size of the listbox then the first method would do that.
    ie.

    Form1.Widht = List1.Width
    Form1.Height = List1.Height
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Guest
    so you need to do this???


    Code:
    Private Sub Form_Load()
        Me.Width = Control.Width
        Me.Height = Control.Height
    End Sub
    ??

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    this is what happens when i use that code. screenshot at http://agent_153.tripod.com/problem.gif

    i need the form to fit around the control, without resizing the control, but resizing the form

  8. #8
    Guest
    Code:
    Private Sub Form_Load()
        Me.Width = Control.Width + 5
        Me.Height = Control.Height + 5
    End Sub
    you may have to change the numbers a little.

  9. #9
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    this should work...alows you to move the textbox to a
    positon where the form can size itself around it and
    then put your form back to it's original state.

    'This will resize it to the size of the textbox
    'and wrap around it...then you can double click
    'the textbox to reset your form to it's origial stature


    Code:
    Option Explicit
    
    Public tl As Integer, tt As Integer
    Public fh As Integer, fw As Integer
    '
    'command button call cmdShrink
    
    Private Sub cmdShrink_Click()
         tt = Text1.Top
         tl = Text1.Left
         fh = Form1.Height
         fw = Form1.Width
         
         Form1.Height = Text1.Height + 380
         Form1.Width = Text1.Width + 80
         Text1.Top = 0
         Text1.Left = 0
    End Sub
    
    
    Private Sub Text1_DblClick()
        Text1.Left = tl
       Text1.Top = tt
       Form1.Height = fh
       Form1.Width = fw
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    that's the problem. i need to figure out how much to offset the size of the form by. I don't want to hardwire the numbers like above, incase the user has weird windows desktop settings.

    I think i can fgure the size of the border by comparing scalewdthi to width (same with height)

    I'll post back if it doesn't work

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Look under: HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics for the sizes
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    OK, i figured it out:
    Code:
    Private Sub Form_Load()
        Dim bw&
        Dim bh&
        
        With Text1
            bw = Width - ScaleWidth
            bh = Height - ScaleHeight
            
            Me.Width = .Width + bw
            Me.Height = .Height + bh
            
            .Top = 0
            .Left = 0
        End With
    End Sub
    -----

    scaleheight/scalewidth return the client size (changing them sets the user scalemode) while width/height return the outer rectangle of the form.

    [Edited by agent on 08-21-2000 at 08:03 PM]

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