(Disclaimer: the following is in process and subject to change. The author, nor Microsoft, makes no guarantees nor warrantys on the content of this post)
One of the features we intended to put into VFP 9 was AppState, a _SCREEN property that would allow you to trap when a VFP application got or lost focus in regards to other Windows apps. All you needed to do was setup some code and a BINDEVENT and you could trap it.
Now this was something asked for by quite a lot of customers and seemed like a great idea. However, we were having problems with it as there were double the number of Windows focus messages flying around under certain circumstances. This made testing difficult and since there was no way to further granularize what was actually happening, it would make for a problematic implementation in line-of-business customer applications.
So Calvin took to exploring the whole Windows messaging concept and has come up with something even better: The RegWinProc function.
What does it do? Well...here's the early upshot direct from Calvin's email:
RegWinProc(hWnd,nWinMessage,cProcedure)
hWnd is the hWnd value from _VFP or _SCREEN or a VFP Form. nWinMessage is the Windows message, a numeric value in a hexadecimal representation in MSDN documentation; ie, 0x0201 is WM_LBUTTONDOWN or left mouse button down. cProcedure is the UDF to call for the specified window and message.
So what is gained? Pretty much the entire Windows messaging world. Here's some mini-use cases:
My understanding is that there are lots of .Net samples for this type of code and I'm sure we'll come up with some and you guys will come up with a lot...which I'm hoping you upload copiously to web forums and other net watering holes to share your insights. I'm sure this will be fertile ground for article writers as well.
Final word: There's a movie quote rattling around in my head, “With great power comes great responsibility”. Ken would know who said it and when <g>. My point is, with this new function you have a lot of control of what is going on in Windows external to your VFP application. It's quite possible, if used poorly, that you could crash your application or other processes on your computer. This is not something new to RegWinProc - you can do it now with DECLARE - DLL and a misuse of the API.
Final (I mean it this time), final word: This new function was just approved and did not make it to the public beta build. However, if we refresh the beta later on you'll likely see it. I'll post a followup if and when that occurs.