|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
AJOUTER UN BOUTON DANS LA BARRE DE TITRE
Information sur la source
Description
C'est pour ajouter un bouton dans la barre de titre Mettez sa dans un module
Source
- Option Explicit
- Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As Rect) As Long
- Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
- Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
- Private 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) As Long
- Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&) As Long
- Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook&) As Long
- Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
- Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
- Private Type Rect
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
- Private Type CWPSTRUCT
- lParam As Long
- wParam As Long
- Message As Long
- hwnd As Long
- End Type
- Const WM_MOVE = &H3
- Const WM_SETCURSOR = &H20
- Const WM_NCPAINT = &H85
- Const WM_COMMAND = &H111
- Const SWP_FRAMECHANGED = &H20
- Const GWL_EXSTYLE = -20
- Private WHook&
- Private ButtonHwnd As Long
- Public laFrm As Form
- Event Click()
- Public Sub InstallBouton()
- ButtonHwnd& = CreateWindowEx
- 'REGARDER PRÈS DE LA * REMPLACER POUR CHANGER LE TEXTE DU Bouton
- (0&, "Button", "*", &H40000000, 50, 50, 14, 14, laFrm.hwnd, 0&, App.hInstance, 0&)
- Call ShowWindow(ButtonHwnd&, 1)
- WHook = SetWindowsHookEx(4, AddressOf HookProc, 0, App.ThreadID)
- Call SetWindowLong(ButtonHwnd&, GWL_EXSTYLE, &H80)
- Call SetParent(ButtonHwnd&, GetParent(laFrm.hwnd))
- End Sub
- Public Sub DesinstallBouton()
- Call UnhookWindowsHookEx(WHook)
- Call SetParent(ButtonHwnd&, laFrm.hwnd)
- End Sub
- Private Function HookProc&(ByVal nCode&, ByVal wParam&, Inf As CWPSTRUCT)
- Dim FormRect As Rect
- Static LastParam&
- If Inf.hwnd = GetParent(ButtonHwnd&) Then
- If Inf.Message = WM_COMMAND Then
- Select Case LastParam
- Case ButtonHwnd&: MsgBox "salut"
- End Select
- ElseIf Inf.Message = WM_SETCURSOR Then
- LastParam = Inf.wParam
- End If
- ElseIf Inf.hwnd = laFrm.hwnd Then
- If Inf.Message = WM_NCPAINT Or Inf.Message = WM_MOVE Then
- Call GetWindowRect(laFrm.hwnd, FormRect)
- Call SetWindowPos(ButtonHwnd&, 0, FormRect.Right - 75, FormRect.Top + 6, 17, 14, SWP_FRAMECHANGED)
- End If
- End If
- End Function
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As Rect) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private 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) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook&) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type CWPSTRUCT
lParam As Long
wParam As Long
Message As Long
hwnd As Long
End Type
Const WM_MOVE = &H3
Const WM_SETCURSOR = &H20
Const WM_NCPAINT = &H85
Const WM_COMMAND = &H111
Const SWP_FRAMECHANGED = &H20
Const GWL_EXSTYLE = -20
Private WHook&
Private ButtonHwnd As Long
Public laFrm As Form
Event Click()
Public Sub InstallBouton()
ButtonHwnd& = CreateWindowEx
'REGARDER PRÈS DE LA * REMPLACER POUR CHANGER LE TEXTE DU Bouton
(0&, "Button", "*", &H40000000, 50, 50, 14, 14, laFrm.hwnd, 0&, App.hInstance, 0&)
Call ShowWindow(ButtonHwnd&, 1)
WHook = SetWindowsHookEx(4, AddressOf HookProc, 0, App.ThreadID)
Call SetWindowLong(ButtonHwnd&, GWL_EXSTYLE, &H80)
Call SetParent(ButtonHwnd&, GetParent(laFrm.hwnd))
End Sub
Public Sub DesinstallBouton()
Call UnhookWindowsHookEx(WHook)
Call SetParent(ButtonHwnd&, laFrm.hwnd)
End Sub
Private Function HookProc&(ByVal nCode&, ByVal wParam&, Inf As CWPSTRUCT)
Dim FormRect As Rect
Static LastParam&
If Inf.hwnd = GetParent(ButtonHwnd&) Then
If Inf.Message = WM_COMMAND Then
Select Case LastParam
Case ButtonHwnd&: MsgBox "salut"
End Select
ElseIf Inf.Message = WM_SETCURSOR Then
LastParam = Inf.wParam
End If
ElseIf Inf.hwnd = laFrm.hwnd Then
If Inf.Message = WM_NCPAINT Or Inf.Message = WM_MOVE Then
Call GetWindowRect(laFrm.hwnd, FormRect)
Call SetWindowPos(ButtonHwnd&, 0, FormRect.Right - 75, FormRect.Top + 6, 17, 14, SWP_FRAMECHANGED)
End If
End If
End Function
Conclusion
Exécuter set Lafrm=Me call installbouton
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
ajouter bouton dans barre titre [ par lomig.menez ]
Bonjour, j'aurai voulu savoir si quelqu'un savait comment faire pour ajouter un bouton dans la barre de titre d'une forme, a coté du Minbutton et Maxb
Bouton de barre de titre URGENT [ par Thibald ]
Il faut que je fasse un programme ayant dans la barre de titre un quatrième bouton (à côté des boutons agrandire, fermer ...) ou dans le menu contextu
Atacher un evenement au bouton "Maximiser" de la barre de titre [ par helorem ]
Comment peut-on detecter un clique sur un des bouton "reduire,maximiser,fermer" de la barre de titre ??je m'interesse surtout au bouton "Maximiser", a
ajouter un bouton dans une barre d'outils en VB 6.0 ??? HELP ME !!! [ par youkizouki ]
Save vous comment RAJOUTER UN BOUTTON AVEC UNE IMAGE avec visual basic 6.0 dans une barre d'outil créée lors de la création d
Ajouter un bouton à la barre des tâches [ par fallenmax ]
Bonjour,J'aimerais savoir s'il est possible d'ajouter un bouton (qui ouvrirais un menu personnalisé) dans la barre des tâches, mais pas dans la sectio
Ajout d'un enregistrement [ par lydiemml ]
Bonjour à tous.J'ai un formulaire sur lequel j'ai des contrôles de différents types : des textbox, combobox, checkbox, ... Ils sont tous reliés à des
Clic souris sur barre de titre d'application [ par jibus ]
Bonjour, bonjour, Bon voilà mon problème, j'aimerai savoir si il existe une API ou un quelconque moyen de déterminer si on a cliqué sur la barre de ti
Barre de titre [ par ouafaekarim ]
comment faire pour cacher la barre de titre d'un form?merci
Titre de la barre des tâches [ par Gunshin82 ]
Bonjour à tous,J'ai chercher un peu partout sur le net avant de posté mais je n'ai rien trouvé donc me voilàs. J'ai fait une petite application pour c
Actualiser les données [ par Philppe2007 ]
Bonjour je vous demande de m'aider sur une question j'ai un bouton ajouter, un bouton actualiser et des textbox j'ai un probléme avec le bouton actu
|
Téléchargements
Logiciels à télécharger sur le même thème :
|