title: Check if a Winform CheckBox is checked through WINAPI only
body: <p>my problem goes like this :
  I need to check if a winform checkbox from a different program is checked or not by WINAPI only. </p>
  
  <p>here how I catch the underlyined C# HWND: 
  first I get all the HWND's of the desktop with EnumWindows and then EnumChildWindows , then I go on each one and with GetWindowText compares my wanted text to the window text and if there is a match - I return it. </p>
  
  <p>just to make things clear - I can catch the underlying HWND. if I print its text and the class name it is the winform checkbox wanted.</p>
  
  <p>now, the checkbox I want to check has WindowsForm.10.BUTTON.app.0.33c0d9d5 class name. with this function I ask it if its a valid checkbox:</p>
  
  <pre><code>bool isValid(){
      if(!handleToControl) return false;
      LONG_PTR styles = GetWindowLongPtr(handleToControl, GWL_STYLE);
      bool isCheckBox = ((styles &amp; BS_AUTO3STATE) == BS_AUTO3STATE);
      isCheckBox = isCheckBox || ((styles &amp; BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX);
      isCheckBox = isCheckBox || ((styles &amp; BS_CHECKBOX) == BS_CHECKBOX);
      return isCheckBox;
  }
  </code></pre>
  
  <p>now, the function does work (I checked it on many native checkboxes and also winform checkboxes) and it can validate if it's a valid checkbox or not (including the checkbox I want to check)</p>
  
  <p>then , I try to see if the winform checkbox is checked or not with this function:</p>
  
  <pre><code>bool isChecked(){
      LRESULT _isChecked = SendMessage(handleToControl, BM_GETCHECK, 0, 0);
      bool ic = !(_isChecked == BST_UNCHECKED);
      if (ic)
          return ic;
      ic = ((Button_GetState(handleToControl) &amp; BST_CHECKED) == BST_CHECKED);
      if (ic)
          return ic;
  
      return false;
  }
  </code></pre>
  
  <p>but I fail miserably. can someone see what's wrong with my idea / code or suggest a different solution?</p>