eng70640
March 8th, 2001, 08:14 AM
Is there a way to detect if the caption of a window has changed ?
|
Click to See Complete Forum and Search --> : Detect Change Caption of a Window eng70640 March 8th, 2001, 08:14 AM Is there a way to detect if the caption of a window has changed ? Clearcode March 8th, 2001, 08:35 AM You could subclass the wndproc and check for the WM_SETTEXT message.. '\\ Declarations Const WM_SETTEXT = &HC private Declare Function SetWindowLongApi Lib "user32" Alias "SetWindowLongA" (byval hwnd as Long, byval nIndex as Long, byval dwNewLong as Long) as Long const GWL_WNDPROC = (-4) using the following Vb equivalent of the wndproc: '\\ --[VB_WindowProc]------------------------------------------------------------------- '\\ 'typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM); '\\ Parameters: '\\ hwnd - window handle receiving message '\\ wMsg - The window message (WM_..etc.) '\\ wParam - First message parameter '\\ lParam - Second message parameter '\\ Note: '\\ When subclassing a window proc using this, set the eventhandler's '\\ hOldWndProc property to the window's previous window proc address. '\\ ---------------------------------------------------------------------------------------- '\\ You have a royalty free right to use, reproduce, modify, publish and mess with this code '\\ I'd like you to visit http://www.merrioncomputing.com for updates, but won't force you '\\ ---------------------------------------------------------------------------------------- public Function VB_WindowProc(byval hwnd as Long, byval wMsg as Long, byval wParam as Long, byval lParam as Long) as Long on Local error resume next If wMsg = WM_SETTEXT then '\\ Window text has changed End If VB_WindowProc = lRet End Function To start subclassing: lRet = SetWindowLongApi(Form1.hwnd, GWL_WNDPROC,AddressOf VB_WindowProc) '\\ store this lret To end subclassing: Call SetWindowLongApi(Form1.hwnd, GWL_WNDPROC,lRet) You must end subclassing before you kill the window... HTH, Duncan ------------------------------------------------- Ex. Datis: Duncan Jones Merrion Computing Ltd http://www.merrioncomputing.com dfwade March 8th, 2001, 02:12 PM if it is your code and you are wanting to detect a caption change then it is simple. Add a property to your form and then call your property rather than the caption property. public property let MyCaption(data as string) If me.Caption <> data then me.Caption = data msgbox "Hey myCaption has Changed" End If End property Yahoo Messenger ID dfWade10900 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |