PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Martin Francom on January 27, 2010, 11:27:26 PM

Title: Testing for control that HAS focus
Post by: Martin Francom on January 27, 2010, 11:27:26 PM
I am trapping the  ESC key in the FF_PUMPHOOK function.

    I want to do one thing a if a particular TextBox has FOCUS   and do something else if that  TextBox  does not have FOCUS.

    How can I test to find out if a particular TextBox has FOCUS ?
Title: Re: Testing for control that HAS focus
Post by: José Roca on January 28, 2010, 12:13:41 AM
Call GetFocus and check if the returned handle is the same as the one of your control.
Title: Re: Testing for control that HAS focus
Post by: Martin Francom on January 28, 2010, 04:47:17 AM
ahh... yes... very good.  thank you Jose


I don't see GetFocus as a FF function  and it doesn't seem to be a PB command.  I found a   FF_Control_SetFocus   in the Function Library  but no  FF_Control_GetFocus.    Is it just a non documented function?    What is the syntax?

I am not sure how to use what your suggesting.
Title: Re: Testing for control that HAS focus
Post by: Rolf Brandt on January 28, 2010, 05:13:51 AM
GetFocus is a Win32 API function. You would call it:

res = GetFocus
msgbox str$(res) 'or ztrace str$(res)

It returns the handle of the window that has currently the focus.
Title: Re: Testing for control that HAS focus
Post by: Martin Francom on January 28, 2010, 09:41:08 PM
Thanks Rolf for the clarification
Title: Re: Testing for control that HAS focus
Post by: Paul Squires on January 28, 2010, 10:07:25 PM
Quote from: Marty Francom on January 28, 2010, 04:47:17 AM
I found a   FF_Control_SetFocus   in the Function Library  but no  FF_Control_GetFocus.    Is it just a non documented function?    What is the syntax?

Looks like it is time for me to write an "Survival Guide to WinAPI Functions". Need to cover the basic functions that every programmer needs to know. For example, I don't know where any programmer would be without GetWindowRect, GetClientRect, SetWindowPos, MapWindowPoints.......
Title: Re: Testing for control that HAS focus
Post by: José Roca on January 28, 2010, 10:59:30 PM
There are two things that anybody wanting to master the Windows API and low-level COM needs to learn: 1) Parameter passing and calling conventions; 2) Pointers.
Title: Re: Testing for control that HAS focus
Post by: Gary Stout on January 29, 2010, 12:33:07 AM
Put my vote down for the API survial guide!
Coming from a product that shielded me from most of the API has me about as lost as a ball in tall weeds when it comes to doing things without them being wrapped in a EZ command   :-\ (some pun intended)

Gary
Title: Re: Testing for control that HAS focus
Post by: Rolf Brandt on January 29, 2010, 04:48:11 AM
API Survival Guide? Y E S !

I used (and still do) a lot of API Function in VB6. I found the API-Guide from the KPD-Team (Dutch Web site, which is no longer available) very helpful. I still use their tool with about a thousand examples, declerations, infos, etc. Much of the code could be easily adapted to PB.

It is quite similar to the FF3 Functions Library I think the Functions Library as a standalone program would make a good API Survival Guide.

Just found the API-Guide on the Net, the guys put up a download site again. Have a look!
http://allapi.mentalis.org/agnet/apiguide.shtml (http://allapi.mentalis.org/agnet/apiguide.shtml)
Title: Re: Testing for control that HAS focus
Post by: José Roca on January 29, 2010, 05:27:28 AM
I began something similar in my forum and posted several dozens of examples. See: http://www.jose.it-berater.org/smfforum/index.php?board=207.0

I will post more when time will allow. Currently I'm busy updating my Windows API Headers to Windows 7.
Title: Re: Testing for control that HAS focus
Post by: Martin Francom on January 29, 2010, 05:41:19 AM
Quote from: TechSupport on January 28, 2010, 10:07:25 PM
Quote from: Marty Francom on January 28, 2010, 04:47:17 AM
I found a   FF_Control_SetFocus   in the Function Library  but no  FF_Control_GetFocus.    Is it just a non documented function?    What is the syntax?

Looks like it is time for me to write an "Survival Guide to WinAPI Functions". Need to cover the basic functions that every programmer needs to know. For example, I don't know where any programmer would be without GetWindowRect, GetClientRect, SetWindowPos, MapWindowPoints.......


Yes, Paul that would be great.   I'm an old guy that never learned to swim, I have jumped in and am in water over my head.  Throwing this old guy a life ring would be most appreciated.   If your  "Survival Guide to WinAPI Functions" ever comes to fruition I most certainly would read it.   The next problem would be imbedding it in my memory, but at least I would have it for reference.

Hey, I appologize for the elementary questions that I ask from time to time.  And I appreciate the good humor with which you all tollerate them.  I am old enough now that I no longer get embarrassed when I ask the obvious. 

I hope from time to time I have been able to contribute a little.       
Title: Re: Testing for control that HAS focus
Post by: Rolf Brandt on January 29, 2010, 06:38:05 AM
There are some very helpful functions in your collection, Jose.

InternetGetConnectedState came in just handy for me, because I am writing a XP based mobile client program.

I am looking forward to more additions.
Title: Re: Testing for control that HAS focus
Post by: Paul Squires on January 29, 2010, 08:23:25 AM
Quote from: Marty Francom on January 29, 2010, 05:41:19 AM
Hey, I appologize for the elementary questions that I ask from time to time.  And I appreciate the good humor with which you all tollerate them.  I am old enough now that I no longer get embarrassed when I ask the obvious. 

I hope from time to time I have been able to contribute a little.       

No worries at all - your questions are always pertienent and you give back more than you take. The more questions that we all ask the better - that's what this programming community is all about. The worst thing that any of us can do is start to believe that we know more about programming than others. I'm lucky that over the last 10 or 15 years that I have gained a fair bit of knowledge (mostly through trial and error testing and writing programs like JellyFish and FireFly) but when i look at some of the stuff by the likes of Jose and Dominic, I just want to hide my head in shame! :)
Title: Re: Testing for control that HAS focus
Post by: Thomas Cone Jr on January 29, 2010, 10:19:31 AM
The API Survival Guide is something I would be very very interested in, too.

-- tom
Title: Re: Testing for control that HAS focus
Post by: Roger Garstang on January 29, 2010, 06:49:17 PM
Custom Control Guide would be good too.  I still want to get the improved FolderTree working I made back in FF3 beta that kept crashing.  It would be much nicer to pull the System Icons and not needing to have a DLL.  Even if it was just a low level showing what FF does when certain options are picked, code snips from FF's custom control functions, differences and changes needed when control uses DLL and without, etc.  I'm alright making the code, it is how to integrate it with FF that wasn't so clear.
Title: Re: Testing for control that HAS focus
Post by: Wilko Verweij on January 30, 2010, 04:55:19 PM
I read Appleman's "guide to the win32 api" a few times and I find it a great book. I learned not only how to use single API calls but especially to understand in which situation you should or could use an API call. It also explains the context of each API call. Is a bit old now, and was written for VB, not PB, but I learned a lot from that book.