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

Re: IsWindowStyle help

Expand Messages
  • brentje
    Bud...I use GetClassName in my code. I ve build a set of functions just for determining what an object is. It works very nicely, and over programs written in
    Message 1 of 6 , Jan 26, 2006
    • 0 Attachment
      Bud...I use GetClassName in my code. I've build a set of functions
      just for determining what an object is. It works very nicely, and
      over programs written in different languages. I'm relatively
      confident I know that it works. Look at the Guitest.pm code and
      you'll see what IsWindowStyle and GetClassName do. Here's the link to
      the MSDN description of GetWindowLong, which is what IsWindowStyle calls:

      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/getwindowlong.asp

      And here's GetClassName. Note that GuiTest's version only accepts the
      window handle.

      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/getclassname.asp


      From the Guitest.pc file, you'll see some values for SW_ constants.
      These are the values used for IsWindowStyle. By the looks of it, you
      are sending IsWindowStyle the SW_RESTORE (9) and SW_SHOWMINNOACTIVE
      (7) values.

      Try this code. You may have to rework it a bit to fit your program,
      but it's closer to what you actually want to do. I'm not sure that
      the Win32::GUI::IsVisible and IsEnabled code will work, but I'll let
      you figure that out. And I'm assuming that @siblings is a list of
      window handles inside your form, taken from FindWindowLike or
      something similar.

      foreach my $optionID (@siblings)
      {
      my $values=0;

      unless (Win32::GUI::IsVisible($optionID) &&
      Win32::GUI::IsEnabled($optionID) ) {next;}

      $s1="BS_GROUPBOX";
      $s2="BS_AUTORADIOBUTTON";

      my $className = GetClassName($optionID);

      print " style:$className, optionID:$optionID \n";
      if ($className eq $s1) #if groupbox
      {
      $btnName = GetWindowText($optionID);
      print " style(isGroupBox):$className, btnname: $btnName \n";
      next;
      }
      else
      {
      print " style (isNotGroupBox:$className)\n";
      next;
      }

      if ($className eq $s2) #if radio button
      {
      print " option IS AutoRadioButton: $optionID \n";
      push @OptionIDs, $optionID;
      $values++;
      }
      else
      {
      print " option NOT AutoRadioButton: $optionID \n";
      }
      }


      For quick testing, put this code into a program and run it from a
      console while your mouse is hovering over the object you want to
      check. It should come out with the object's text value if it has one,
      and it's class name.

      $hwndObject = WindowFromPoint(GetCursorPos());
      if($hwndObject != 0)
      {
      print (WMGetText($hwndObject) . "|" . GetClassName($hwndObject) .
      "|" . "\n");
      }

      For example, if you ran this code with you mouse over a Windows
      Explorer folder list, GetClassName detects it as "SysTreView321". The
      Address field detects as "ComboBox1". And the file list detects as a
      "SysListView321". The numbers may not always be the same, but the
      names should.

      Brent




      --- In perlguitest@yahoogroups.com, "oohay1_2005" <oohay1_2005@y...>
      wrote:
      >
      > It appears IsWindowStyle can determine different Win32 GUI styles type
      > (btw i do have a copy of winspy, that's how i know BS_GROUPBOX -->
      > 00000007); just not sure what documention
      > http://www.piotrkaluski.com/files/winguitest/docs/ch09s45.html
      > means by $style, is it the hex value, or decimal, or window styles
      > name? I have tried all but none seem to have an absolution output.
      >
      > $style = IsWindowStyle($optionID, '99999999' );
      > printf( " style: $style: %x\n", $optionID );
      > style:65604: 1c06f8
      > style:7: 1d06e6
      > style:65539: 1d0782
      > style:2: 150734
      > style:7: 1307fe
      > style:65539: 170730
      > style:2: 1506d6
      > style:65539: 18072c
      > style:7: 120792
      > style:9: 13078c
      > style:65545: 1606c4
      > ...
      >
      > $style = IsWindowStyle($optionID, '00000007' );
      > printf( " style: $style: %x\n", $optionID );
      > style:4: 1c06f8
      > style:7: 1d06e6
      > style:3: 1d0782
      > style:2: 150734
      > style:7: 1307fe
      > style:3: 170730
      > style:2: 1506d6
      > style:3: 18072c
      > style:7: 120792
      > style:1: 13078c
      > style:1: 1606c4
      >
      > while i appreciate all the supports and comments, if you are not sure,
      > please don't just comment randomly; this might give other reader(s)
      > the wrong message.
      >
      > no punt intended.
      > oohay1_2005
      >
      > --- In perlguitest@yahoogroups.com, "brentje" <brentje@y...> wrote:
      > >
      > > Hi
      > >
      > > I think you may be looking in the wrong place for what you want.
      > > IsWindowStyle has more to do with things like if a windows is
      > > maximized or iconifide, etc. What I think you are looking for is
      > > GetClassName(ControlHandle). This will return the control's class
      > > name, which in most programs come back with LISTBOX, RADIOBUTTON, etc.
      > > Get a spy utility (I occasionally use Winspector, but there's lots of
      > > others) and see what it detects your controls to be. Whatever it
      > > detects will be the same as what GetClassName returns. Then use those
      > > descriptions to find what you're looking for.
      > >
      > > Check out this:
      > > http://www.piotrkaluski.com/files/winguitest/docs/ch09s11.html
      > >
      > > There should also some working examples on the site too, with the
      > > spy.pl and spy--.pl programs.
      > >
      > > Hope this helps.
      > > Brent
      > >
      > > --- In perlguitest@yahoogroups.com, "oohay1_2005" <oohay1_2005@y...>
      > > wrote:
      > > >
      > > > I am trying to dynamically discover all radiobutton for each
      groupbox
      > > > to later create comboboxes of each radiobutton of each groupbox, for
      > > > selection from a test console, but having some problem with
      > > > IsWidnowStyle function. output of test of code below always return
      > > > false for groupbox and radiobutton. Thanks for all the support.
      > > >
      > > > [...]
      > > > foreach my $optionID (@siblings) {
      > > > my $values=0;
      > > > unless (Win32::GUI::IsVisible($optionID) &&
      > > > Win32::GUI::IsEnabled($optionID) ) {
      > > > next;
      > > > }
      > > >
      > > > $s1='^00000007'; #groupbox
      > > > $s2='^00000009'; #radiobutton
      > > > #s1="BS_GROUPBOX"; #not working;
      > > > #s2="BS_AUTORADIOBUTTON"; #not working
      > > > $style = IsWindowStyle($optionID, $s1 );
      > > > print " style:$style, optionID:$optionID \n";
      > > > if ($style eq 'TRUE'){ #if groupbox
      > > > #if ($style == 1){ #if groupbox
      > > > $btnName = GetWindowText($optionID);
      > > > print " style(isGroupBox):$style, btnname: $btnName \n";
      > > > next;
      > > > }
      > > >
      > > > if ($style eq 'FALSE'){ #if NOT groupbox
      > > > #if ($style eq == 0){
      > > > print " style (isNotGroupBox:$style, btnname: $btnName \n";
      > > > next;
      > > > }
      > > >
      > > > $optionStyle = IsWindowStyle($optionID, $s2);
      > > > print " optionStyle:$optionStyle, optionID:$optionID \n";
      > > > if ((GetClassName($optionID) eq 'Button') && ($optionStyle eq
      'TRUE'
      > > > )) {
      > > > print " option IS AutoRadioButton: $optionID \n";
      > > > push @OptionIDs, $optionID;
      > > > $values++;
      > > > }
      > > >
      > > > if ((GetClassName($optionID) eq 'Button') && ($optionStyle eq
      > > > 'FALSE' )) {
      > > > print " option NOT AutoRadioButton: $optionID \n";
      > > > }
      > > > }
      > > > [...]
      > > >
      > >
      >
    • oohay1_2005
      for those that are curious, my output shows that it s possible to use IsWindowStyle to test for certain GUI Styles type (groupbox, radiobutton, etc...). If one
      Message 2 of 6 , Jan 26, 2006
      • 0 Attachment
        for those that are curious, my output shows that it's possible to use
        IsWindowStyle to test for certain GUI Styles type (groupbox,
        radiobutton, etc...). If one is using WinSpy++, the value from Styles
        tab is in DWORD datatype, in my test, by converting the max. DWORD
        value to decimal value, IsWindowStyle was returning the style value in
        decimal format.

        #decimal DWORD desc
        #1342308361 50020009 unchecked radio button
        #1342242825 50010009 checked radio button
        #131072 00200000 WS_GROUP groupbox
        #4294967295 FFFFFFFF max DWORD
        ...
        $style = IsWindowStyle($optionID,4294967295);
        $style=sprintf( "%08d", $style);
        if ($style == 1342242825) {
        printf( " is checked radiobutton: $style: %x\n", $optionID );
        }
        if ($style == 1342308361) {
        printf( " is unchecked radiobutton: $style: %x\n", $optionID );
        }
        else {
        printf( " style: $style: %x\n", $optionID );
        }

        output example:
        style: 1342308359: 300738
        is unchecked radiobutton: 1342308361: 28072c
        is checked radiobutton: 1342242825: 4707b2
        style: 1342242825: 4707b2
        style: 1342308354: 1806e8
        style: 1342308359: a08dc
        is unchecked radiobutton: 1342308361: 6092c
        is checked radiobutton: 1342242825: 608f0
        style: 1342242825: 608f0
        style: 1342308354: 30a10
        style: 1342308359: 30a12
        ...

        someone correct me if i am wrong.

        --- In perlguitest@yahoogroups.com, "oohay1_2005" <oohay1_2005@y...>
        wrote:
        >
        > It appears IsWindowStyle can determine different Win32 GUI styles type
        > (btw i do have a copy of winspy, that's how i know BS_GROUPBOX -->
        > 00000007); just not sure what documention
        > http://www.piotrkaluski.com/files/winguitest/docs/ch09s45.html
        > means by $style, is it the hex value, or decimal, or window styles
        > name? I have tried all but none seem to have an absolution output.
        >
        > $style = IsWindowStyle($optionID, '99999999' );
        > printf( " style: $style: %x\n", $optionID );
        > style:65604: 1c06f8
        > style:7: 1d06e6
        > style:65539: 1d0782
        > style:2: 150734
        > style:7: 1307fe
        > style:65539: 170730
        > style:2: 1506d6
        > style:65539: 18072c
        > style:7: 120792
        > style:9: 13078c
        > style:65545: 1606c4
        > ...
        >
        > $style = IsWindowStyle($optionID, '00000007' );
        > printf( " style: $style: %x\n", $optionID );
        > style:4: 1c06f8
        > style:7: 1d06e6
        > style:3: 1d0782
        > style:2: 150734
        > style:7: 1307fe
        > style:3: 170730
        > style:2: 1506d6
        > style:3: 18072c
        > style:7: 120792
        > style:1: 13078c
        > style:1: 1606c4
        >
        > while i appreciate all the supports and comments, if you are not sure,
        > please don't just comment randomly; this might give other reader(s)
        > the wrong message.
        >
        > no punt intended.
        > oohay1_2005
        >
        > --- In perlguitest@yahoogroups.com, "brentje" <brentje@y...> wrote:
        > >
        > > Hi
        > >
        > > I think you may be looking in the wrong place for what you want.
        > > IsWindowStyle has more to do with things like if a windows is
        > > maximized or iconifide, etc. What I think you are looking for is
        > > GetClassName(ControlHandle). This will return the control's class
        > > name, which in most programs come back with LISTBOX, RADIOBUTTON, etc.
        > > Get a spy utility (I occasionally use Winspector, but there's lots of
        > > others) and see what it detects your controls to be. Whatever it
        > > detects will be the same as what GetClassName returns. Then use those
        > > descriptions to find what you're looking for.
        > >
        > > Check out this:
        > > http://www.piotrkaluski.com/files/winguitest/docs/ch09s11.html
        > >
        > > There should also some working examples on the site too, with the
        > > spy.pl and spy--.pl programs.
        > >
        > > Hope this helps.
        > > Brent
        > >
        > > --- In perlguitest@yahoogroups.com, "oohay1_2005" <oohay1_2005@y...>
        > > wrote:
        > > >
        > > > I am trying to dynamically discover all radiobutton for each
        groupbox
        > > > to later create comboboxes of each radiobutton of each groupbox, for
        > > > selection from a test console, but having some problem with
        > > > IsWidnowStyle function. output of test of code below always return
        > > > false for groupbox and radiobutton. Thanks for all the support.
        > > >
        > > > [...]
        > > > foreach my $optionID (@siblings) {
        > > > my $values=0;
        > > > unless (Win32::GUI::IsVisible($optionID) &&
        > > > Win32::GUI::IsEnabled($optionID) ) {
        > > > next;
        > > > }
        > > >
        > > > $s1='^00000007'; #groupbox
        > > > $s2='^00000009'; #radiobutton
        > > > #s1="BS_GROUPBOX"; #not working;
        > > > #s2="BS_AUTORADIOBUTTON"; #not working
        > > > $style = IsWindowStyle($optionID, $s1 );
        > > > print " style:$style, optionID:$optionID \n";
        > > > if ($style eq 'TRUE'){ #if groupbox
        > > > #if ($style == 1){ #if groupbox
        > > > $btnName = GetWindowText($optionID);
        > > > print " style(isGroupBox):$style, btnname: $btnName \n";
        > > > next;
        > > > }
        > > >
        > > > if ($style eq 'FALSE'){ #if NOT groupbox
        > > > #if ($style eq == 0){
        > > > print " style (isNotGroupBox:$style, btnname: $btnName \n";
        > > > next;
        > > > }
        > > >
        > > > $optionStyle = IsWindowStyle($optionID, $s2);
        > > > print " optionStyle:$optionStyle, optionID:$optionID \n";
        > > > if ((GetClassName($optionID) eq 'Button') && ($optionStyle eq
        'TRUE'
        > > > )) {
        > > > print " option IS AutoRadioButton: $optionID \n";
        > > > push @OptionIDs, $optionID;
        > > > $values++;
        > > > }
        > > >
        > > > if ((GetClassName($optionID) eq 'Button') && ($optionStyle eq
        > > > 'FALSE' )) {
        > > > print " option NOT AutoRadioButton: $optionID \n";
        > > > }
        > > > }
        > > > [...]
        > > >
        > >
        >
      • Piotr Kaluski
        ... Good point. I will try to remember to fix it. --Piotr
        Message 3 of 6 , Jan 27, 2006
        • 0 Attachment
          --- In perlguitest@yahoogroups.com, "oohay1_2005" <oohay1_2005@y...>
          wrote:
          >
          > It appears IsWindowStyle can determine different Win32 GUI styles type
          > (btw i do have a copy of winspy, that's how i know BS_GROUPBOX -->
          > 00000007); just not sure what documention
          > http://www.piotrkaluski.com/files/winguitest/docs/ch09s45.html
          > means by $style, is it the hex value, or decimal, or window styles
          > name?

          Good point. I will try to remember to fix it.

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