|
こんにちは。
APIで出来るんですねえ!!
ならば、
Userform1のモジュールを以下のように変更すれば、
'====================================
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Sub SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long)
Private Const GWL_STYLE As Long = -16
Private Const WS_THICKFRAME = &H40000
Private s_w As Double
Private s_h As Double
Private spd As Object
'============================
Private Sub UserForm_Initialize()
Dim strMClass As String
Dim strSClass As String
Dim strClass As String
Dim fhWnd As Long
Dim mhWnd As Long
Dim shWnd As Long
strMClass = "ThunderDFrame"
fhWnd = FindWindow(strMClass, Me.Caption)
' フォームのサイズ変更可
SetWindowLong fhWnd, GWL_STYLE, _
GetWindowLong(fhWnd, GWL_STYLE) Or WS_THICKFRAME
With Me
.Width = 425
.Height = 350
s_w = .Width
s_h = .Height
End With
Set spd = Controls.Add("OWC.Spreadsheet.9", , True)
With spd
.Left = 0
.Top = 0
.Width = 200
.Height = 150
.AutoFit = True
End With
End Sub
'==========================================================
Private Sub UserForm_Resize()
If Not spd Is Nothing Then
spd.Width = spd.Width * Me.Width / s_w
spd.Height = spd.Height * Me.Height / s_h
End If
End Sub
ユーザーフォームのサイズ変更がスプレッドシートに反映されますね!!
|
|