|
▼いのっち さん:
>
>※追加質問ですみませんが、今、UserForm1が固定の大きさ(プロパティのHeight200,Width500位)なのですが、UserForm1が表示された時、ユーザーが自由に大きさを変えられるようにすることは可能でしょうか?(SpreadSheetの方の兼ね合いもあるかもしれませんネ)。
フォームのサイズ変更とSpreadsheetの位置も自由に動かせるものです。
上記が出来るからSpreadsheetのサイズ変更も可にしてもOKかな?
strClassの値ですがSpreadsheetのバージョンで違うので注意して下さい。
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_CAPTION = &HC00000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Const WS_THICKFRAME = &H40000
Private Const WS_OVERLAPPED = &H0
Private Const WS_OVERLAPPEDWINDOW = _
(WS_OVERLAPPED Or _
WS_CAPTION Or _
WS_SYSMENU Or _
WS_THICKFRAME Or _
WS_MINIMIZEBOX Or _
WS_MAXIMIZEBOX)
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_OVERLAPPEDWINDOW
'Spredsheetの移動可
strSClass = "F3 Server 60000000"
mhWnd = FindWindowEx(fhWnd, 0&, strClass, vbNullString)
If mhWnd = 0 Then Exit Sub
strClass = "ATL:38CAE248" ' Spreadsheet 10 の時
strClass = "ATL:10EDB528" ' Spreadsheet 11 の時
shWnd = FindWindowEx(mhWnd, 0&, strClass, vbNullString)
If shWnd = 0 Then Exit Sub
SetWindowLong shWnd, GWL_STYLE, _
GetWindowLong(shWnd, GWL_STYLE) Or WS_CAPTION
'Spredsheetのサイズ変更不可
' Me.Spreadsheet1.AutoFit = True
End Sub
|
|