Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How can I get the ID of an activex control that the keyboard foucs staying at?

How can I get the ID of an activex control that the keyboard foucs staying at?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncom
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pantao551
    wrote on last edited by
    #1

    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!

    N 1 Reply Last reply
    0
    • P pantao551

      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!

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      I have noticed that active-x are always created with id 0. Use Spy++ and check the ID.

      nave [OpenedFileFinder]

      S 1 Reply Last reply
      0
      • N Naveen

        I have noticed that active-x are always created with id 0. Use Spy++ and check the ID.

        nave [OpenedFileFinder]

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • S Stephen Hewitt

          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

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          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]

          S 1 Reply Last reply
          0
          • N Naveen

            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]

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #5

            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

            N 1 Reply Last reply
            0
            • S Stephen Hewitt

              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

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #6

              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]

              S 1 Reply Last reply
              0
              • N Naveen

                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]

                S Offline
                S Offline
                Stephen Hewitt
                wrote on last edited by
                #7

                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

                N 1 Reply Last reply
                0
                • S Stephen Hewitt

                  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

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #8

                  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]

                  P 1 Reply Last reply
                  0
                  • N Naveen

                    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]

                    P Offline
                    P Offline
                    pantao551
                    wrote on last edited by
                    #9

                    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.

                    N 1 Reply Last reply
                    0
                    • P pantao551

                      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.

                      N Offline
                      N Offline
                      Naveen
                      wrote on last edited by
                      #10

                      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::FindItemfunction() for more details.

                      nave [OpenedFileFinder]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups