OLE Control and Events (OpenInsight 32-bit)
At 06 DEC 2022 10:08:11PM Joshua Goddard wrote:
OI: 9.4
Hi,
I have a form that has an ole control in it. The OLE control is a html editor made in Winforms.
Anyway, I want to capture when a user enters a character into the control. To do that, I have qualified the WM_KEYDOWN and WM_CHAR events in my code.
rv = Send_Message(@window,'QUALIFY_EVENT', 'ALL_OLES' ,1) rv = Send_Message(@window,'QUALIFY_EVENT', 'ALL_WINMSGS' ,1)However, the WM_KEYDOWN and WM_CHAR events are not getting into my commuter module (I logged all events, and those events were not in the log). But I know that these events are occurring because I can see them in the SPY++ tool (https://learn.microsoft.com/en-us/visualstudio/debugger/using-spy-increment?view=vs-2022)
So, my question is, how can I capture these events for an OLE control in an OI commuter module.
At 07 DEC 2022 01:53AM Donald Bakke wrote:
OI: 9.4
Hi,
I have a form that has an ole control in it. The OLE control is a html editor made in Winforms.
Anyway, I want to capture when a user enters a character into the control. To do that, I have qualified the WM_KEYDOWN and WM_CHAR events in my code.
rv = Send_Message(@window,'QUALIFY_EVENT', 'ALL_OLES' ,1) rv = Send_Message(@window,'QUALIFY_EVENT', 'ALL_WINMSGS' ,1)However, the WM_KEYDOWN and WM_CHAR events are not getting into my commuter module (I logged all events, and those events were not in the log). But I know that these events are occurring because I can see them in the SPY++ tool (https://learn.microsoft.com/en-us/visualstudio/debugger/using-spy-increment?view=vs-2022)
So, my question is, how can I capture these events for an OLE control in an OI commuter module.
You should be qualifying the event for the full control name rather than just @Window.
Does this HTML editor provide its own support to capture these messages or are you hoping to add your own support on top of what the OLE control does natively?
At 07 DEC 2022 04:57PM Joshua Goddard wrote:
Actually, I accidentally omitted the control name from the code I posted. In my actual code, I use the control name. So, it's not that.
The Winforms control does have these events
KeyDown
KeyUp
KeyPress
PreviewKeyDown
So I think it does support these events.
At 07 DEC 2022 05:25PM Carl Pates wrote:
It's unlikely that the PS gets to see the Windows messages that you are interested in unless the control is subclassed in some fashion or can pass them on in the form of an event that can be caught in the OLE layer.
.NET controls hosted in OLE are messy at best - they usually live on a different thread to the main PS thread and use a different memory model, so there's quite a bit of isolation. The best way forward it to create a .NET wrapper around your control that exposes that parts that you need to COM so you can qualify them in OI as OLE events and see them there. Using the "raw" Windows API against them generally doesn't work.
Another tip: never use "ALL_WINMSGS" - this can hammer your system into the ground - only specify the ones that you need, otherwise you have a lot of unnecessary overhead (FYI - ALL_WINMSGS is not supported in v10)
At 08 DEC 2022 01:42AM Joshua Goddard wrote:
OK, if I can't figure out how to "expose" the events to OI, I will ask here.
BTW, are there ways other than COM to call another DLL from OI? For example, can I call a .net DLL from OI without COM?
Thanks
At 08 DEC 2022 01:49AM Donald Bakke wrote:
Actually, I accidentally omitted the control name from the code I posted. In my actual code, I use the control name. So, it's not that.
The Winforms control does have these events
KeyDown
KeyUp
KeyPress
PreviewKeyDown
So I think it does support these events.
If these are events built into the OLE control itself, then I would expect this to work:
rv = Send_Message(@window : '.HTML_CTRL', 'QUALIFY_EVENT', 'OLE.KeyDown', 1) rv = Send_Message(@window : '.HTML_CTRL', 'QUALIFY_EVENT', 'OLE.KeyUp', 1) rv = Send_Message(@window : '.HTML_CTRL', 'QUALIFY_EVENT', 'OLE.KeyPress', 1) rv = Send_Message(@window : '.HTML_CTRL', 'QUALIFY_EVENT', 'OLE.PreviewKeyDown', 1)
At 11 DEC 2022 06:17PM Joshua Goddard wrote:
Thanks…I will try your suggestion once the stored procedure is not locked…
At 11 DEC 2022 07:03PM Joshua Goddard wrote:
Hmmm, this didn't work.