投稿日 | : 2005/01/07(Fri) 09:58 |
投稿者 | : 魔界の仮面弁士 |
Eメール | : |
URL | : |
タイトル | : Re: フォームの上にフォームを乗せる |
> Form1の上にForm2を乗せて合体させてしまいたいのですが、
> 良い方法はあるでしょうか?
VB6の場合は、SetParent APIを使う方法ぐらいかな…。
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private WithEvents ChildForm As Form
Private Sub Dispose()
If Not ChildForm Is Nothing Then
Unload ChildForm
Set ChildForm = Nothing
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dispose
End Sub
Private Sub Command1_Click()
Dispose
Set ChildForm = New Form2
ChildForm.Caption = Format(Time(), "Long Time")
ChildForm.Move 0, 0, 1440, 1440
SetParent ChildForm.hWnd, Me.hWnd
ChildForm.Visible = True
End Sub
> でもForm2はForm1上で移動できる必要は無く、
> 固定しておきたいのです。
と言うことは、Form2はサイズ変更もしないのですよね。
見た目だけの問題なら、PictureBoxをFormに見立てて使ってみては如何でしょう。