// a better solution should be found later...
#define wxUSE_MOUSEEVENT_HACK 0
+#include "wx/hash.h"
+
+// pseudo-template HWND <-> wxWindow hash table
+WX_DECLARE_HASH(wxWindow, wxWindowList, wxWinHashTable);
+
+extern wxWinHashTable *wxWinHandleHash;
+
// ---------------------------------------------------------------------------
// constants
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
extern wxChar *wxBuffer;
-extern wxList *wxWinHandleList;
extern wxList WXDLLEXPORT wxPendingDelete;
#ifndef __WXMICROWIN__
extern void wxSetKeyboardHook(bool doIt);
wxRegisterPenWin();
#endif
- wxWinHandleList = new wxList(wxKEY_INTEGER);
+ wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
// This is to foil optimizations in Visual C++ that throw out dummy.obj.
// PLEASE DO NOT ALTER THIS.
Ctl3dUnregister(wxhInstance);
#endif
- if (wxWinHandleList)
- delete wxWinHandleList;
+ delete wxWinHandleHash;
// GL: I'm annoyed ... I don't know where to put this and I don't want to
// create a module for that as it's part of the core.
#endif
#endif
-
// ---------------------------------------------------------------------------
// global variables
// ---------------------------------------------------------------------------
// wxWindow <-> HWND map
// ----------------------------------------------------------------------------
-wxList *wxWinHandleList = NULL;
+wxWinHashTable *wxWinHandleHash = NULL;
wxWindow *wxFindWinFromHandle(WXHWND hWnd)
{
- wxNode *node = wxWinHandleList->Find((long)hWnd);
- if ( !node )
- return NULL;
- return (wxWindow *)node->Data();
+ return wxWinHandleHash->Get((long)hWnd);
}
void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win)
#endif // __WXDEBUG__
if (!oldWin)
{
- wxWinHandleList->Append((long)hWnd, win);
+ wxWinHandleHash->Put((long)hWnd, win);
}
}
void wxRemoveHandleAssociation(wxWindowMSW *win)
{
- wxWinHandleList->DeleteObject(win);
+ wxWinHandleHash->Delete((long)win->GetHWND());
}
// ----------------------------------------------------------------------------