Accueil > > > AJOUTER UN BOUTON DANS LA BARRE DE TITRE
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
Sources du même auteur
Sources de la même categorie
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
|
Derniers Blogs
PRéSENTATION DES API REST DE WINDOWS AZURE : LISTER LES COMPTES DE STORAGEPRéSENTATION DES API REST DE WINDOWS AZURE : LISTER LES COMPTES DE STORAGE par richardc
http://www.c2idotnet.com/articles/presentation-des-api-rest-de-windows-azure-lister-les-comptes-de-storage
Désolé pour "toto", mais c2i existait avant blogs.developpeur.org et c'est mon site "officiel" ;-) ...
Cliquez pour lire la suite de l'article par richardc [HTML5] SLIDES ET DéMOS : AUTOUR DU W3C , NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] SLIDES ET DéMOS : AUTOUR DU W3C , NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Très bonne après-midi passée lors cette conférence avec le W3C, organisée par L' Inria sur les nouveaux standards, ce Mardi 14 Février, on sent vraiment que çà bosse au W3C, et l'avenir est très très prometteur pour le HTML5, notamment ...
Cliquez pour lire la suite de l'article par Gio GESTION D'EXCEPTION AVEC LES TASKSGESTION D'EXCEPTION AVEC LES TASKS par richardc
Nous avons vu dans un précédent article comment utiliser Task pour effectuer des opérations dans un autre thread.
Malheureusement, comme tout le monde n'est pas parfait, il se peut que cette exécution se passe mal et qu'une exception se produise.
La...
Cliquez pour lire la suite de l'article par richardc DéMARRONS AVEC LES TASKSDéMARRONS AVEC LES TASKS par richardc
Que vous le vouliez ou non, le développement multi-tâche est maintenant une obligation pour toute nouvelle application. Il est donc vital d'en comprendre les mécanismes et de s'y mettre le plus tôt possible.
En attendant le .NET Framework 4.5 avec le...
Cliquez pour lire la suite de l'article par richardc
Forum
FONCTION EXCELFONCTION EXCEL par samanta26
Cliquez pour lire la suite par samanta26
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|