Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Question d'API

2 réponses
Avatar
DJ9B
Bonjour à tous !
Je voudrai sur un userform ne plus voir apparaître la croix ainsi qu'y
placer mon icone perso.
J'ai trouver sur le site de Misange des classeurs exemples pour faire soit
l'un soit l'autre.
Mais comment faire pour associer les 2 ?
Merci !

Pour faire disparaitre la croix :
Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub UserForm_Initialize()
Dim hwnd As Long
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub

Pour y placer mon icone perso :
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName$, ByVal lpWindowName$) As Long
Private Declare Function SendMessageA Lib "user32" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam%, ByVal lParam
As Long) As Long
Private Declare Function ExtractIconA Lib "shell32.dll" _
(ByVal hInst As Long, ByVal lpszExeFileName$, ByVal nIconIndex As
Long) As Long

Private Sub UserForm_Initialize()
Dim Chemin$, IcoPath$
Dim hIcon As Long
Chemin = ThisWorkbook.Path
IcoPath = Chemin & "\SP.ico"
hIcon = Len(Dir(IcoPath))
If hIcon = 0 Then Exit Sub
hIcon = ExtractIconA(0, IcoPath, 0)
Me.Caption = " Impression des Plannings Chargement"
SendMessageA FindWindow(vbNullString, Me.Caption), &H80, False, hIcon
End Sub

--
à tantôt !
DJ9B
e-mail : *Enleve_moi_ça*dj9b@free.fr
Site : www.dj9b.fr.st

2 réponses

Avatar
Michel Pierron
Bonsoir DJ9B;
AMHA, il faut que tu choisisses. L'ajout d'une icône entraine la
restauration du menu system et la suppression du menu system entraine
automatiquement la suppresion de l'icône; la seule chose compatible avec tes
souhaits est l'hinibition de la croix de fermeture.

Exemple 1: Suppression du menu system
Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)

Private Sub UserForm_Initialize()
Me.Caption = " Impression des Plannings Chargement"
SetWindowLong FindWindow(vbNullString, Me.Caption), -16, &H84C00080
End Sub

Exemple 2: Ajout d'une icône
Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function ExtractIcon& Lib "shell32.dll" Alias _
"ExtractIconA" (ByVal hInst&, ByVal lpszExeFileName$, ByVal nIconIndex&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" _
(ByVal hwnd&, ByVal wMsg&, ByVal wParam%, ByVal lParam As Any)

Private Sub UserForm_Initialize()
Me.Caption = " Impression des Plannings Chargement"
Dim IcoPath$, hIcon&
IcoPath = ThisWorkbook.Path & "SP.ico"
If Len(Dir(IcoPath)) Then
hIcon = ExtractIcon(0, IcoPath, 0)
SendMessage FindWindow(vbNullString, Me.Caption), &H80, 0, hIcon
End If
End Sub

Exemple 3: Ajout d'une icône et inhibition de la croix de fermeture
Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function ExtractIcon& Lib "shell32.dll" Alias _
"ExtractIconA" (ByVal hInst&, ByVal lpszExeFileName$, ByVal nIconIndex&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" _
(ByVal hwnd&, ByVal wMsg&, ByVal wParam%, ByVal lParam As Any)
Private Declare Function GetSystemMenu& Lib "user32" _
(ByVal hwnd&, ByVal bRevert&)
Private Declare Function DeleteMenu& Lib "user32" _
(ByVal hMenu&, ByVal nPosition&, ByVal wFlags&)
Private Declare Function DrawMenuBar& Lib "user32" (ByVal hwnd&)

Private Sub UserForm_Initialize()
Me.Caption = " Impression des Plannings Chargement"
Dim hwnd&, IcoPath$, hIcon&
hwnd = FindWindow(vbNullString, Me.Caption)
IcoPath = ThisWorkbook.Path & "SP.ico"
If Len(Dir(IcoPath)) Then
hIcon = ExtractIcon(0, IcoPath, 0)
SendMessage hwnd, &H80, 0, hIcon
End If
DeleteMenu GetSystemMenu(hwnd, 0), &HF060, 0&
DrawMenuBar hwnd
End Sub

MP

"DJ9B" <enlevez-ç a écrit dans le message de
news:
Bonjour à tous !
Je voudrai sur un userform ne plus voir apparaître la croix ainsi qu'y
placer mon icone perso.
J'ai trouver sur le site de Misange des classeurs exemples pour faire soit
l'un soit l'autre.
Mais comment faire pour associer les 2 ?
Merci !

Pour faire disparaitre la croix :
Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub UserForm_Initialize()
Dim hwnd As Long
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub

Pour y placer mon icone perso :
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName$, ByVal lpWindowName$) As Long
Private Declare Function SendMessageA Lib "user32" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam%, ByVal lParam
As Long) As Long
Private Declare Function ExtractIconA Lib "shell32.dll" _
(ByVal hInst As Long, ByVal lpszExeFileName$, ByVal nIconIndex As
Long) As Long

