Accueil > > > EVENT QUAND LA FORM BOUGE (SUBSCLASSING)
EVENT QUAND LA FORM BOUGE (SUBSCLASSING)
Information sur la source
Description
Grâce au subclassing, on peut savoir lorsque l'utilisateur déplace la fenêtre
Source
- ' ###################
- ' # Dans une form nommée Form1
- ' ###################
- Private Sub Form_Load()
- HookForm1
- Show 0
- End Sub
-
- Private Sub Form_Unload(Cancel As Integer)
- UnHookForm1
- End Sub
-
- ' ###################
- ' # Dans un module
- ' ###################
-
- Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
- Public Const GWL_WNDPROC = (-4)
-
- Public Const WM_MOVE = &H3
-
- Public OldProc As Long
-
- Sub HookForm1()
- OldProc = SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf WindowProc)
- End Sub
-
- Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
- Select Case uMsg
- Case WM_MOVE
- Form1.Caption = "Heure du dernier déplacement : " & Time
- End Select
- WindowProc = CallWindowProc(OldProc, hwnd, uMsg, wParam, lParam)
- End Function
-
- Sub UnHookForm1()
- Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, OldProc)
- End Sub
-
' ###################
' # Dans une form nommée Form1
' ###################
Private Sub Form_Load()
HookForm1
Show 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnHookForm1
End Sub
' ###################
' # Dans un module
' ###################
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const GWL_WNDPROC = (-4)
Public Const WM_MOVE = &H3
Public OldProc As Long
Sub HookForm1()
OldProc = SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_MOVE
Form1.Caption = "Heure du dernier déplacement : " & Time
End Select
WindowProc = CallWindowProc(OldProc, hwnd, uMsg, wParam, lParam)
End Function
Sub UnHookForm1()
Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, OldProc)
End Sub
Conclusion
Avant de débuguer, tester, ... ma source. merci de lire l'article sur le subclassing (si vous ne voulez pas faire plater votre VB) : http://vbfrance.com/article.aspx?Val=5226
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
PAS D'INTELLITRACE SUR MON SITE WEB DANS IIS !PAS D'INTELLITRACE SUR MON SITE WEB DANS IIS ! par Etienne Margraff
J'ai récemment eu un problème pour obtenir l'intelliTrace sur un site web dans IIS. Il n'y avait pas de message d'erreur, rien dans le journal d'évènement Windows, et après 3 appels à une voyante, 2 visites chez un marabou, j'ai failli me résign...
Cliquez pour lire la suite de l'article par Etienne Margraff OFFICE 365 - SHAREPOINT ONLINE, QUELQUES LIMITATIONSOFFICE 365 - SHAREPOINT ONLINE, QUELQUES LIMITATIONS par junarnoalg
De nombreuses entreprises font le choix de SharePoint Online, service fourni au travers de l'offre de Microsoft Office 365. S'il est vrai que ce choix apporte un grand nombre d'avantages; rapidité de mise en œuvre, disponibilité, large couvertu...
Cliquez pour lire la suite de l'article par junarnoalg 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
Forum
FONCTION EXCEL VBAFONCTION EXCEL VBA 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
|