Caio Alex sto lavorando sul tuo demo ho preso il demo Abilita Messaggi su un pc a 32 bit ho selezionato i soli codici che mi servono, ora però in fase di conversione a 64 bit ho un problema, ho convertito le dichiarazioni delle subclass così
Option Explicit
' ---------------- DICHIARAZIONE A LIVELLO DI MODULO ----------------
'WIN 64
Private Declare PtrSafe Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As LongPtr, ByVal hwnd As LongPtr, _
ByVal Msg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Public Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As LongLong
Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal nCount As Long)
'win 32
'Public Declare PtrSafe Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, _
ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Public Declare PtrSafe Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
'Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal nCount As Long)
Public Const WM_SYSCOMMAND = &H112
Public Const SC_MINIMIZE = &HF020&
Public Const SC_MAXIMIZE = &HF030&
Public Const SC_RESTORE = &HF120&
Public Const GWL_WNDPROC As Long = (-4)
' Imposta il nuovo indirizzo per la WindowProc
Public OldWindowProc As Long
'Public Function NewWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function NewWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPtr
Const WM_WINDOWPOSCHANGED = &H47
Dim mret As Boolean
Dim retVal As Long
Select Case Msg
Case WM_SYSCOMMAND
mret = Forms!AbilitaMessaggi.GetMessage(Msg, wParam)
If mret Then Exit Function
retVal = CallWindowProc(OldWindowProc, hwnd, Msg, wParam, lParam)
Case Else
retVal = CallWindowProc(OldWindowProc, hwnd, Msg, wParam, lParam)
End Select
' Continua il normale processamento. IMPORTANTISSIMO!
NewWindowProc = retVal
End Function
ed invece i codice nella maschera così
Private Sub Form_Load()
' Attivazione del SubClassing sulla Form
OldWindowProc = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf NewWindowProc)
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Me.hwnd, GWL_WNDPROC, OldWindowProc
End Sub
Public Function GetMessage(ByVal uMsg As Long, ByVal wParam As LongPtr) As Boolean
Select Case uMsg
Case WM_SYSCOMMAND
Select Case wParam
Case SC_MINIMIZE
Me.lstMessage.AddItem "Ricevuto SC_MINIMIZE = " & SC_MINIMIZE & IIf(ck_SC_MINIMIZE, " Attivo", " Disattivato")
GetMessage = Not ck_SC_MINIMIZE
Case SC_MAXIMIZE
Me.lstMessage.AddItem "Ricevuto SC_MAXIMIZE = " & SC_MAXIMIZE & IIf(ck_SC_MAXIMIZE, " Attivo", " Disattivato")
GetMessage = Not ck_SC_MAXIMIZE
Case SC_RESTORE
Me.lstMessage.AddItem "Ricevuto SC_RESTORE = " & SC_RESTORE & IIf(ck_SC_RESTORE, " Attivo", " Disattivato")
GetMessage = Not ck_SC_RESTORE
Case Else
GetMessage = False
End Select
End Select
End Function
ma mi dà l' errore tipo non corispondente in
AddressOf NewWindowProc
sicuramente è un problema di conversione ma non riesco a capire dove.
non è che mi potresti dare una dritta?