How can I get the ID of an activex control that the keyboard foucs staying at?
-
There are some activeX controls on my dialog, and I want to get the ID of the activeX control that has the keyboard focus. I use the function: GetWindowsLong(::GetFocus(), GWL_ID), But the return value is always 0. I put the fuction GetLastErr() after it, but the return value is ERORR_SUCCESS. Did I use the wrong fuction? And is there any other way to get the Id? Thanks!
-
There are some activeX controls on my dialog, and I want to get the ID of the activeX control that has the keyboard focus. I use the function: GetWindowsLong(::GetFocus(), GWL_ID), But the return value is always 0. I put the fuction GetLastErr() after it, but the return value is ERORR_SUCCESS. Did I use the wrong fuction? And is there any other way to get the Id? Thanks!
I have noticed that active-x are always created with id 0. Use Spy++ and check the ID.
nave [OpenedFileFinder]
-
I have noticed that active-x are always created with id 0. Use Spy++ and check the ID.
nave [OpenedFileFinder]
Naveen.R wrote:
I have noticed that active-x are always created with id 0. Use Spy++ and check the ID.
I don't believe this is reliable. Also note that ActiveX controls need not even have a window.
Steve
-
Naveen.R wrote:
I have noticed that active-x are always created with id 0. Use Spy++ and check the ID.
I don't believe this is reliable. Also note that ActiveX controls need not even have a window.
Steve
Stephen Hewitt wrote:
I don't believe this is reliable
I just said my findings. If you show me a sample which have a active-x control id other than 0, I am ready to change the statement.
nave [OpenedFileFinder]
-
Stephen Hewitt wrote:
I don't believe this is reliable
I just said my findings. If you show me a sample which have a active-x control id other than 0, I am ready to change the statement.
nave [OpenedFileFinder]
I inserted the “Microsoft Office Chart 10.0” control into the “ActiveX Control Test Container” then used "Spy++" to scope out the IDs -- no zeros to be seen! Your advice relies on implementation details of the controls in question.
Steve
-
I inserted the “Microsoft Office Chart 10.0” control into the “ActiveX Control Test Container” then used "Spy++" to scope out the IDs -- no zeros to be seen! Your advice relies on implementation details of the controls in question.
Steve
Stephen Hewitt wrote:
I inserted the “Microsoft Office Chart 10.0” control into the “ActiveX Control Test Container” then used "Spy++" to scope out the IDs
Ya u r right... Its an ATL active-x isnt it. when I chacked other ATL activex's, it also have have ID. But many other non ATL active x, the ID 0, like Calender,Micorsoft Form 2 controls( For those having windows ). I have tried specifying the control id while creating the control. In such cases also Id is coming as 0. May be as you said its the implementation difference of control. But offcourse I think this is not under our control. Do you think its the implementation differece of ATL Active X and MFC Active x?
nave [OpenedFileFinder]
-
Stephen Hewitt wrote:
I inserted the “Microsoft Office Chart 10.0” control into the “ActiveX Control Test Container” then used "Spy++" to scope out the IDs
Ya u r right... Its an ATL active-x isnt it. when I chacked other ATL activex's, it also have have ID. But many other non ATL active x, the ID 0, like Calender,Micorsoft Form 2 controls( For those having windows ). I have tried specifying the control id while creating the control. In such cases also Id is coming as 0. May be as you said its the implementation difference of control. But offcourse I think this is not under our control. Do you think its the implementation differece of ATL Active X and MFC Active x?
nave [OpenedFileFinder]
Naveen.R wrote:
Do you think its the implementation differece of ATL Active X and MFC Active x?
Both ATL's and MFC's hosting and control implentation details differ. But this line of reasoning is missing the point: If you’re manipulating an ActiveX control you should manipulate it via the OLE control interfaces if possible and be weary of directly manipulating it’s window; windowless controls need not even have windows! One of the main goals of ActiveX control is to isolate clients of the implementation details of the control. ATL allows you to treat the control as a window but the window you manipulate is part of the hosting code and not part of the control: it handles messages and translates them into interface calls on the control. See the
OnSize
function in the "ATLHOST.H" file for an example.Steve
-
Naveen.R wrote:
Do you think its the implementation differece of ATL Active X and MFC Active x?
Both ATL's and MFC's hosting and control implentation details differ. But this line of reasoning is missing the point: If you’re manipulating an ActiveX control you should manipulate it via the OLE control interfaces if possible and be weary of directly manipulating it’s window; windowless controls need not even have windows! One of the main goals of ActiveX control is to isolate clients of the implementation details of the control. ATL allows you to treat the control as a window but the window you manipulate is part of the hosting code and not part of the control: it handles messages and translates them into interface calls on the control. See the
OnSize
function in the "ATLHOST.H" file for an example.Steve
Sorry I dont know much about ATL. May be we can focus on MFC.. :) What my doubt is that, when ever I create a MFC activex and add it to some applications, the control id is 0. Why this comes so? MFC ignores those ID's? ( Not only MFC activex but the activex like microsoft form 2 control also have same behavior )
nave [OpenedFileFinder]
-
Sorry I dont know much about ATL. May be we can focus on MFC.. :) What my doubt is that, when ever I create a MFC activex and add it to some applications, the control id is 0. Why this comes so? MFC ignores those ID's? ( Not only MFC activex but the activex like microsoft form 2 control also have same behavior )
nave [OpenedFileFinder]
-
The axtiveX I used was "Microsoft Forms 2.0 OptionButton", and I created it in the MFC application.... But in the Resource.h file the activeX control has the id which is not 0.
Can you tell me y u need the id of the control? As i told earlier, that "Microsoft Forms 2.0 OptionButton" active x will be created with out an id. But MFC internally keeps the id of the control. check the
COleControlSite::FindItem
function() for more details.nave [OpenedFileFinder]