|
-
March 8th, 2001, 09:14 AM
#1
Detect Change Caption of a Window
Is there a way to detect if the caption of a window has changed ?
-
March 8th, 2001, 09:35 AM
#2
Re: Detect Change Caption of a Window
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
-
March 8th, 2001, 03:12 PM
#3
Re: Detect Change Caption of a Window
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|