|
こーいうことがしたいのかな・・?
[標準モジュール]
Declare Function SetActiveWindow Lib "user32" (ByVal hWnd&) As Long
Public hWnd As Long, ApSet As Long
Sub Fom_Shw()
If MsgBox("ユーザーフォームを常に手前にセットしますか" & _
vbLf & "「いいえ」なら設定を解除します", 36) = 6 Then
ApSet = -1
UserForm1.Show
Else
ApSet = -2
UserForm1.Show False
End If
End Sub
Sub Act_Fom() 'ユーザーフォームをアクティブにする
SetActiveWindow hWnd
End Sub
[フォームモジュール]
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Sub UserForm_Activate()
Dim Ret As Long, hWnd As Long
hWnd = FindWindow("ThunderDFrame", Me.Caption)
Ret = SetWindowPos(hWnd, ApSet, 0, 0, 0, 0, &H40 Or &H1 Or &H2)
End Sub
|
|