From fe42ab1d7bf89e823e55903ce449eb90ea195ee2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 25 Apr 2010 12:07:30 +0000 Subject: [PATCH] Declare various WXH* handles compatibly with SDK. 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 | 49 ++++++++++++++++++++++------------------ include/wx/msw/private.h | 6 ----- src/msw/dlmsw.cpp | 2 +- src/msw/toolbar.cpp | 2 +- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 4a8967ba85..a73801290c 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -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; diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 9683257776..23da42791b 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -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)); -} - // 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. diff --git a/src/msw/dlmsw.cpp b/src/msw/dlmsw.cpp index ea04a1ae19..f0f4d43a5c 100644 --- a/src/msw/dlmsw.cpp +++ b/src/msw/dlmsw.cpp @@ -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 diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index ce1595afa9..e0a51a13c0 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1807,7 +1807,7 @@ WXHBRUSH wxToolBar::MSWGetToolbarBgBrush() wxBrush * const brush = wxTheBrushList->FindOrCreateBrush(colBg); - return brush ? brush->GetResourceHandle() : 0; + return brush ? static_cast(brush->GetResourceHandle()) : 0; } WXHBRUSH wxToolBar::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child) -- 2.45.2