From 78a054f6677cfeaa8a1f78c8de4507ea50af379c Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Mon, 18 Jul 2005 13:43:42 +0000 Subject: [PATCH] Code simplification and warning fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34882 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/dib.cpp | 2 +- src/msw/utils.cpp | 47 ++++++++++++----------------------------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index f56dae0b1f..66ebda4954 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -634,7 +634,7 @@ wxPalette *wxDIB::CreatePalette() const // and the colour table wxCharBuffer rgb(sizeof(RGBQUAD) * biClrUsed); RGBQUAD *pRGB = (RGBQUAD*)rgb.data(); - SelectInHDC(hDC, m_handle); + SelectInHDC selectHandle(hDC, m_handle); ::GetDIBColorTable(hDC, 0, biClrUsed, pRGB); for ( DWORD i = 0; i < biClrUsed; i++, pRGB++ ) { diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index ead9e70d1c..977ae5d5c3 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -806,9 +806,11 @@ int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags) return 0; } -HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ; -BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ; -BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ; +typedef HANDLE (WINAPI *CreateToolhelp32Snapshot_t)(DWORD,DWORD); +typedef BOOL (WINAPI *Process32_t)(HANDLE,LPPROCESSENTRY32); + +CreateToolhelp32Snapshot_t lpfCreateToolhelp32Snapshot; +Process32_t lpfProcess32First, lpfProcess32Next; static void InitToolHelp32() { @@ -823,9 +825,7 @@ static void InitToolHelp32() lpfProcess32First = NULL; lpfProcess32Next = NULL; - HINSTANCE hInstLib = LoadLibrary( wxT("Kernel32.DLL") ) ; - if( hInstLib == NULL ) - return ; + wxDynamicLibrary dllKernel(_T("kernel32.dll"), wxDL_VERBATIM); // Get procedure addresses. // We are linking to these functions of Kernel32 @@ -833,37 +833,14 @@ static void InitToolHelp32() // this code would fail to load under Windows NT, // which does not have the Toolhelp32 // functions in the Kernel 32. - lpfCreateToolhelp32Snapshot= - (HANDLE(WINAPI *)(DWORD,DWORD)) - GetProcAddress( hInstLib, -#ifdef __WXWINCE__ - wxT("CreateToolhelp32Snapshot") -#else - "CreateToolhelp32Snapshot" -#endif - ) ; + lpfCreateToolhelp32Snapshot = + (CreateToolhelp32Snapshot_t)dllKernel.RawGetSymbol(_T("CreateToolhelp32Snapshot")); - lpfProcess32First= - (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) - GetProcAddress( hInstLib, -#ifdef __WXWINCE__ - wxT("Process32First") -#else - "Process32First" -#endif - ) ; - - lpfProcess32Next= - (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) - GetProcAddress( hInstLib, -#ifdef __WXWINCE__ - wxT("Process32Next") -#else - "Process32Next" -#endif - ) ; + lpfProcess32First = + (Process32_t)dllKernel.RawGetSymbol(_T("Process32First")); - FreeLibrary( hInstLib ) ; + lpfProcess32Next = + (Process32_t)dllKernel.RawGetSymbol(_T("Process32Next")); } // By John Skiff -- 2.45.2