0

I've written a custom control (that does not create an HWND) that sits inside a modal dialog. I'm trying to intercept WM_GETOBJECT with lParam set to OBJID_CLIENT so I can return my IAccessible implementation of my custom control. The strange thing is I never see lParam set to OBJID_CLIENT although I do see WM_GETOBJECT.

The dialog is derived from WTL's CDialogImpl

The strange thing is, if I create a child window of the dialog and size it to fit within the dialog's client area, THAT window DOES get WM_GETOBJECT with lParam set to OBJID_CLIENT and everything works correctly.

Is there some special style or property I need to set on the dialog to receive the correct WM_GETOBJECT calls?

cppguy
  • 3,611
  • 2
  • 21
  • 36
  • What does "not based on an `HWND`" mean? – Jonathan Potter Jun 05 '15 at 01:56
  • Meaning it does not instantiate an HWND via CreateWindow. It's just an object that can render itself to a dc – cppguy Jun 05 '15 at 02:04
  • You say you are getting `WM_GETOBJECT`, just not `OBJID_CLIENT`, so what value(s) ARE you getting? Your control does not have an `HWND` so it cannot receive `WM_GETOBJECT` directly, you have to process it from the dialog's `HWND` instead. Seems like you would need a custom `IAccessible` for the dialog itself that reports your control as a child of the dialog. Do you have that? Or is that what you are having trouble implementing? – Remy Lebeau Jun 05 '15 at 02:20
  • It might be easier just to wrap your control in a "do-nothing" window class that can receive its own `WM_GETOBJECT` messages. – Jonathan Potter Jun 05 '15 at 02:22
  • @RemyLebeau the lParam is either 0 or -25 (which doesn't seem to even be a valid value). I am checking for WM_GETOBJECT in the dialog's windowproc. The dialog is itself a window of course which should have support for IAccessible for itself at least. – cppguy Jun 05 '15 at 02:24
  • @JonathanPotter That was one solution I tried but that would mean all my handling of mouse move/click messages that my custom control needs would have to be forwarded from the "do-nothing" window. Seems like a bit of a hack. Perhaps modal dialogs just don't ever receive the IAccessible notification directly. Although that seems to be false because running "Inspect" shows the dialog, the caption toolbar and the close button all as accessible objects – cppguy Jun 05 '15 at 02:27
  • You could try sub-classing the dialog and see if you get the expected `WM_GETOBJECT` messages that way - it may be that the dialog manager is filtering them out and not forwarding them to the dialog procedure. – Jonathan Potter Jun 05 '15 at 02:32
  • @JonathanPotter Like overwriting the window proc with SetWindowLongPtr? – cppguy Jun 05 '15 at 02:36
  • @cppguy Prefer `SetWindowSubclass`. – Jonathan Potter Jun 05 '15 at 02:40
  • 1
    @cppguy: -25 is `UiaRootObjectId`, which means "*the request is for a UI Automation provider. If the server is implementing UI Automation, it should return a provider using the [UiaReturnRawElementProvider](https://msdn.microsoft.com/en-us/library/windows/desktop/ee684069.aspx) function.*". See [Handling the WM_GETOBJECT Message](https://msdn.microsoft.com/en-us/library/windows/desktop/dd561885.aspx) for more details. – Remy Lebeau Jun 05 '15 at 03:07
  • 1
    Active Accessibility has built in support for dialogs, so it may not be sending OBJID_CLIENT. Also I'm not sure if you can create your own custom IAccessible object for the dialog that has your fake control as a child since dialog objects don't support `get_accChild`. Instead clients are supposed to "obtain the window handle of the control and then call AccessibleObjectFromWindow". I think you could save yourself a lot grief by implementing your control in a window like normal. – Ross Ridge Jun 05 '15 at 03:14

1 Answers1

1

So, ultimately I solved this problem by creating a child window at the same position as my custom control in my dialog with WM_ERASEBKGND returning TRUE and WM_NCHITTEST returning HTTRANSPARENT. In the message map of that window I forward all WM_GETOBJECT messages to my custom control.

cppguy
  • 3,611
  • 2
  • 21
  • 36