Réponse acceptée !
Bonjour.
J'ai ça en magasin !
ctac
Cet exemple affiche une boite de message dont les paramètres sont stockés dans les propriétés de la fenêtre principale de l'application.
Private Declare Function SetProp& _
Lib "user32" Alias "SetPropA" _
(ByVal Hwnd&, ByVal lpString$, ByVal hData&)
Private Declare Function LocalFree& _
Lib "kernel32" _
(ByVal hMem&)
Private Declare Function LocalAlloc& _
Lib "kernel32" _
(ByVal wFlags&, ByVal wBytes&)
Private Declare Function GetActiveWindow& _
Lib "user32" _
()
Private Declare Function GetProp& _
Lib "user32" Alias "GetPropA" _
(ByVal Hwnd&, ByVal lpString$)
Private Declare Function RemoveProp& _
Lib "user32" Alias "RemovePropA" _
(ByVal Hwnd&, ByVal lpString$)
Private Declare Function lstrlen& _
Lib "kernel32" Alias "lstrlenA" _
(ByVal lpString As Any)
Private Declare Function lstrcpy& _
Lib "kernel32" Alias "lstrcpyA" _
(ByVal lpString1 As Any, ByVal lpString2 As Any)
Sub Demo_SetProp()
Const LMEM_FIXED& = &H0, LMEM_ZEROINIT& = &H40
Dim Hwnd&, MemA&, MemB&, Texte$
Texte = "Utilisation de SetProp" & Chr$(0&)
MemA = LocalAlloc(LMEM_FIXED Or LMEM_ZEROINIT, Len(Texte))
lstrcpy MemA, ByVal Texte
Texte = "Divers paramètres passés par l'intermédiaire de SetProp." & Chr$(0&)
MemB = LocalAlloc(LMEM_FIXED Or LMEM_ZEROINIT, Len(Texte))
lstrcpy MemB, ByVal Texte
Hwnd = GetActiveWindow
SetProp Hwnd, "PropA", MemA
SetProp Hwnd, "PropB", MemB
SetProp Hwnd, "PropC", vbInformation
Affich Hwnd
LocalFree MemA
LocalFree MemB
RemoveProp Hwnd, "PropA"
RemoveProp Hwnd, "PropB"
RemoveProp Hwnd, "PropC"
End Sub
Private Function Affich&(Hwnd&)
Dim Msg$, Titre$
Affich = GetProp(Hwnd, "PropB")
Msg = Space$(lstrlen(Affich))
lstrcpy Msg, Affich
Affich = GetProp(Hwnd, "PropA")
Titre = Space$(lstrlen(Affich))
lstrcpy Titre, Affich
Affich = MsgBox(Msg, GetProp(Hwnd, "PropC"), Titre)
End Function