Fix fatal bug in wxGetWindowFromHWND() for radio buttons.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 30 Oct 2010 23:50:39 +0000 (23:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 30 Oct 2010 23:50:39 +0000 (23:50 +0000)
commit7ee21e3a3dd028502ef81f832a24a049a0734f2b
tree172c951dcac686d96be5c966ad930a463e3f378e
parenta16e51b56ac3c46af2f2f7630c8e71b30c2b374d
Fix fatal bug in wxGetWindowFromHWND() for radio buttons.

wxGetWindowFromHWND() could crash if it was called for a HWND of a radio
button which was not created by wxWidgets because it blindly dereferenced the
user data associated with the button expecting it to be a pointer to
wxRadioBox and crashed if it was something different. And this actually
happened when using the standard Windows printing dialog which can contain
radio buttons which obviously used their user data field for their own
purposes.

Fix this by maintaining a global hash map with radio buttons HWNDs as keys and
radio boxes as values. This ensures that we can always safely check whether
the given HWND is a radio button in one of our radio boxes or not.

Also change wxSpinCtrl which already did something similar in a different way
(using an array instead or a more efficient hash map) for consistency.

Closes #12083.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65957 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
include/wx/msw/radiobox.h
include/wx/msw/spinctrl.h
src/msw/radiobox.cpp
src/msw/spinctrl.cpp
src/msw/window.cpp