关于窗体放大时SSTab控件显示不全的问题
关于窗体放大时SSTab控件显示不全的问题 高手们,你们好!我在窗体中使用了SSTab控件,设置了5个选项卡。我又添加了让VB自动改变控件大小的代码,运行程序的时候放大窗体,只有一个选项卡上的控件的可以正常显示,其他的的选项卡里什么都没有了,请问这种问题如何解决?谢谢! --------------------编程问答-------------------- 代码帖出来看下。 --------------------编程问答-------------------- Option Explicit
Private ObjOldWidth As Long '保存窗体的原始宽度
Private ObjOldHeight As Long '保存窗体的原始高度
Private ObjOldFont As Single '保存窗体的原始字体比
'在调用ResizeForm前先调用本函数
Public Sub ResizeInit(FormName As Form)
Dim Obj As Control
ObjOldWidth = FormName.ScaleWidth
ObjOldHeight = FormName.ScaleHeight
ObjOldFont = FormName.Font.Size / ObjOldHeight
On Error Resume Next
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
On Error GoTo 0
End Sub
'按比例改变表单内各元件的大小,
'在调用ReSizeForm前先调用ReSizeInit函数
Public Sub ResizeForm(FormName As Form)
Dim Pos(4) As Double
Dim I As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double
ScaleX = FormName.ScaleWidth / ObjOldWidth
'保存窗体宽度缩放比例
ScaleY = FormName.ScaleHeight / ObjOldHeight
'保存窗体高度缩放比例
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For I = 0 To 4
'读取控件的原始位置与大小
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(I) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(I) = 0
End If
'根据控件的原始位置及窗体改变大
'小的比例对控件重新定位与改变大小
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Obj.Font.Size = ObjOldFont * FormName.ScaleHeight
Next I
Next Obj
On Error GoTo 0
End Sub
Private Sub Form_Resize()
'确保窗体改变时控件随之改变
Call ResizeForm(Me)
End Sub
Private Sub Form_Load()
Move (Screen.Width - Form2.Width) / 2, (Screen.Height - Form2.Height) / 2
Call ResizeInit(Me)
End Sub
Private Sub Option1_Click()
SSTab1.TabEnabled(4) = False
Text97.Enabled = False
Text98.Enabled = False
Text99.Enabled = False
End Sub
Private Sub Option2_Click()
SSTab1.TabEnabled(4) = True
Text97.Enabled = True
Text98.Enabled = True
Text99.Enabled = True
End Sub
Private Sub Command3_Click()
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
Text4.Text = 0
Text5.Text = 0
Text6.Text = 0 '清零
End Sub
Private Sub Command4_Click()
Text7.Text = 0
Text8.Text = 0
Text9.Text = 0
Text10.Text = 0
Text11.Text = 0
Text12.Text = 0 '清零
End Sub
Private Sub Command8_Click()
Form2.Hide
Form3.Show
End Sub
Private Sub Command9_Click()
End
End Sub
Private Sub Command7_Click()
Dim textobj As Control
For Each textobj In Controls
If TypeOf textobj Is TextBox Then
textobj.Text = ""
End If
Next
End Sub '清零文本框
--------------------编程问答-------------------- 多帮忙帮忙啊 --------------------编程问答-------------------- 这个控件是有问题,建议用别的控件代替 --------------------编程问答-------------------- 我上面写了不少控件,非得换? --------------------编程问答-------------------- 求助阿 --------------------编程问答-------------------- 据传SSTab是有此BUG,你把SSTAB里的东西弄进Frame里,再用TabStrip代替吧。
补充:VB , 控件