Closed leviwilson closed 11 years ago
Yep, that sounds about right. I looked into it some months back and never could figure out why it was always returning 0. The MsUia adapter should be good to go though if you don't have a particular need to use the Win32 one.
I don't have a problem using MsUia
. Wanted to make sure I wasn't crazy that the specs were not passing :-) This post talks about the problem that I'm seeing as well. I'll keep digging to see if there's an alternative way to get this using Win32
.
That post also supposedly found a solution and posted it. I'll have to try it out later unless you want to beat me to it. I've got a few deadlines that will keep me from doing it for about a week otherwise. Thanks for the research.
Yeah, it looked like the solution was to go through IAccessible
, which it looks like it is already using. I'll poke around some more.
I have to chime in by saying that i have investigated this problem too in the past and couldn't figure out the reason behind it. It would be awesome if we could solve this problem at last!
I messed around with it a lot last night but to no avail. I added debug messages to IAccessibleDLL.dll
to see what was going on, but could not gather info about the checked state :-( The focus would be returned in the get_accState
result, but not the STATE_SYSTEM_CHECKED
flag.
I noticed that the HMODULE
is not being freed and neither is the IAccessible *
in that method, but fixing that had no effect (not that I thought it would).
__declspec( dllexport ) long get_button_state(HWND buttonHwnd) {
HMODULE hModule = LoadLibraryA("oleacc.dll");
LPFNACCESSIBLEOBJECTFROMWINDOW lpfnAccessibleObjectFromWindow = (LPFNACCESSIBLEOBJECTFROMWINDOW)GetProcAddress(hModule, "AccessibleObjectFromWindow");
IAccessible *pIAccessible ;
HRESULT hr = lpfnAccessibleObjectFromWindow(buttonHwnd, OBJID_CLIENT, IID_IAccessible, (void**)&pIAccessible) ;
VARIANT varChildId;
VariantInit(&varChildId);
varChildId.vt = VT_I4;
varChildId.lVal = CHILDID_SELF ;
VARIANT varState;
pIAccessible->get_accState(varChildId, &varState);
FreeLibrary(hModule);
pIAccessible->Release();
return varState.lVal;
}
I was going to poke around to see if building the WindowsForms.exe
with a different .NET platform would make a difference or maybe changing a property of the checkbox would help.
Changing the FlatStyle property of the CheckBox
control to System
fixed the spec. I had to do the same thing for the RadioButton
as well. Using FlatStyle.System
allows the operating system to handle the drawing of the control. I'm guessing in this instance, the .NET CheckBox control does not subclass the default control, so it behaves as expected?
I've issued a pull request for this.
Closed by @leviwilson pull request. Awesome discovery!
I've pulled the latest sources and am running them on Windows 7. It looks like everything that uses
ButtonHelper.set?
is failing asBM_GETSTATE
is always returning0
(according to Spy). Here is my output fromrake
(only the fail information):