]> git.saurik.com Git - wxWidgets.git/commitdiff
Declare various WXH* handles compatibly with SDK.
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 25 Apr 2010 12:07:30 +0000 (12:07 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 25 Apr 2010 12:07:30 +0000 (12:07 +0000)
It is no longer necessary to cast between e.g. HINSTANCE and
WXHINSTANCE, they are now declared as the same type (without including
Windows SDK header).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64138 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h
include/wx/msw/private.h
src/msw/dlmsw.cpp
src/msw/toolbar.cpp

index 4a8967ba85b630b32dbae3e4eb67ec7ab425681c..a73801290c08d47e18bac7834d20983ce1b776a8 100644 (file)
@@ -2904,29 +2904,34 @@ typedef void *          WXRECTANGLEPTR;
 /* ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port */
 #if defined(__WIN32__)
 
-/*  the keywords needed for WinMain() declaration */
-#ifndef WXFAR
-#    define WXFAR
-#endif
-
 /*  Stand-ins for Windows types to avoid #including all of windows.h */
-typedef void *          WXHWND;
-typedef void *          WXHANDLE;
-typedef void *          WXHICON;
-typedef void *          WXHFONT;
-typedef void *          WXHMENU;
-typedef void *          WXHPEN;
-typedef void *          WXHBRUSH;
-typedef void *          WXHPALETTE;
-typedef void *          WXHCURSOR;
-typedef void *          WXHRGN;
-typedef void *          WXRECTPTR;
-typedef void *          WXHACCEL;
-typedef void WXFAR  *   WXHINSTANCE;
-typedef void *          WXHBITMAP;
-typedef void *          WXHIMAGELIST;
-typedef void *          WXHGLOBAL;
-typedef void *          WXHDC;
+
+#ifndef NO_STRICT
+    #define WX_MSW_DECLARE_HANDLE(type) typedef struct type##__ * WX##type
+#else
+    #define WX_MSW_DECLARE_HANDLE(type) typedef void * WX##type
+#endif
+
+typedef void* WXHANDLE;
+WX_MSW_DECLARE_HANDLE(HWND);
+WX_MSW_DECLARE_HANDLE(HICON);
+WX_MSW_DECLARE_HANDLE(HFONT);
+WX_MSW_DECLARE_HANDLE(HMENU);
+WX_MSW_DECLARE_HANDLE(HPEN);
+WX_MSW_DECLARE_HANDLE(HBRUSH);
+WX_MSW_DECLARE_HANDLE(HPALETTE);
+WX_MSW_DECLARE_HANDLE(HCURSOR);
+WX_MSW_DECLARE_HANDLE(HRGN);
+WX_MSW_DECLARE_HANDLE(RECTPTR);
+WX_MSW_DECLARE_HANDLE(HACCEL);
+WX_MSW_DECLARE_HANDLE(HINSTANCE);
+WX_MSW_DECLARE_HANDLE(HBITMAP);
+WX_MSW_DECLARE_HANDLE(HIMAGELIST);
+WX_MSW_DECLARE_HANDLE(HGLOBAL);
+WX_MSW_DECLARE_HANDLE(HDC);
+
+#undef WX_MSW_DECLARE_HANDLE
+
 typedef unsigned int    WXUINT;
 typedef unsigned long   WXDWORD;
 typedef unsigned short  WXWORD;
index 9683257776a411de2f4880065737114db3ef30e7..23da42791beee845bbbd0fe960f3df3886b351c8 100644 (file)
@@ -973,12 +973,6 @@ inline long wxSetWindowExStyle(const wxWindowMSW *win, long style)
 // and returns either that window if it does or NULL otherwise
 extern WXDLLIMPEXP_CORE wxWindow* wxFindWinFromHandle(HWND hwnd);
 
-// without STRICT WXHWND is the same as HWND anyhow
-inline wxWindow* wxFindWinFromHandle(WXHWND hWnd)
-{
-    return wxFindWinFromHandle(static_cast<HWND>(hWnd));
-}
-
 // find the window for HWND which is part of some wxWindow, i.e. unlike
 // wxFindWinFromHandle() above it will also work for "sub controls" of a
 // wxWindow.
index ea04a1ae1937443197707fd1673fe76783a1b9fa..f0f4d43a5c4ea6bb8b7b6417b54f3b502f094792 100644 (file)
@@ -296,7 +296,7 @@ wxDynamicLibraryDetailsArray wxDynamicLibrary::ListLoaded()
 }
 
 /* static */
-HMODULE wxDynamicLibrary::MSWGetModuleHandle(const char *name, void *addr)
+WXHINSTANCE wxDynamicLibrary::MSWGetModuleHandle(const char *name, void *addr)
 {
     // we want to use GetModuleHandleEx() instead of usual GetModuleHandle()
     // because the former works correctly for comctl32.dll while the latter
index ce1595afa9eea4194631e58947dc876580437165..e0a51a13c004b739ebccc8c8e2d4b69ade9df815 100644 (file)
@@ -1807,7 +1807,7 @@ WXHBRUSH wxToolBar::MSWGetToolbarBgBrush()
     wxBrush * const
         brush = wxTheBrushList->FindOrCreateBrush(colBg);
 
-    return brush ? brush->GetResourceHandle() : 0;
+    return brush ? static_cast<WXHBRUSH>(brush->GetResourceHandle()) : 0;
 }
 
 WXHBRUSH wxToolBar::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)