非常怪的scalemode的问题求教.
非常怪的scalemode的问题求教. 我想在窗体的resize事件中控制组合框的长度,用到api函数,可是为什么使用movewindow函数,scalemode必须设置成像素才行呢?如果设成缇的话,根本组合框就无法显示出来,真是怪了.请大家指教,代码如下:
Option Explicit
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Sub Command1_Click()
MsgBox ScaleMode
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 50: Combo1.AddItem Format$(i): Next i
End Sub
Private Sub Form_Resize()
Dim combo_height As Integer
Dim form_mode As Integer
form_mode = ScaleMode
ScaleMode = vbPixels '使用这一句正常
'ScaleMode = vbTwips '使用这一句则无法显示出组合框,而且每运行一次resize事件,组合框的 left ,top属性都会变化
combo_height = ScaleHeight - Combo1.Top - 5
If MoveWindow(Combo1.hwnd, Combo1.Left, Combo1.Top, Combo1.Width, combo_height, 1) = 0 Then
MsgBox "err"
Else
MsgBox Combo1.Left & "----" & Combo1.Top
End If
ScaleMode = form_mode '恢复原来的
End Sub