Private Sub UserForm_Initialize()
Dim Chemin$, IcoPath$
Dim hIcon As Long
Chemin = ThisWorkbook.Path
IcoPath = Chemin & "SP.ico"
hIcon = Len(Dir(IcoPath))
If hIcon = 0 Then Exit Sub
hIcon = ExtractIconA(0, IcoPath, 0)
Me.Caption = " Impression des Plannings Chargement"
SendMessageA FindWindow(vbNullString, Me.Caption), &H80, False, hIcon
End Sub

--
à tantôt !
DJ9B
e-mail : *Enleve_moi_ça*
Site : www.dj9b.fr.st




Avatar
DJ9B
Bonjour Michel !
L'exemple 3 me convient parfaitement, ce qui m'importe c'est que
l'utilisateur ne puisse pas utiliser la croix pour sortir du userform.
Je te remercie !

--
à tantôt !
DJ9B
e-mail : *Enleve_moi_ça*
Site : www.dj9b.fr.st
"Michel Pierron" a écrit dans le message de
news:%
Bonsoir DJ9B;
AMHA, il faut que tu choisisses. L'ajout d'une icône entraine la
restauration du menu system et la suppression du menu system entraine
automatiquement la suppresion de l'icône; la seule chose compatible avec
tes

souhaits est l'hinibition de la croix de fermeture.

Exemple 1: Suppression du menu system
Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)

Private Sub UserForm_Initialize()
Me.Caption = " Impression des Plannings Chargement"
SetWindowLong FindWindow(vbNullString, Me.Caption), -16, &H84C00080
End Sub

Exemple 2: Ajout d'une icône
Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function ExtractIcon& Lib "shell32.dll" Alias _
"ExtractIconA" (ByVal hInst&, ByVal lpszExeFileName$, ByVal nIconIndex&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" _
(ByVal hwnd&, ByVal wMsg&, ByVal wParam%, ByVal lParam As Any)

Private Sub UserForm_Initialize()
Me.Caption = " Impression des Plannings Chargement"
Dim IcoPath$, hIcon&
IcoPath = ThisWorkbook.Path & "SP.ico"
If Len(Dir(IcoPath)) Then
hIcon = ExtractIcon(0, IcoPath, 0)
SendMessage FindWindow(vbNullString, Me.Caption), &H80, 0, hIcon
End If
End Sub

Exemple 3: Ajout d'une icône et inhibition de la croix de fermeture
Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function ExtractIcon& Lib "shell32.dll" Alias _
"ExtractIconA" (ByVal hInst&, ByVal lpszExeFileName$, ByVal nIconIndex&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" _
(ByVal hwnd&, ByVal wMsg&, ByVal wParam%, ByVal lParam As Any)
Private Declare Function GetSystemMenu& Lib "user32" _
(ByVal hwnd&, ByVal bRevert&)
Private Declare Function DeleteMenu& Lib "user32" _
(ByVal hMenu&, ByVal nPosition&, ByVal wFlags&)
Private Declare Function DrawMenuBar& Lib "user32" (ByVal hwnd&)

Private Sub UserForm_Initialize()
Me.Caption = " Impression des Plannings Chargement"
Dim hwnd&, IcoPath$, hIcon&
hwnd = FindWindow(vbNullString, Me.Caption)
IcoPath = ThisWorkbook.Path & "SP.ico"
If Len(Dir(IcoPath)) Then
hIcon = ExtractIcon(0, IcoPath, 0)
SendMessage hwnd, &H80, 0, hIcon
End If
DeleteMenu GetSystemMenu(hwnd, 0), &HF060, 0&
DrawMenuBar hwnd
End Sub

MP

"DJ9B" <enlevez-ç a écrit dans le message de
news:
Bonjour à tous !
Je voudrai sur un userform ne plus voir apparaître la croix ainsi qu'y
placer mon icone perso.
J'ai trouver sur le site de Misange des classeurs exemples pour faire
soit


l'un soit l'autre.
Mais comment faire pour associer les 2 ?
Merci !

Pour faire disparaitre la croix :
Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub UserForm_Initialize()
Dim hwnd As Long
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub

Pour y placer mon icone perso :
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName$, ByVal lpWindowName$) As Long
Private Declare Function SendMessageA Lib "user32" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam%, ByVal
lParam


As Long) As Long
Private Declare Function ExtractIconA Lib "shell32.dll" _
(ByVal hInst As Long, ByVal lpszExeFileName$, ByVal nIconIndex As
Long) As Long

Private Sub UserForm_Initialize()
Dim Chemin$, IcoPath$
Dim hIcon As Long
Chemin = ThisWorkbook.Path
IcoPath = Chemin & "SP.ico"
hIcon = Len(Dir(IcoPath))
If hIcon = 0 Then Exit Sub
hIcon = ExtractIconA(0, IcoPath, 0)
Me.Caption = " Impression des Plannings Chargement"
SendMessageA FindWindow(vbNullString, Me.Caption), &H80, False, hIcon
End Sub

--
à tantôt !
DJ9B
e-mail : *Enleve_moi_ça*
Site : www.dj9b.fr.st