Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour,
Quelqu'un peut-il comprendre ce qui ne va pas dans mon code ?
J'ai essayé de me servir d'une fonction API (AnimateWindow), mais cela ne
marche pas .
J'ai créé un module dans lequel j'ai mis :
Option Explicit
Private Declare Function AnimateWindow Lib « user32 » ( _
ByVal hwnd As Long, _
ByVal dwTime As Long, _
ByVal dwFlags As Long) As Long
J'ai créé également un UserForm dans lequel j'ai mis
Private Sub UserForm_Activate()
Debug.Print AnimateWindow(Me.hwnd, 10000, &H10 Or &H20000)
End Sub
J'ai essayé de remplacer le Me par UserForm, mais cela ne change rien.
J'ai démarré le programme à partir du UserForm. Le UserForm s'affiche,
mais
sa taille n'est pas
modifiée, alors qu'elle serait censée l'être avec le code de l'API.
D'avance merci,
Jean-michel
Bonjour Michel.
Je n'arrive à faire fonctionner aucune de tes propositions.
Le UserForm apparait puis disparait.
Ceci semble fonctionner
Dans le module du UserForm
'Anime la fenêtre de gauche à droite.
Const AW_HOR_POSITIVE = &H1
'Anime la fenêtre de droite à gauche.
Const AW_HOR_NEGATIVE = &H2
'Anime la fenêtre du haut vers le bas.
Const AW_VER_POSITIVE = &H4
'Anime la fenêtre du bas vers le haut.
Const AW_VER_NEGATIVE = &H8
'Réduction vers son centre avec AW_HIDE et inversement avec AW_ACTIVATE.
Const AW_CENTER = &H10
'Cache la fenêtre.
Const AW_HIDE = &H10000
'Active la fenêtre.
Const AW_ACTIVATE = &H20000 'Active la fenêtre.
'Effet de "fondu" (si elle est au premier plan).
Const AW_BLEND = &H80000
'Fait "rouler" la fenêtre.
Const AW_SLIDE = &H40000
Private Declare Function AnimateWindow& Lib "user32" _
(ByVal hwnd&, ByVal dwTime&, ByVal dwFlags&)
Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function GetWindowLong& Lib "user32" Alias
"GetWindowLongA" _
(ByVal hwnd&, ByVal nIndex&)
Private Declare Function SetWindowLong& Lib "user32" Alias
"SetWindowLongA" _
(ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Declare Function CallWindowProc& Lib "user32" Alias
"CallWindowProcA" _
(ByVal lpPrevWndFunc&, ByVal hwnd&, ByVal Msg&, ByVal wParam&, ByVal
lParam&)
Private Declare Function ShowWindow& Lib "user32" _
(ByVal hwnd&, ByVal nCmdShow&)
Private BaseWinProc&
Private Sub UserForm_Initialize()
Const GWL_WNDPROC& = -4&
Dim HandleUF&
HandleUF = FindWindow(vbNullString, Me.Caption)
BaseWinProc = GetWindowLong(HandleUF, GWL_WNDPROC)
#If vba6 Then
SetWindowLong HandleUF, GWL_WNDPROC, AddressOf RelaisWinProc
#Else
SetWindowLong HandleUF, GWL_WNDPROC, AddrOf("RelaisWinProc")
#End If
End Sub
Public Function WinProc&(ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal
lParam&)
Const WM_ACTIVATE& = &H6, GWL_WNDPROC& = -4&
If uMsg = WM_ACTIVATE Then
ShowWindow hwnd, 0&
AnimateWindow hwnd, 400&, AW_VER_POSITIVE Or AW_HOR_POSITIVE Or
AW_ACTIVATE
SetWindowLong hwnd, GWL_WNDPROC, BaseWinProc
AppActivate Me.Caption
WinProc = 1&
Exit Function
End If
WinProc = CallWindowProc(BaseWinProc, hwnd, uMsg, wParam, lParam)
End Function
Dans un module standard
Private Declare Function GetCurrentVbaProject& Lib "vba332" _
Alias "EbGetExecutingProj" (hProject&)
Private Declare Function GetFuncID& Lib "vba332" _
Alias "TipGetFunctionId" (ByVal hProject&, _
ByVal strFunctionName$, ByRef strFunctionID$)
Private Declare Function GetAddr& Lib "vba332" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject&, _
ByVal strFunctionID$, ByRef lpfnAddressOf&)
#If vba6 Then
#Else
Public Function AddrOf&(CallbackFunctionName$)
'AddressOf operator replacement for Office97 VBA
'Authors: Ken Getz and Michael Kaplan
'declaration of local variables
Dim aResult&, CurrentVBProject&, strFunctionID$
Dim AddressOfFunction&, UnicodeFunctionName$
'if the current VBProjects exists...
If GetCurrentVbaProject(CurrentVBProject) = 0 Then Exit Function
'convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'get the function ID of the callback function, based on its
unicode-converted name, _
in order to ensure that it exists
If GetFuncID(CurrentVBProject, UnicodeFunctionName, strFunctionID) = 0
Then
'if the function exists indeed ...
'get a pointer to the callback function based on the strFunctionID
argument _
of the GetFuncID function
If GetAddr(CurrentVBProject, strFunctionID, AddressOfFunction) = 0
Then _
AddrOf = AddressOfFunction
'if we've got the pointer pass it to the result of the function
End If
End Function
#End If
Function RelaisWinProc&(ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal
lParam&)
RelaisWinProc = UserForm1.WinProc(hwnd, uMsg, wParam, lParam)
End Function
Alain CROS
Bonjour Michel.
Je n'arrive à faire fonctionner aucune de tes propositions.
Le UserForm apparait puis disparait.
Ceci semble fonctionner
Dans le module du UserForm
'Anime la fenêtre de gauche à droite.
Const AW_HOR_POSITIVE = &H1
'Anime la fenêtre de droite à gauche.
Const AW_HOR_NEGATIVE = &H2
'Anime la fenêtre du haut vers le bas.
Const AW_VER_POSITIVE = &H4
'Anime la fenêtre du bas vers le haut.
Const AW_VER_NEGATIVE = &H8
'Réduction vers son centre avec AW_HIDE et inversement avec AW_ACTIVATE.
Const AW_CENTER = &H10
'Cache la fenêtre.
Const AW_HIDE = &H10000
'Active la fenêtre.
Const AW_ACTIVATE = &H20000 'Active la fenêtre.
'Effet de "fondu" (si elle est au premier plan).
Const AW_BLEND = &H80000
'Fait "rouler" la fenêtre.
Const AW_SLIDE = &H40000
Private Declare Function AnimateWindow& Lib "user32" _
(ByVal hwnd&, ByVal dwTime&, ByVal dwFlags&)
Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function GetWindowLong& Lib "user32" Alias
"GetWindowLongA" _
(ByVal hwnd&, ByVal nIndex&)
Private Declare Function SetWindowLong& Lib "user32" Alias
"SetWindowLongA" _
(ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Declare Function CallWindowProc& Lib "user32" Alias
"CallWindowProcA" _
(ByVal lpPrevWndFunc&, ByVal hwnd&, ByVal Msg&, ByVal wParam&, ByVal
lParam&)
Private Declare Function ShowWindow& Lib "user32" _
(ByVal hwnd&, ByVal nCmdShow&)
Private BaseWinProc&
Private Sub UserForm_Initialize()
Const GWL_WNDPROC& = -4&
Dim HandleUF&
HandleUF = FindWindow(vbNullString, Me.Caption)
BaseWinProc = GetWindowLong(HandleUF, GWL_WNDPROC)
#If vba6 Then
SetWindowLong HandleUF, GWL_WNDPROC, AddressOf RelaisWinProc
#Else
SetWindowLong HandleUF, GWL_WNDPROC, AddrOf("RelaisWinProc")
#End If
End Sub
Public Function WinProc&(ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal
lParam&)
Const WM_ACTIVATE& = &H6, GWL_WNDPROC& = -4&
If uMsg = WM_ACTIVATE Then
ShowWindow hwnd, 0&
AnimateWindow hwnd, 400&, AW_VER_POSITIVE Or AW_HOR_POSITIVE Or
AW_ACTIVATE
SetWindowLong hwnd, GWL_WNDPROC, BaseWinProc
AppActivate Me.Caption
WinProc = 1&
Exit Function
End If
WinProc = CallWindowProc(BaseWinProc, hwnd, uMsg, wParam, lParam)
End Function
Dans un module standard
Private Declare Function GetCurrentVbaProject& Lib "vba332" _
Alias "EbGetExecutingProj" (hProject&)
Private Declare Function GetFuncID& Lib "vba332" _
Alias "TipGetFunctionId" (ByVal hProject&, _
ByVal strFunctionName$, ByRef strFunctionID$)
Private Declare Function GetAddr& Lib "vba332" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject&, _
ByVal strFunctionID$, ByRef lpfnAddressOf&)
#If vba6 Then
#Else
Public Function AddrOf&(CallbackFunctionName$)
'AddressOf operator replacement for Office97 VBA
'Authors: Ken Getz and Michael Kaplan
'declaration of local variables
Dim aResult&, CurrentVBProject&, strFunctionID$
Dim AddressOfFunction&, UnicodeFunctionName$
'if the current VBProjects exists...
If GetCurrentVbaProject(CurrentVBProject) = 0 Then Exit Function
'convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'get the function ID of the callback function, based on its
unicode-converted name, _
in order to ensure that it exists
If GetFuncID(CurrentVBProject, UnicodeFunctionName, strFunctionID) = 0
Then
'if the function exists indeed ...
'get a pointer to the callback function based on the strFunctionID
argument _
of the GetFuncID function
If GetAddr(CurrentVBProject, strFunctionID, AddressOfFunction) = 0
Then _
AddrOf = AddressOfFunction
'if we've got the pointer pass it to the result of the function
End If
End Function
#End If
Function RelaisWinProc&(ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal
lParam&)
RelaisWinProc = UserForm1.WinProc(hwnd, uMsg, wParam, lParam)
End Function
Alain CROS
Bonjour Michel.
Je n'arrive à faire fonctionner aucune de tes propositions.
Le UserForm apparait puis disparait.
Ceci semble fonctionner
Dans le module du UserForm
'Anime la fenêtre de gauche à droite.
Const AW_HOR_POSITIVE = &H1
'Anime la fenêtre de droite à gauche.
Const AW_HOR_NEGATIVE = &H2
'Anime la fenêtre du haut vers le bas.
Const AW_VER_POSITIVE = &H4
'Anime la fenêtre du bas vers le haut.
Const AW_VER_NEGATIVE = &H8
'Réduction vers son centre avec AW_HIDE et inversement avec AW_ACTIVATE.
Const AW_CENTER = &H10
'Cache la fenêtre.
Const AW_HIDE = &H10000
'Active la fenêtre.
Const AW_ACTIVATE = &H20000 'Active la fenêtre.
'Effet de "fondu" (si elle est au premier plan).
Const AW_BLEND = &H80000
'Fait "rouler" la fenêtre.
Const AW_SLIDE = &H40000
Private Declare Function AnimateWindow& Lib "user32" _
(ByVal hwnd&, ByVal dwTime&, ByVal dwFlags&)
Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function GetWindowLong& Lib "user32" Alias
"GetWindowLongA" _
(ByVal hwnd&, ByVal nIndex&)
Private Declare Function SetWindowLong& Lib "user32" Alias
"SetWindowLongA" _
(ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Declare Function CallWindowProc& Lib "user32" Alias
"CallWindowProcA" _
(ByVal lpPrevWndFunc&, ByVal hwnd&, ByVal Msg&, ByVal wParam&, ByVal
lParam&)
Private Declare Function ShowWindow& Lib "user32" _
(ByVal hwnd&, ByVal nCmdShow&)
Private BaseWinProc&
Private Sub UserForm_Initialize()
Const GWL_WNDPROC& = -4&
Dim HandleUF&
HandleUF = FindWindow(vbNullString, Me.Caption)
BaseWinProc = GetWindowLong(HandleUF, GWL_WNDPROC)
#If vba6 Then
SetWindowLong HandleUF, GWL_WNDPROC, AddressOf RelaisWinProc
#Else
SetWindowLong HandleUF, GWL_WNDPROC, AddrOf("RelaisWinProc")
#End If
End Sub
Public Function WinProc&(ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal
lParam&)
Const WM_ACTIVATE& = &H6, GWL_WNDPROC& = -4&
If uMsg = WM_ACTIVATE Then
ShowWindow hwnd, 0&
AnimateWindow hwnd, 400&, AW_VER_POSITIVE Or AW_HOR_POSITIVE Or
AW_ACTIVATE
SetWindowLong hwnd, GWL_WNDPROC, BaseWinProc
AppActivate Me.Caption
WinProc = 1&
Exit Function
End If
WinProc = CallWindowProc(BaseWinProc, hwnd, uMsg, wParam, lParam)
End Function
Dans un module standard
Private Declare Function GetCurrentVbaProject& Lib "vba332" _
Alias "EbGetExecutingProj" (hProject&)
Private Declare Function GetFuncID& Lib "vba332" _
Alias "TipGetFunctionId" (ByVal hProject&, _
ByVal strFunctionName$, ByRef strFunctionID$)
Private Declare Function GetAddr& Lib "vba332" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject&, _
ByVal strFunctionID$, ByRef lpfnAddressOf&)
#If vba6 Then
#Else
Public Function AddrOf&(CallbackFunctionName$)
'AddressOf operator replacement for Office97 VBA
'Authors: Ken Getz and Michael Kaplan
'declaration of local variables
Dim aResult&, CurrentVBProject&, strFunctionID$
Dim AddressOfFunction&, UnicodeFunctionName$
'if the current VBProjects exists...
If GetCurrentVbaProject(CurrentVBProject) = 0 Then Exit Function
'convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'get the function ID of the callback function, based on its
unicode-converted name, _
in order to ensure that it exists
If GetFuncID(CurrentVBProject, UnicodeFunctionName, strFunctionID) = 0
Then
'if the function exists indeed ...
'get a pointer to the callback function based on the strFunctionID
argument _
of the GetFuncID function
If GetAddr(CurrentVBProject, strFunctionID, AddressOfFunction) = 0
Then _
AddrOf = AddressOfFunction
'if we've got the pointer pass it to the result of the function
End If
End Function
#End If
Function RelaisWinProc&(ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal
lParam&)
RelaisWinProc = UserForm1.WinProc(hwnd, uMsg, wParam, lParam)
End Function
Alain CROS