OCX control focus events not firing.

Started by Elias Montoya, January 13, 2012, 04:29:09 AM

Previous topic - Next topic

Elias Montoya


Hi It's me again.  :-[ :-[ :-[

I am not getting the WM_SETFOCUS and WM_KILLFOCUS events in the CUSTOM event handler. Is there a way to do it?

Here's my code:

'--------------------------------------------------------------------------------
FUNCTION STEP129_OCXCONTROL1_CUSTOM ( _
                                   ControlIndex  As Long,  _  ' index in Control Array
                                   hWndForm      As Dword, _  ' handle of Form
                                   hWndControl   As Dword, _  ' handle of Control
                                   wMsg          As Long,  _  ' type of message
                                   wParam        As Dword, _  ' first message parameter
                                   lParam        As Long   _  ' second message parameter
                                   ) As Long
                                   
                                   
Select Case wMsg
   Case %WM_KILLFOCUS
      MsgBox "No luck."
     
   Case %WM_SETFOCUS
      MsgBox "No luck."     
   
End Select

End FUNCTION


Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

José Roca

May we know some details like which OCX control is it?

Elias Montoya


Im still using DHTMLEdit control.

I connected the event handler but i don't see how could i know the focus state with those.
Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

José Roca

1. OCXs don't send WM_XXX messages, but fire events to the events sink class.

2. I don't see any "focus" event among the events fired by this control.

Elias Montoya


I will give it a try to that.

When i click the control in the editor, i am not able to move the control unless i select it in the firefly workspace and enter the position manually. So, I thought that, if Paul couldn't do it, it would not be possible.

Thanks again Jose.
Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

José Roca

You don't have to click in the OCX, but in the border of the window. The OCX is not displayed directly in the form, but inside the Ole Container.

Elias Montoya

#6
I tried, and yes, some times it works. Most of the times i end up double clicking the form and going to the form's default function. For now i will stick to seleting it in the list of controls. But thanks for the tip Jose. :)

By the way, calling GetFocus() while the OCX control is focused, gives me a handle. And then using GetParent(GetParent(GetFocus())) Gives me the handle of the OCX container, which is the HWND_FORM196_OCXCONTROL1 that firefly defines. From there, setting up a timer also gives me the information if the form is focused or not... and i can forward that message as a WM_SETFOCUS or a WM_KILLFOCUS notification via sendmessage to the control's event handler that Firefly provides. However, im not so sure how safe is that to do, considering that maybe the result will be different in diferent OS's and different versions of the DHTMLEdit control... What do you think? Should i stick to the event's sink class? (sounds safer)

:)

Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

José Roca

#7
There are controls like this one that are designed to work with languages such Visual Basic in which the entire form is a container for ActiveX controls. Using and Ole Container implemented as a custom control such mine or ATL just provides a way to use them, but without fully integration, since both the form and the other controls are SDK windows, not ActiveXs. Once VB6 has been deprecated, all the OCXs made for it have also been deprecated. Don't know why you want to use DHTMLEDIT, since it no longer works in Vista/Windows 7. Currently, the only ActiveX control that I use is the WebBrowser control. The rest, simply stop working in new versions of Windows or have problems, and nobody cares to update them.


Elias Montoya


I get the picture. So, it's like grappling to the past. Well, I want to use DHTMLEdit mainly because of two reasons:

a) It is working pretty good in Windows 7.
b) I don't know any better.  ;D

If you have a better solution, I am willing to try. Of course i am. Coming from you, I'm sure it will be good. :)
Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.


Elias Montoya


Wow.. it is even simpler than using the DHTMLEdit control... i will give it a try!!!. :)

Thanks Jose!
Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.