Bonjour,

Je travaille avec Microsoft Excel 2019 sous Windows 10.
Pour une de mes applications en VBA, je voudrais masquer la barre de titre de cette application.
J'ai trouvé du code sur un forum mais il ne fonctionne pas sur les systèmes 64 bits.

Un message s'affiche :

"Le code contenu dans ce projet doit être mis à jour pour être utilisé sur les systèmes 64 bits. Vérifiez et mettez à jour les instructions Declare puis marquez les avec l'attribut PtrSafe."

Quelqu'un pourrait-il m'aider ?

Merci d'avance.

------------------- Voici le code utilisé ------------------------------
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Option Explicit
 
'### Apis ###
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" ( _
  ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
 
Private Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" ( _
  ByVal Hwnd As Long, ByVal nIndex As Long)
 
Declare Function SetWindowPos& Lib "user32" ( _
  ByVal Hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
  ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
 
Declare Function GetWindowRect& Lib "user32" (ByVal Hwnd As Long, lpRect As structRECT)
 
'### Constantes ###
'--- GetWindowLong ---
Const GWL_STYLE = (-16)
Const WS_CAPTION = &HC00000
Const WS_MAXIMIZEBOX = &H10000
Const WS_MINIMIZEBOX = &H20000
Const WS_SYSMENU = &H80000
'--- SetWindowPos ---
Const SWP_FRAMECHANGED = &H20
Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Const SWP_HIDEWINDOW = &H80
Const SWP_NOACTIVATE = &H10
Const SWP_NOCOPYBITS = &H100
Const SWP_NOMOVE = &H2
Const SWP_NOOWNERZORDER = &H200
Const SWP_NOREDRAW = &H8
Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_SHOWWINDOW = &H40
'--- GetWindowRect ---
Private Type structRECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type
 
Sub DemasqueTitreAppli()
Call SwitchMasque(True)
End Sub
 
Sub MasqueTitreAppli()
Call SwitchMasque(False)
End Sub
 
Sub SwitchMasque(bool As Boolean)
Dim Style&
Dim Rect As structRECT
Dim Hwnd&
Hwnd& = Application.Hwnd
GetWindowRect Hwnd&, Rect
'---
Style& = GetWindowLong(Hwnd&, GWL_STYLE)
If Not bool Then
  Style& = Style& And Not WS_SYSMENU
  Style& = Style& And Not WS_MAXIMIZEBOX
  Style& = Style& And Not WS_MINIMIZEBOX
  Style& = Style& And Not WS_CAPTION
Else
  Style& = Style& Or WS_SYSMENU
  Style& = Style& Or WS_MAXIMIZEBOX
  Style& = Style& Or WS_MINIMIZEBOX
  Style& = Style& Or WS_CAPTION
End If
SetWindowLong Hwnd&, GWL_STYLE, Style&
'---
With Rect
  SetWindowPos Hwnd&, 0, .Left, .Top - 25, .Right - .Left, .Bottom - .Top + 25, _
      SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED
End With
End Sub