投稿日 | : 2005/06/06(Mon) 15:23 |
投稿者 | : 魔界の仮面弁士 |
Eメール | : |
URL | : |
タイトル | : Re: 【再質問】コントロールオブジェクトの保存・リストア |
> というわけでSetPropを利用してコントロールオブジェクトの保存・リストアを
> 試みているのですが、オブジェクト変数の扱いに苦慮しています。
こういう事でよいのかな。
Option Explicit
Private Declare Function SetProp Lib "user32" Alias "SetPropA" (ByVal hWnd As Long, ByVal lpString As String, ByVal hData As Object) As Long
Private Declare Function GetProp Lib "user32" Alias "GetPropA" (ByVal hWnd As Long, ByVal lpString As String) As Object
Private Declare Function RemoveProp Lib "user32" Alias "RemovePropA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Sub Form_Load()
SetProp Me.hWnd, "Orator", Me.Text1
End Sub
Private Sub Command1_Click()
Dim C As VB.Control
Set C = GetProp(Me.hWnd, "Orator")
If C Is Nothing Then
MsgBox "取得失敗", vbExclamation
Else
MsgBox "Name=" & C.Name & vbCrLf & "Text=" & C.Text, vbInformation
Set C = Nothing
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
RemoveProp Me.hWnd, "Orator"
End Sub