XGUI not passing events to dispatch methods
Messages for XGUI classes only go through the wndproc event handler on the underlying forms but are not passed to the windows dispatch methods. Migrated code relying on processing the events in dispatchers doesn't work.
To Reproduce Write a simple AppWindow with a dispatcher and show it. Let the disptcher record all events. Move the mouse or click inside. Check the output - there is none.
Expected behavior Every event should arrive in the windows dispatchers like it does in VO. The events should carry the window handle (not the panel handle). It's up to the developer if he uses this or not. Here are our reasons for that: https://www.xsharp.eu/forum/topic?p=33378#p33378
Additional context Add any other context about the problem here.
I totally forgot, but this has already been implemented in 96c725f91d77e505fbbfa82fe9aaf00355191e4c and will be part of X# 2.23.
There is now a property EnableDispatch on the Window class. When set to TRUE then the Dispatch() method on the window will be called. This method has the following prototype:
METHOD Dispatch (oEvent as Event) AS LONG
When this method returns 0, then the standard WndProc() of the Forms class will be called. A non-zero return value suppresses the call to super:WndProc().
Will let Stefan confirm that this is working as expected for his needs.
Original problem reported in https://www.xsharp.eu/forum/topic?t=5397&start=10
Robert, Stefan asked for an additional global setting to EnableDispatch for all windows and controls, in order to avoid doing that for every single one manually. Can this be done easily?
Chris, The real value for Control:EnableDispatch is stored in the VOControlProperties class. The value for Window:EnableDispatch is stored in the VOForm class. These are not really initialized, so it is initialized to FALSE. We can initialize them from a global variable, so by setting the global all new controls and forms will have the value set from that global. That would still allow you to suppress the dispatch per window/control if you want. I suggest creating a global gEnableDispatch in Application.prg (there are several other globals in there) and use that global to initialize the EnableDispatch properties.
That would be great, thanks. Besides, the virtual propery EnableDispatch works perfectly as expected.
I have pushed the change to the Dev branch. Chris, can you test it and produce a DLL for Stefan to test?
Seems to be working well here, Stefan you need to update the file in the GAC (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\XSharp.VOGUIClasses\v4.0_2.6.0.0__ed555a0467764586) and in the X# Redist folder (C:\Program Files (x86)\XSharp\Redist).
You'll need to set gEnableDispatch := TRUE before you instantiate the windows.
Hi Chris,
I've copied the file to both directories, cleaned the project, updated all references and added the line in the very first processed lines of our code like this:
PROCEDURE globalInit() _INIT3 // as void pascal
gcbOldBlock := ErrorBlock( gcbKOBErrorhandler )
gcErrorStack := HandlerAsString( Errorhandlers.KOBERRORHANDLER )+" (EInit)"
glGlobalInitDone := TRUE
gEnableDispatch := TRUE
return
Result:
Fehler XS0103 The name 'gEnableDispatch' does not exist in the current context lib_(F9)XBasis C:\Users\stefan.ungemach\source\repos\XSharp\XBasis\lib(F9)_XBasis\Funktionen_funRuntime.prg 108
I could place it elsewhere but I want to understand what I'm missing.
Maybe you should also copy the file to "c:\Program Files (x86)\XSharp\Assemblies"
That did the trick! After copying the file to all the 3 destinations I put the global setting in _INIT3, removed the EnableDispatch entries from all of my test classes and recompiled - everything behaving as expected. Thanks!
Confirmed fixed by client