Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 24th, 2005, 9:38 AM   #1
faLLeN
Newbie
 
Join Date: Mar 2005
Location: Hertfordshire, UK
Posts: 16
Rep Power: 0 faLLeN is on a distinguished road
Send a message via MSN to faLLeN
Subclassing \ hooking the OS

Hi

I am trying to determine how to do the following things in VB6:

1) Determine when the keyboard focus has changed (ie. the user has moved the blinking text cursor to another text box or edit class in any application)

2) After having recieved notification of the above, I would like to be able to determine if the textbox that has the focus has character masking enabled on it. In VB6 you would determine this in your application by seeing if PasswordChar contains anything. Of course, the method in which I could check this is going to be different - as I am wanting to monitor ANY application!

Any help much appreciated!

Matthew
__________________
Kind regards,
Matthew Hall
______________________________________
My personal site
iD Hosting Services UK - Plans from £2.50!
faLLeN is offline   Reply With Quote
Old Aug 24th, 2005, 10:05 AM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Hey,

to find out if a text box has focus you can do sotmhign like this:

Private Sub Text1_GotFocus()
          'Do what you want.
End Sub
which would work if the user ether
1) clicks the text box.
2) Tabs to the text box.

As for your second question, for checking for any app, you'd probably have to do it through the Windows API.

See the msdn for more info on that.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Aug 26th, 2005, 11:07 PM   #3
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Well whatever the purpose, be it systematically grabbing the contents of every textbox that could possibly be a password (!), your best bet would be to look out for the WM_FOCUS window message, the lParam of which is the windows handle. You could then do a GetWindowLong(hwnd) Or WS_CHARMASKED or whatever to see if it employs the text masked style (for exact details of the password box class, use Spy++) and grab its contents using GetWindowText(), or the longer SendMessage(WM_GETTEXT ... ) for the "more secure" XP password boxes.
To actually hook the Windows global message stream, you can insert a callback via the CallWindowsHookEx function, though this starts to get into some complex multithreading, as windows sets a timeout on the delegate of 100ms or so.
I would post my hilarious program-that-replaces-what-you-type-with-rude-words project that demonstrates windows hooks, but I'm stuck halfway through a Gentoo install with a buggy BIOS.
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:17 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC