Correct sending of wxW event from wxChoice on MS Smartphone.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-03-13 15:32:30 +00:00
parent 0bb0e26c0c
commit 01d2bf4def
3 changed files with 59 additions and 2 deletions

View File

@@ -98,6 +98,11 @@ public:
// get the subclassed window proc of the buddy list of choices
WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
// return the choice object whose buddy is the given window or NULL
static wxChoice *GetChoiceForListBox(WXHWND hwndBuddy);
virtual bool MSWCommand(WXUINT param, WXWORD id);
protected:
virtual void DoSetItemClientData( int n, void* clientData );
virtual void* DoGetItemClientData( int n ) const;

View File

@@ -109,6 +109,22 @@ LRESULT APIENTRY _EXPORT wxBuddyChoiceWndProc(HWND hwnd,
hwnd, message, wParam, lParam);
}
wxChoice *wxChoice::GetChoiceForListBox(WXHWND hwndBuddy)
{
wxChoice *choice = (wxChoice *)wxGetWindowUserData((HWND)hwndBuddy);
int i = ms_allChoiceSpins.Index(choice);
if ( i == wxNOT_FOUND )
return NULL;
// sanity check
wxASSERT_MSG( choice->m_hwndBuddy == hwndBuddy,
_T("wxChoice has incorrect buddy HWND!") );
return choice;
}
// ----------------------------------------------------------------------------
// creation
// ----------------------------------------------------------------------------
@@ -284,9 +300,36 @@ WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const
if ( style & wxCB_SORT )
msStyle |= LBS_SORT;
msStyle |= LBS_NOTIFY;
return msStyle;
}
bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
if ( param != LBN_SELCHANGE)
{
// "selection changed" is the only event we're after
return false;
}
int n = GetSelection();
if (n > -1)
{
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId);
event.SetInt(n);
event.SetEventObject(this);
event.SetString(GetStringSelection());
if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );
ProcessCommand(event);
}
return true;
}
wxChoice::~wxChoice()
{
Free();

View File

@@ -4269,18 +4269,27 @@ bool wxWindowMSW::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
return GetEventHandler()->ProcessEvent(event);
}
#if wxUSE_SPINCTRL && !defined(__WXUNIVERSAL__)
else
{
#if wxUSE_SPINCTRL && !defined(__WXUNIVERSAL__)
// the text ctrl which is logically part of wxSpinCtrl sends WM_COMMAND
// notifications to its parent which we want to reflect back to
// wxSpinCtrl
wxSpinCtrl *spin = wxSpinCtrl::GetSpinForTextCtrl(control);
if ( spin && spin->ProcessTextCommand(cmd, id) )
return true;
}
#endif // wxUSE_SPINCTRL
#if wxUSE_CHOICE && defined(__SMARTPHONE__)
// the listbox ctrl which is logically part of wxChoice sends WM_COMMAND
// notifications to its parent which we want to reflect back to
// wxChoice
wxChoice *choice = wxChoice::GetChoiceForListBox(control);
if ( choice && choice->MSWCommand(cmd, id) )
return true;
#endif
}
return false;
}