Bonjour Patrick et autres membres,

Peut on me dire si les lignes ci-dessous peuvent être sans inconvénient mises en lieux et place du second code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
' Exemple de déclaration compatible avec 64 bit tiré du fichier "redimensionner userform.xlm"
' voir également pour formation le documet sur le net "compatibilité entre les version 64 bits et 32 bits sur d'office 2010"
 
Option Explicit
#If VBA7 Then
     'api pour changer le mode d affichage du userform et activer ou non la fenetre
    Public Declare PtrSafe Function SWH Lib "user32" Alias "ShowWindow" (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Long
    ' api pour changer le mode d affichage du userform et activer ou non la fenetre
    Public Declare PtrSafe Function SWA Lib "user32" Alias "ShowWindowAsync" (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Long
     ' api pour redresser l'affichage en cas de modification de la caption
    Public Declare PtrSafe Function DMB Lib "user32" Alias "DrawMenuBar" (ByVal hwnd As LongPtr) As Long
      #If Win64 Then
         Public Declare PtrSafe Function SWLA Lib "user32" Alias "SetWindowLongPtrA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
         Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
      #Else
         'api pour trouver et identifier le handle de la fenetre (identifiant de la fenetre
         Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
         'api pour appliquer le nouveau style a la fenetre (userform)
         Public Declare PtrSafe Function SWLA Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
      #End If
 
#Else
   'api pour trouver et identifier le handle de la fenetre (identifiant de la fenetre
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
      'api pour appliquer le nouveau style a la fenetre (userform)
    Public Declare Function SWLA Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
     'api pour redresser l'affichage en cas de modification de la caption
    Public Declare Function DMB Lib "user32" Alias "DrawMenuBar" (ByVal hwnd As Long) As Long
     'api pour changer le mode d affichage du userform et activer ou non la fenetre
    Public Declare Function SWH Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    ' api pour changer le mode d affichage du userform et activer ou non la fenetre
    Public Declare Function SWA Lib "user32" Alias "ShowWindowAsync" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
 
#End If
Option Explicit

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Public Declare PtrSafe Function FindWindowA& Lib "user32" (ByVal lpClassName$, ByVal lpWindowName$)
Public Declare PtrSafe Function GetWindowLongA& Lib "user32" (ByVal hwnd&, ByVal nIndex&)
Public Declare PtrSafe Function SetWindowLongA& Lib "user32" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
Comment puis-je adapter le premier code beaucoup plus général ? Il me semble que dans le premier code, il manque la seconde ligne du second code (et peut-être autre chose).

Merci.

Cordialement,
Paul