Implemented BindWinEvent for Windows Message events#196
Merged
Conversation
bindwinevent.PRG, unbindwinevents.prg, vfpxwin32eventhandler.prg
Required by vfpxwin32eventhandler.prg
Owner
|
I found one issue: VFPxWin32EventHandler.CleanupEvents causes an error if there are no events, such as when closing Project Explorer without having edited anything. I changed: If laWinEvents[lnRow,1] = loWinEvent.hWnd and laWinEvents[lnRow,2] = loWinEvent.nMessage to: If not empty(laWinEvents[lnRow,1]) and laWinEvents[lnRow,1] = loWinEvent.hWnd and ; |
Author
|
I suppose that would never happen in FoxTabs, but I will make the change there too. Thanks! |
Owner
|
I made a couple of other changes to support calling UnbindWinEvents with 2 parameters:
CASE Pcount() = 3 to: CASE Pcount() = 2
CASE Pcount() = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While using ProjectExplorer, I noticed that FoxTabs wasn't working right. I figured this probably came down to event binding conflicts, since FoxTabs makes heavy use of events. Years ago, I discovered the following statement in the VFP Help file:
When binding to Windows message (Win Msg) events, only one hWnd to Windows message pairing can exist.
Due to this limitation, Greg Green ran into conflicts between FoxTabs and his utilities. So, he developed a small framework to work around the limitation. It basically converts Win Msg events to standard VFP events, which allow multiple bindings. There is more on this subject at http://www.joelleach.net/2010/04/11/foxtabs-092-and-multiple-windows-event-bindings/.
I implemented this framework with ProjectExplorer, and I have been using it for a couple of months. It resolved the conflicts, and I have not noticed any ill effects. That said, you would want to confirm that your Win Msg event bindings are still working as expected. If you refactor any of the code, please ensure that the VFPxWin32EventHandler interface remains the same and that the instance is named "_Screen.oEventHandler", as FoxTabs and ProjectExplorer will be sharing that object.
This is my first pull request, so let me know if I did it wrong! :)