1 ''' // **************************************
   2 ''' // User Form code
   3 ''' // **************************************
   4 
   5 ''' // Initialize the Resizer Class
   6 Dim moResizer As New CFormResizer
   7 
   8 ''' // Specify the minWidth + Height of this special UserForm
   9 ''' // This is used to assure the Dlg will never get smaller its minimum size - so never any controls will be cut off or distorted
  10 Const DLG_MIN_WIDTH As Double = 388
  11 Const DLG_MIN_HEIGHT As Double = 279
  12 
  13 
  14 ''' // Ctrl Click Events
  15 Private Sub TreeView1_Click()
  16 Dim List1 As Object
  17 Dim WS As Worksheet
  18 Dim c As Integer, lr As Long
  19 
  20         Set WS = ThisWorkbook.Worksheets("ResizeDemoCountryLists")
  21 
  22         lr = Tools.Get_Last_Row(WS)
  23         c = Me.TreeView1.SelectedItem.Index - 1
  24 
  25        Call ListView1_Set(WS, lr, c)
  26 End Sub
  27 
  28 Private Sub ListBox1_Change()
  29 Dim WS As Worksheet
  30 Dim lr As Long
  31 
  32         Set WS = ThisWorkbook.Worksheets("ResizeDemoCountryLists")
  33 
  34         lr = Tools.Get_Last_Row(WS)
  35 
  36         Call ListView2_Set(WS, lr)
  37 End Sub
  38 
  39 ''' // Close
  40 Private Sub CommandButton1_Click()
  41     Unload Me
  42 End Sub
  43 
  44 
  45 ''' // ****************************************************************************************
  46 ''' // Resize
  47 Private Sub UserForm_Activate()
  48     Set moResizer.Form = Me
  49 End Sub
  50 
  51 ''' // Resize UserForm, hand over the minWidth and minHeight
  52 Private Sub UserForm_Resize()
  53     moResizer.FormResize DLG_MIN_WIDTH, DLG_MIN_HEIGHT
  54 End Sub
  55 
  56 ''' // Resize Icon at lower right hand side of UserForm was doubleclicked - (nearly) maximize UserForm or bring back to min Width + Height
  57 Private Sub Image2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
  58     If Me.Width = Tools.BlowDlg_MaxWidth Then
  59         Me.Width = DLG_MIN_WIDTH
  60         Me.Height = DLG_MIN_HEIGHT
  61         ''' // Position UserForm at center of application window (plus a little bit to top ...)
  62         Me.Top = Application.Top + (Application.Height / 2 - DLG_MIN_HEIGHT / 2) - (Application.Height * 0.1)
  63         Me.Left = Application.Left + (Application.Width / 2 - DLG_MIN_WIDTH / 2)
  64     Else
  65         Call Tools.BlowDlg_FullSize(Me)
  66     End If
  67 End Sub
  68 
  69 ''' // ****************************************************************************************
  70 
  71 
  72