Code simplification and warning fixes.
authorWłodzimierz Skiba <abx@abx.art.pl>
Mon, 18 Jul 2005 13:43:42 +0000 (13:43 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Mon, 18 Jul 2005 13:43:42 +0000 (13:43 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34882 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/dib.cpp
src/msw/utils.cpp

index f56dae0b1fb92b4feabbe8e29345ec166fcf0222..66ebda4954c55bc634f3b31f25d036aa8af2fdc9 100644 (file)
@@ -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++ )
     {
index ead9e70d1c0fa56b25d7ff099aa61b0883e6ce2a..977ae5d5c39f29e5baeea2c28bf3a710c2b2be8b 100644 (file)
@@ -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