]> git.saurik.com Git - wxWidgets.git/commitdiff
replaced wxList for storing HWND <-> wxWindow with wxHashTable
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 2 Nov 2001 00:44:19 +0000 (00:44 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 2 Nov 2001 00:44:19 +0000 (00:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/window.h
src/msw/app.cpp
src/msw/window.cpp

index 4e9bc75585d0aba0aeedccc59e5190792c3b2c0e..790c282c83d9ac6b0041ecd1a31683c4821ca4fe 100644 (file)
 // 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
 // ---------------------------------------------------------------------------
index 45250cfe163dcfd64d162d2a6ee82c2b493ca856..31e9ddfc8a7ff6889490e45e18f6a99903ce41cf 100644 (file)
 // ---------------------------------------------------------------------------
 
 extern wxChar *wxBuffer;
-extern wxList *wxWinHandleList;
 extern wxList WXDLLEXPORT wxPendingDelete;
 #ifndef __WXMICROWIN__
 extern void wxSetKeyboardHook(bool doIt);
@@ -295,7 +294,7 @@ bool wxApp::Initialize()
     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.
@@ -701,8 +700,7 @@ void wxApp::CleanUp()
     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.
index dc8a9563588b2c9bfc6f6f28a06343acb8bf6fd9..a73e4bad73c7f0fb4b599a647c0c462928fe23ac 100644 (file)
     #endif
 #endif
 
-
 // ---------------------------------------------------------------------------
 // global variables
 // ---------------------------------------------------------------------------
@@ -2594,14 +2593,11 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
 // 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)
@@ -2622,13 +2618,13 @@ 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());
 }
 
 // ----------------------------------------------------------------------------