Results 1 to 8 of 8

Thread: Please help! How to handle form events when window is resized?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Question Please help! How to handle form events when window is resized?

    I'm new to VB 6.0. I really don't know what is the easiest way to handle events, when window is resized by user. Please help.
    Here is full form's text from VB, I want to execute
    Public Sub formResize()
    every time vhen window is resized

    thanks


    Option Explicit

    Const BORDER = 120 'Bulgarian constant
    Const MIN_WINDOW_SIZE = 4200 'too

    Private Sub Form_Load()
    Resize
    rtbStatusList.Text = "30.11.2005 15:24:11 Papiermangel" + vbCr + "30.11.2005 16:55:00 Papierende" + vbCr + "30.11.2005 20:12:11 Keine Verbindung"
    rtbStatusList.Text = rtbStatusList.Text + rtbStatusList.Text
    rtbStatusList.Text = rtbStatusList.Text + rtbStatusList.Text
    End Sub

    Private Sub Resize()
    On Error Resume Next
    End Sub

    Public Sub formResize()
    Dim w As Integer
    Dim h As Integer

    w = ScaleWidth
    h = ScaleHeight
    If (w < MIN_WINDOW_SIZE) Then
    w = MIN_WINDOW_SIZE
    End If
    If (h < MIN_WINDOW_SIZE) Then
    h = MIN_WINDOW_SIZE
    End If
    fraCardInfo.Width = w - picCreditCard.Width - BORDER * 3
    fraButtons.Width = w - picCreditCard.Width - BORDER * 3
    picCreditCard.Left = w - picCreditCard.Width - BORDER
    rtbStatusList.Width = w - BORDER * 2
    rtbStatusList.Height = h - rtbStatusList.Top - BORDER
    End Sub

  2. #2
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Please help! How to handle form events when window is resized?

    Isn't there a Form_Resize event in the events combo for your form ¿
    VB.NET MVP 2008 - Present

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Re: Please help! How to handle form events when window is resized?

    Where could I find it? I have components on left side and project and properties on the right side of program, but I can't find combo box with events

  4. #4
    Lively Member
    Join Date
    Aug 2005
    Posts
    126

    Re: Please help! How to handle form events when window is resized?

    VB Code:
    1. Private Sub Form_Resize()
    2. Dim w As Integer
    3. Dim h As Integer
    4.  
    5. w = ScaleWidth
    6. h = ScaleHeight
    7. If (w < MIN_WINDOW_SIZE) Then
    8. w = MIN_WINDOW_SIZE
    9. End If
    10. If (h < MIN_WINDOW_SIZE) Then
    11. h = MIN_WINDOW_SIZE
    12. End If
    13. fraCardInfo.Width = w - picCreditCard.Width - BORDER * 3
    14. fraButtons.Width = w - picCreditCard.Width - BORDER * 3
    15. picCreditCard.Left = w - picCreditCard.Width - BORDER
    16. rtbStatusList.Width = w - BORDER * 2
    17. rtbStatusList.Height = h - rtbStatusList.Top - BORDER
    18. End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Re: Please help! How to handle form events when window is resized?

    Thanks a lot, it works good now.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Please help! How to handle form events when window is resized?

    The proper way

    Not that using the _Resize event doesn't work, it's just a lot less efficient and you get flickering when you try to make the window too small or too large.

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Re: Please help! How to handle form events when window is resized?

    Using _Resize with limits is really better option, thanks

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Please help! How to handle form events when window is resized?

    And I'm telling you it isn't the better option, but do as you wish.

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