Skip to content

Implemented BindWinEvent for Windows Message events #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 13, 2021

Conversation

JoelLeach
Copy link

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! :)

@DougHennig DougHennig merged commit e88f93c into DougHennig:master Apr 13, 2021
@DougHennig
Copy link
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 ;
laWinEvents[lnRow,2] = loWinEvent.nMessage

@JoelLeach
Copy link
Author

I suppose that would never happen in FoxTabs, but I will make the change there too. Thanks!

@DougHennig
Copy link
Owner

I made a couple of other changes to support calling UnbindWinEvents with 2 parameters:

  • In UnbindWinEvents.prg, change:

CASE Pcount() = 3

to:

CASE Pcount() = 2

  • In VFPxWin32EventHandler.prg.UnBindEvents, I added another case:

CASE Pcount() = 2
* Unbind specific event/message
UnBindEvents(thWnd, tnMessage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants