Loading ...
Sorry, an error occurred while loading the content.

OLE controls and child windows with ID = 0

Expand Messages
  • pkaluski
    Hi, I have an interesting problem, which probably some of you have faced already. I am trying to automate testing of GUI application (let s call it APP1) using
    Message 1 of 3 , May 21, 2004
    • 0 Attachment
      Hi,
      I have an interesting problem, which probably some of you have faced
      already.

      I am trying to automate testing of GUI application (let's call it
      APP1) using Win32::GUITest.
      APP1 is a standard window application, writen with MFC, with many
      windows.
      I am trying to avoid reaching the given control by a sequence of tabs.
      Instead I do the following:
      I am running APP1, the I run spy++ and I find the control I want to
      deal with. Using spy++ I can find control's Control ID. Having this I
      can find a control's window handle using FindWindowLike in my perl
      script.
      After all, Control ID is constant and does not change between runs,
      whereas window handle is different everytime we run the APP1.
      OK. It worked fine. However one day I found a window, which contained
      control with Control ID = 0. If you run FindWindowLike with Control ID
      = 0, you will get all children. I solved the problem by adding a
      condition on a window class (there was only one control of this
      class).
      However, I found next window, which contained several controls of the
      same class, all with Control ID = 0.
      The question is - how can I get window handle of the SPECIFIC control.
      Let me illustrate what I mean:

      If I have window with three controls:

      Name (edit), ControlID= 1
      LastName( edit), ControlID= 2
      Age (edit), ControlID= 3

      Then I can easily get control's handle. I do FindWindowLike with
      Controls ID = 2 and I get a window handle to LastName.

      If I have window with three controls:

      Name (CustomEditControl), ControlID= 0
      LastName (CustomEditControl), ControlID= 0
      Age (CustomEditControl), ControlID= 0

      Now, when I call FindWindowLike with ControlID = 0, I will get a list
      of 3 window handles. How would I programatically figure out, which
      handle is for Age, which is for name and so on?


      There is also one more factor, which may actually help. It seams that
      those "ID 0" controls are OLE controls. If so, how can I deal with
      them? Are there any tools and libraries, which would allow me to write
      a script, which will always figure out correctly which control is
      Name, which is LastName and so on?

      Any help would be greatly appreciated
      -Piotr
    • Gabor Szabo
      ... I am not sure I understood the issue but can t you access theses controls by their title ? Anyway I am not a Windows developer but do you know why are
      Message 2 of 3 , Jun 8, 2004
      • 0 Attachment
        On Fri, 21 May 2004, pkaluski wrote:


        > If I have window with three controls:
        >
        > Name (CustomEditControl), ControlID= 0
        > LastName (CustomEditControl), ControlID= 0
        > Age (CustomEditControl), ControlID= 0
        >
        > Now, when I call FindWindowLike with ControlID = 0, I will get a list
        > of 3 window handles. How would I programatically figure out, which
        > handle is for Age, which is for name and so on?

        I am not sure I understood the issue but can't you access theses controls
        by their title ?

        Anyway I am not a Windows developer but do you know why are there several
        controls with the same ID ? I don't know any valid reason for this
        (correct me if I am wrong) so I would consider this as a bug. If the
        Application you are using is in your control you should report this as
        a bug and get the developers fix this.

        Of course it means you have to reach a point where the developers actually
        make the application easily testable which might not be easy.

        Gabor
      • pkaluski
        ... list ... controls ... several ... as ... actually ... Hi Gabor, Thanks for your response. To answer your questions: 1. Can t you access this control by
        Message 3 of 3 , Jun 27, 2004
        • 0 Attachment
          --- In perlguitest@yahoogroups.com, Gabor Szabo <gabor@p...> wrote:
          > On Fri, 21 May 2004, pkaluski wrote:
          >
          >
          > > If I have window with three controls:
          > >
          > > Name (CustomEditControl), ControlID= 0
          > > LastName (CustomEditControl), ControlID= 0
          > > Age (CustomEditControl), ControlID= 0
          > >
          > > Now, when I call FindWindowLike with ControlID = 0, I will get a
          list
          > > of 3 window handles. How would I programatically figure out, which
          > > handle is for Age, which is for name and so on?
          >
          > I am not sure I understood the issue but can't you access theses
          controls
          > by their title ?
          >
          > Anyway I am not a Windows developer but do you know why are there
          several
          > controls with the same ID ? I don't know any valid reason for this
          > (correct me if I am wrong) so I would consider this as a bug. If the
          > Application you are using is in your control you should report this
          as
          > a bug and get the developers fix this.
          >
          > Of course it means you have to reach a point where the developers
          actually
          > make the application easily testable which might not be easy.
          >
          > Gabor

          Hi Gabor,
          Thanks for your response.
          To answer your questions:
          1. Can't you access this control by it's title.
          No, I can't because this control has no title.
          2. Do I know why this is the case and is this a bug.
          Well, the controls I am talking about are all controls of the same
          type. They are ole controls used in MFC project. When you have project
          wizard generate the proper code for you, it will add the control with
          control ID = 0.
          So it seams that either control id is not obligatory for a control or
          ole controls are handled differently.

          -Piotr
        Your message has been successfully submitted and would be delivered to recipients shortly.