From 6d99499879c434f212f4c02e751f730eca610983 Mon Sep 17 00:00:00 2001
From: Kirill Volinsky <mataes2007@gmail.com>
Date: Sun, 24 Jun 2012 12:33:43 +0000
Subject: Chat: plusified

git-svn-id: http://svn.miranda-ng.org/main/trunk@602 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/Chat/chat.h                  | 21 +++++++-
 plugins/Chat/chat_10.vcxproj         | 36 +++++++-------
 plugins/Chat/chat_10.vcxproj.filters | 22 ++++-----
 plugins/Chat/clist.cpp               |  2 -
 plugins/Chat/colorchooser.cpp        |  8 +--
 plugins/Chat/log.cpp                 |  6 +--
 plugins/Chat/main.cpp                | 95 ++++++++++++++----------------------
 plugins/Chat/manager.cpp             |  6 +--
 plugins/Chat/message.cpp             |  6 +--
 plugins/Chat/options.cpp             | 15 +++---
 plugins/Chat/richutil.cpp            |  6 +--
 plugins/Chat/services.cpp            |  3 +-
 plugins/Chat/tools.cpp               |  9 ++--
 plugins/Chat/window.cpp              | 18 +++----
 14 files changed, 119 insertions(+), 134 deletions(-)

(limited to 'plugins/Chat')

diff --git a/plugins/Chat/chat.h b/plugins/Chat/chat.h
index 27e325fd7b..ca73960017 100644
--- a/plugins/Chat/chat.h
+++ b/plugins/Chat/chat.h
@@ -156,6 +156,8 @@ typedef struct  {
 	GETEVENTFUNC pfnAddEvent;
 }GCPTRS;
 
+extern HINSTANCE g_hInst;
+
 //structs
 
 typedef struct  MODULE_INFO_TYPE
@@ -312,12 +314,27 @@ typedef struct
 }
 	LOGSTREAMDATA;
 
-struct CREOleCallback
+struct CREOleCallback : public IRichEditOleCallback
 {
-	IRichEditOleCallbackVtbl *lpVtbl;
+	CREOleCallback() : refCount(0) {}
 	unsigned refCount;
 	IStorage *pictStg;
 	int nextStgId;
+
+ 	STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * lplpObj); 
+	STDMETHOD_(ULONG,AddRef) (THIS); 
+	STDMETHOD_(ULONG,Release) (THIS); 
+
+	STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode); 
+	STDMETHOD(GetNewStorage) (LPSTORAGE FAR * lplpstg); 
+	STDMETHOD(GetInPlaceContext) (LPOLEINPLACEFRAME FAR * lplpFrame, LPOLEINPLACEUIWINDOW FAR * lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo); 
+	STDMETHOD(ShowContainerUI) (BOOL fShow); 
+	STDMETHOD(QueryInsertObject) (LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp); 
+	STDMETHOD(DeleteObject) (LPOLEOBJECT lpoleobj); 
+	STDMETHOD(QueryAcceptData) (LPDATAOBJECT lpdataobj, CLIPFORMAT FAR * lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict); 
+	STDMETHOD(GetClipboardData) (CHARRANGE FAR * lpchrg, DWORD reco, LPDATAOBJECT FAR * lplpdataobj); 
+	STDMETHOD(GetDragDropEffect) (BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect); 
+	STDMETHOD(GetContextMenu) (WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE FAR * lpchrg, HMENU FAR * lphmenu) ; 
 };
 
 struct GlobalLogSettings_t {
diff --git a/plugins/Chat/chat_10.vcxproj b/plugins/Chat/chat_10.vcxproj
index 6c13364f13..1e9a6828b6 100644
--- a/plugins/Chat/chat_10.vcxproj
+++ b/plugins/Chat/chat_10.vcxproj
@@ -73,14 +73,13 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
-      <CompileAs>CompileAsC</CompileAs>
       <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <PrecompiledHeader>Use</PrecompiledHeader>
       <PrecompiledHeaderFile>chat.h</PrecompiledHeaderFile>
@@ -106,13 +105,12 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <WarningLevel>Level3</WarningLevel>
-      <CompileAs>CompileAsC</CompileAs>
       <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <PrecompiledHeader>Use</PrecompiledHeader>
       <PrecompiledHeaderFile>chat.h</PrecompiledHeaderFile>
@@ -138,16 +136,16 @@
     <ClCompile>
       <Optimization>Full</Optimization>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
       <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
       <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <ExceptionHandling>false</ExceptionHandling>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <FloatingPointModel>Fast</FloatingPointModel>
       <WarningLevel>Level3</WarningLevel>
-      <CompileAs>CompileAsC</CompileAs>
       <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <PrecompiledHeader>Use</PrecompiledHeader>
       <PrecompiledHeaderFile>chat.h</PrecompiledHeaderFile>
@@ -175,16 +173,16 @@
     <ClCompile>
       <Optimization>Full</Optimization>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
       <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
       <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;CHAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <ExceptionHandling>false</ExceptionHandling>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <FloatingPointModel>Fast</FloatingPointModel>
       <WarningLevel>Level3</WarningLevel>
-      <CompileAs>CompileAsC</CompileAs>
       <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <PrecompiledHeader>Use</PrecompiledHeader>
       <PrecompiledHeaderFile>chat.h</PrecompiledHeaderFile>
@@ -209,21 +207,21 @@
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="clist.c" />
-    <ClCompile Include="colorchooser.c" />
-    <ClCompile Include="log.c" />
-    <ClCompile Include="main.c">
+    <ClCompile Include="clist.cpp" />
+    <ClCompile Include="colorchooser.cpp" />
+    <ClCompile Include="log.cpp" />
+    <ClCompile Include="main.cpp">
       <PrecompiledHeader>Create</PrecompiledHeader>
     </ClCompile>
-    <ClCompile Include="manager.c" />
-    <ClCompile Include="message.c" />
-    <ClCompile Include="options.c" />
-    <ClCompile Include="richutil.c">
+    <ClCompile Include="manager.cpp" />
+    <ClCompile Include="message.cpp" />
+    <ClCompile Include="options.cpp" />
+    <ClCompile Include="richutil.cpp">
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
     </ClCompile>
-    <ClCompile Include="services.c" />
-    <ClCompile Include="tools.c" />
-    <ClCompile Include="window.c" />
+    <ClCompile Include="services.cpp" />
+    <ClCompile Include="tools.cpp" />
+    <ClCompile Include="window.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="chat.h" />
diff --git a/plugins/Chat/chat_10.vcxproj.filters b/plugins/Chat/chat_10.vcxproj.filters
index 0ddf24be60..7d33c0fb9f 100644
--- a/plugins/Chat/chat_10.vcxproj.filters
+++ b/plugins/Chat/chat_10.vcxproj.filters
@@ -19,37 +19,37 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="clist.c">
+    <ClCompile Include="clist.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="colorchooser.c">
+    <ClCompile Include="colorchooser.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="log.c">
+    <ClCompile Include="log.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="main.c">
+    <ClCompile Include="main.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="manager.c">
+    <ClCompile Include="manager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="message.c">
+    <ClCompile Include="message.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="options.c">
+    <ClCompile Include="options.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="richutil.c">
+    <ClCompile Include="richutil.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="services.c">
+    <ClCompile Include="services.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="tools.c">
+    <ClCompile Include="tools.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="window.c">
+    <ClCompile Include="window.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
diff --git a/plugins/Chat/clist.cpp b/plugins/Chat/clist.cpp
index 87d544097e..df60f1de3a 100644
--- a/plugins/Chat/clist.cpp
+++ b/plugins/Chat/clist.cpp
@@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "chat.h"
 
-extern HINSTANCE		g_hInst;
-
 extern HANDLE hJoinMenuItem, hLeaveMenuItem;
 
 HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
diff --git a/plugins/Chat/colorchooser.cpp b/plugins/Chat/colorchooser.cpp
index 2402b8c399..0d2642165f 100644
--- a/plugins/Chat/colorchooser.cpp
+++ b/plugins/Chat/colorchooser.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 static int CalculateCoordinatesToButton(COLORCHOOSER * pCC, POINT pt)
 {
-	int iSquareRoot = (int)sqrt(pCC->pModule->nColorCount);
+	int iSquareRoot = (int)sqrt((double)pCC->pModule->nColorCount);
 	int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount?iSquareRoot+1:iSquareRoot;
 
 	int col = pt.x / 25;
@@ -42,7 +42,7 @@ static int CalculateCoordinatesToButton(COLORCHOOSER * pCC, POINT pt)
 static RECT CalculateButtonToCoordinates(COLORCHOOSER * pCC, int buttonPosition)
 {
 	RECT pt;
-	int iSquareRoot = (int)sqrt(pCC->pModule->nColorCount);
+	int iSquareRoot = (int)sqrt((double)pCC->pModule->nColorCount);
 	int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount?iSquareRoot+1:iSquareRoot;
 
 	int row = buttonPosition / nCols;
@@ -79,7 +79,7 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L
 			iCurrentHotTrack = -2;
 			bChoosing = FALSE;
 
-			iSquareRoot = (int)sqrt(pCC->pModule->nColorCount);
+			iSquareRoot = (int)sqrt((double)pCC->pModule->nColorCount);
 
 			iColumns = iSquareRoot * iSquareRoot == pCC->pModule->nColorCount?iSquareRoot:iSquareRoot+1;
 			iRows = iSquareRoot;
@@ -234,7 +234,7 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L
 				rc.bottom = iThisRow * 20- 3 + 20 ;
 				rc.right = iThisColumn * 25-3 ;
 
-				FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH));
+				FillRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
 
 				hbr = CreateSolidBrush(pCC->pModule->crColors[i]);
 
diff --git a/plugins/Chat/log.cpp b/plugins/Chat/log.cpp
index 665ab8939c..86b2f41b0a 100644
--- a/plugins/Chat/log.cpp
+++ b/plugins/Chat/log.cpp
@@ -681,7 +681,7 @@ void LoadMsgLogBitmaps(void)
 	for (i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
 		hIcon = hIcons[i];
 		pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2);
-		rtfHeaderSize = sprintf(pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
+		rtfHeaderSize = sprintf((char *)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
 		hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
 		FillRect(hdcMem, &rc, hBkgBrush);
 		DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL);
@@ -690,9 +690,9 @@ void LoadMsgLogBitmaps(void)
 		{
 			int n;
 			for (n = 0; n < sizeof(BITMAPINFOHEADER); n++)
-				sprintf(pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]);
+				sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]);
 			for (n = 0; n < widthBytes * bih.biHeight; n += 4)
-				sprintf(pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]);
+				sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]);
 		}
 		logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1;
 		pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}';
diff --git a/plugins/Chat/main.cpp b/plugins/Chat/main.cpp
index 41ad270461..e9c344ab61 100644
--- a/plugins/Chat/main.cpp
+++ b/plugins/Chat/main.cpp
@@ -54,8 +54,6 @@ const CLSID IID_IRichEditOleCallback = { 0x00020D03, 0x00, 0x00, { 0xC0, 0x00, 0
 
 struct GlobalLogSettings_t g_Settings;
 
-static void InitREOleCallback(void);
-
 PLUGININFOEX pluginInfo = {
 	sizeof(PLUGININFOEX),
 	"Chat",
@@ -76,18 +74,18 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
 	return TRUE;
 }
 
-__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
 {
 	return &pluginInfo;
 }
 
 static const MUUID interfaces[] = {MIID_CHAT, MIID_LAST};
-__declspec(dllexport) const MUUID * MirandaPluginInterfaces(void)
+extern "C" __declspec(dllexport) const MUUID * MirandaPluginInterfaces(void)
 {
 	return interfaces;
 }
 
-int __declspec(dllexport) Load(PLUGINLINK *link)
+extern "C" __declspec(dllexport) int Load(PLUGINLINK *link)
 {
 	BOOL bFlag = FALSE;
 	HINSTANCE hDll;
@@ -132,7 +130,6 @@ int __declspec(dllexport) Load(PLUGINLINK *link)
 	UpgradeCheck();
 
 	g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
-	InitREOleCallback();
 	HookEvents();
 	CreateServiceFunctions();
 	CreateHookableEvents();
@@ -141,7 +138,7 @@ int __declspec(dllexport) Load(PLUGINLINK *link)
 	return 0;
 }
 
-int __declspec(dllexport) Unload(void)
+extern "C" __declspec(dllexport) int Unload(void)
 {
 	DBWriteContactSettingWord(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
 	DBWriteContactSettingWord(NULL, "Chat", "SplitterY", (WORD)g_Settings.iSplitterY);
@@ -237,8 +234,8 @@ void LoadIcons(void)
 	ImageList_AddIcon(hIconsList,LoadSkinnedIcon( SKINICON_EVENT_MESSAGE));
 	ImageList_AddIcon(hIconsList,LoadIconEx( "overlay", FALSE ));
 	ImageList_SetOverlayImage(hIconsList, 1, 1);
-	ImageList_AddIcon(hImageList,LoadImage(g_hInst,MAKEINTRESOURCE(IDI_BLANK),IMAGE_ICON,0,0,0));
-	ImageList_AddIcon(hImageList,LoadImage(g_hInst,MAKEINTRESOURCE(IDI_BLANK),IMAGE_ICON,0,0,0));
+	ImageList_AddIcon(hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
+	ImageList_AddIcon(hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
 }
 
 void FreeIcons(void)
@@ -248,110 +245,90 @@ void FreeIcons(void)
 	ImageList_Destroy(hIconsList);
 }
 
-static IRichEditOleCallbackVtbl reOleCallbackVtbl;
-struct CREOleCallback reOleCallback;
+CREOleCallback reOleCallback;
 
-static STDMETHODIMP_(ULONG) CREOleCallback_QueryInterface(struct CREOleCallback *lpThis, REFIID riid, LPVOID * ppvObj)
+STDMETHODIMP CREOleCallback::QueryInterface(REFIID riid, LPVOID * ppvObj)
 {
-	if (IsEqualIID(riid, &IID_IRichEditOleCallback)) {
-		*ppvObj = lpThis;
-		lpThis->lpVtbl->AddRef((IRichEditOleCallback *) lpThis);
+	if (IsEqualIID(riid, IID_IRichEditOleCallback)) {
+		*ppvObj = this;
+		AddRef();
 		return S_OK;
 	}
 	*ppvObj = NULL;
 	return E_NOINTERFACE;
 }
 
-static STDMETHODIMP_(ULONG) CREOleCallback_AddRef(struct CREOleCallback *lpThis)
+STDMETHODIMP_(ULONG) CREOleCallback::AddRef()
 {
-	if (lpThis->refCount == 0) {
-		if (S_OK != StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &lpThis->pictStg))
-			lpThis->pictStg = NULL;
-		lpThis->nextStgId = 0;
+	if (refCount == 0) {
+		if (S_OK != StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &pictStg))
+			pictStg = NULL;
+		nextStgId = 0;
 	}
-	return ++lpThis->refCount;
+	return ++refCount;
 }
 
-static STDMETHODIMP_(ULONG) CREOleCallback_Release(struct CREOleCallback *lpThis)
+STDMETHODIMP_(ULONG) CREOleCallback::Release()
 {
-	if (--lpThis->refCount == 0) {
-		if (lpThis->pictStg)
-			lpThis->pictStg->lpVtbl->Release(lpThis->pictStg);
+	if (--refCount == 0) {
+		if (pictStg)
+			pictStg->Release();
 	}
-	return lpThis->refCount;
+	return refCount;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_ContextSensitiveHelp(struct CREOleCallback *lpThis, BOOL fEnterMode)
+STDMETHODIMP CREOleCallback::ContextSensitiveHelp(BOOL fEnterMode)
 {
 	return S_OK;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_DeleteObject(struct CREOleCallback *lpThis, LPOLEOBJECT lpoleobj)
+STDMETHODIMP CREOleCallback::DeleteObject(LPOLEOBJECT lpoleobj)
 {
 	return S_OK;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_GetClipboardData(struct CREOleCallback *lpThis, CHARRANGE * lpchrg, DWORD reco, LPDATAOBJECT * lplpdataobj)
+STDMETHODIMP CREOleCallback::GetClipboardData(CHARRANGE * lpchrg, DWORD reco, LPDATAOBJECT * lplpdataobj)
 {
 	return E_NOTIMPL;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_GetContextMenu(struct CREOleCallback *lpThis, WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE * lpchrg, HMENU * lphmenu)
+STDMETHODIMP CREOleCallback::GetContextMenu(WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE * lpchrg, HMENU * lphmenu)
 {
 	return E_INVALIDARG;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_GetDragDropEffect(struct CREOleCallback *lpThis, BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect)
+STDMETHODIMP CREOleCallback::GetDragDropEffect(BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect)
 {
 	return S_OK;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_GetInPlaceContext(struct CREOleCallback *lpThis, LPOLEINPLACEFRAME * lplpFrame, LPOLEINPLACEUIWINDOW * lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo)
+STDMETHODIMP CREOleCallback::GetInPlaceContext(LPOLEINPLACEFRAME * lplpFrame, LPOLEINPLACEUIWINDOW * lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo)
 {
 	return E_INVALIDARG;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_GetNewStorage(struct CREOleCallback *lpThis, LPSTORAGE * lplpstg)
+STDMETHODIMP CREOleCallback::GetNewStorage(LPSTORAGE * lplpstg)
 {
 	WCHAR szwName[64];
 	char szName[64];
-	wsprintfA(szName, "s%u", lpThis->nextStgId);
+	wsprintfA(szName, "s%u", nextStgId++);
 	MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, SIZEOF(szwName));
-	if (lpThis->pictStg == NULL)
+	if (pictStg == NULL)
 		return STG_E_MEDIUMFULL;
-	return lpThis->pictStg->lpVtbl->CreateStorage(lpThis->pictStg, szwName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
+	return pictStg->CreateStorage(szwName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_QueryAcceptData(struct CREOleCallback *lpThis, LPDATAOBJECT lpdataobj, CLIPFORMAT * lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict)
+STDMETHODIMP CREOleCallback::QueryAcceptData(LPDATAOBJECT lpdataobj, CLIPFORMAT * lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict)
 {
 	return S_OK;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_QueryInsertObject(struct CREOleCallback *lpThis, LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp)
+STDMETHODIMP CREOleCallback::QueryInsertObject(LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp)
 {
 	return S_OK;
 }
 
-static STDMETHODIMP_(HRESULT) CREOleCallback_ShowContainerUI(struct CREOleCallback *lpThis, BOOL fShow)
+STDMETHODIMP CREOleCallback::ShowContainerUI(BOOL fShow)
 {
 	return S_OK;
-}
-
-static void InitREOleCallback(void)
-{
-	reOleCallback.lpVtbl = &reOleCallbackVtbl;
-	reOleCallback.lpVtbl->AddRef = (ULONG(__stdcall *) (IRichEditOleCallback *)) CREOleCallback_AddRef;
-	reOleCallback.lpVtbl->Release = (ULONG(__stdcall *) (IRichEditOleCallback *)) CREOleCallback_Release;
-	reOleCallback.lpVtbl->QueryInterface = (ULONG(__stdcall *) (IRichEditOleCallback *, REFIID, PVOID *)) CREOleCallback_QueryInterface;
-	reOleCallback.lpVtbl->ContextSensitiveHelp = (HRESULT(__stdcall *) (IRichEditOleCallback *, BOOL)) CREOleCallback_ContextSensitiveHelp;
-	reOleCallback.lpVtbl->DeleteObject = (HRESULT(__stdcall *) (IRichEditOleCallback *, LPOLEOBJECT)) CREOleCallback_DeleteObject;
-	reOleCallback.lpVtbl->GetClipboardData = (HRESULT(__stdcall *) (IRichEditOleCallback *, CHARRANGE *, DWORD, LPDATAOBJECT *)) CREOleCallback_GetClipboardData;
-	reOleCallback.lpVtbl->GetContextMenu = (HRESULT(__stdcall *) (IRichEditOleCallback *, WORD, LPOLEOBJECT, CHARRANGE *, HMENU *)) CREOleCallback_GetContextMenu;
-	reOleCallback.lpVtbl->GetDragDropEffect = (HRESULT(__stdcall *) (IRichEditOleCallback *, BOOL, DWORD, LPDWORD)) CREOleCallback_GetDragDropEffect;
-	reOleCallback.lpVtbl->GetInPlaceContext = (HRESULT(__stdcall *) (IRichEditOleCallback *, LPOLEINPLACEFRAME *, LPOLEINPLACEUIWINDOW *, LPOLEINPLACEFRAMEINFO))CREOleCallback_GetInPlaceContext;
-	reOleCallback.lpVtbl->GetNewStorage = (HRESULT(__stdcall *) (IRichEditOleCallback *, LPSTORAGE *)) CREOleCallback_GetNewStorage;
-	reOleCallback.lpVtbl->QueryAcceptData = (HRESULT(__stdcall *) (IRichEditOleCallback *, LPDATAOBJECT, CLIPFORMAT *, DWORD, BOOL, HGLOBAL)) CREOleCallback_QueryAcceptData;
-	reOleCallback.lpVtbl->QueryInsertObject = (HRESULT(__stdcall *) (IRichEditOleCallback *, LPCLSID, LPSTORAGE, LONG)) CREOleCallback_QueryInsertObject;
-	reOleCallback.lpVtbl->ShowContainerUI = (HRESULT(__stdcall *) (IRichEditOleCallback *, BOOL)) CREOleCallback_ShowContainerUI;
-	reOleCallback.refCount = 0;
-}
+}
\ No newline at end of file
diff --git a/plugins/Chat/manager.cpp b/plugins/Chat/manager.cpp
index 82fb61ae7b..1b9ecd9421 100644
--- a/plugins/Chat/manager.cpp
+++ b/plugins/Chat/manager.cpp
@@ -807,7 +807,7 @@ void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewC
 	SESSION_INFO* pTemp = m_WndList;
 	while ( pTemp != NULL ) {
 		if ( lstrcmpi( pTemp->ptszID, pszID ) == 0 && lstrcmpiA( pTemp->pszModule, pszModule ) == 0) { // match
-			COMMAND_INFO *node = mir_alloc(sizeof(COMMAND_INFO));
+			COMMAND_INFO *node = (COMMAND_INFO *)mir_alloc(sizeof(COMMAND_INFO));
 			node->lpCommand = mir_strdup( lpNewCommand );
 			node->last = NULL; // always added at beginning!
 
@@ -935,7 +935,7 @@ char* SM_GetUsers(SESSION_INFO* si)
 	do {
 		int pLen = lstrlenA(p), nameLen = lstrlen(utemp->pszUID);
 		if ( pLen + nameLen + 2 > alloced )
-			p = mir_realloc( p, alloced += 4096 );
+			p = (char *)mir_realloc( p, alloced += 4096 );
 
 		WideCharToMultiByte( CP_ACP, 0, utemp->pszUID, -1, p + pLen, nameLen+1, 0, 0 );
 		lstrcpyA( p + pLen + nameLen, " " );
@@ -1441,7 +1441,7 @@ BOOL UM_SetStatusEx(USERINFO* pUserList, const TCHAR* pszText, int flags )
 			pTemp->iStatusEx = 0;
 
 		if ( pszText != NULL ) {
-			TCHAR* s = _tcsstr( pszText, pTemp->pszUID );
+			TCHAR* s = (TCHAR *)_tcsstr(pszText, pTemp->pszUID);
 			if ( s ) {
 				pTemp->iStatusEx = 0;
 				if ( s == pszText || s[-1] == cDelimiter ) {
diff --git a/plugins/Chat/message.cpp b/plugins/Chat/message.cpp
index 5d1de9379a..ce76bfc6f5 100644
--- a/plugins/Chat/message.cpp
+++ b/plugins/Chat/message.cpp
@@ -92,7 +92,7 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO* si)
 
 	// create an index of colors in the module and map them to
 	// corresponding colors in the RTF color table
-	pIndex = mir_alloc(sizeof(int) * MM_FindModule(si->pszModule)->nColorCount);
+	pIndex = (int *)mir_alloc(sizeof(int) * MM_FindModule(si->pszModule)->nColorCount);
 	for(i = 0; i < MM_FindModule(si->pszModule)->nColorCount ; i++)
 		pIndex[i] = -1;
 
@@ -317,14 +317,14 @@ static DWORD CALLBACK Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff,
 	char ** ppText = (char **) dwCookie;
 
 	if (*ppText == NULL) {
-		*ppText = mir_alloc(cb + 1);
+		*ppText = (char *)mir_alloc(cb + 1);
 		memcpy(*ppText, pbBuff, cb);
 		(*ppText)[cb] = 0;
 		*pcb = cb;
 		dwRead = cb;
 	}
 	else {
-		char  *p = mir_alloc(dwRead + cb + 1);
+		char  *p = (char *)mir_alloc(dwRead + cb + 1);
 		memcpy(p, *ppText, dwRead);
 		memcpy(p+dwRead, pbBuff, cb);
 		p[dwRead + cb] = 0;
diff --git a/plugins/Chat/options.cpp b/plugins/Chat/options.cpp
index c80b0c1871..77989d4b39 100644
--- a/plugins/Chat/options.cpp
+++ b/plugins/Chat/options.cpp
@@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <m_fontservice.h>
 
-extern HANDLE       g_hInst;
 extern HBRUSH       hEditBkgBrush;
 extern HBRUSH       hListBkgBrush;
 extern HBRUSH       hListSelectedBkgBrush;
@@ -755,7 +754,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA
 
 			iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_HIGHLIGHTWORDS));
 			if ( iLen > 0 ) {
-				TCHAR *ptszText = mir_alloc((iLen+2) * sizeof(TCHAR));
+				TCHAR *ptszText = (TCHAR *)mir_alloc((iLen+2) * sizeof(TCHAR));
 				TCHAR *p2 = NULL;
 				
 				if(ptszText) {
@@ -773,7 +772,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA
 
 			iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY));
 			if ( iLen > 0 ) {
-				pszText = mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
+				pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
 				GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText,iLen + 1);
 				DBWriteContactSettingTString(NULL, "Chat", "LogDirectory", pszText);
 			}
@@ -783,7 +782,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA
 
 			iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGTIMESTAMP));
 			if ( iLen > 0 ) {
-				pszText = mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
+				pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
 				GetDlgItemText(hwndDlg, IDC_LOGTIMESTAMP, pszText, iLen+1);
 				DBWriteContactSettingTString(NULL, "Chat", "LogTimestamp", pszText);
 			}
@@ -791,7 +790,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA
 
 			iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TIMESTAMP));
 			if ( iLen > 0 ) {
-				pszText = mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
+				pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
 				GetDlgItemText(hwndDlg, IDC_TIMESTAMP, pszText, iLen+1);
 				DBWriteContactSettingTString(NULL, "Chat", "HeaderTime", pszText);
 			}
@@ -799,7 +798,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA
 
 			iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_INSTAMP));
 			if ( iLen > 0 ) {
-				pszText = mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
+				pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
 				GetDlgItemText(hwndDlg, IDC_INSTAMP, pszText,iLen+1);
 				DBWriteContactSettingTString(NULL, "Chat", "HeaderIncoming", pszText);
 			}
@@ -807,7 +806,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA
 
 			iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_OUTSTAMP));
 			if ( iLen > 0 ) {
-				pszText = mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
+				pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
 				GetDlgItemText(hwndDlg, IDC_OUTSTAMP, pszText,iLen+1);
 				DBWriteContactSettingTString(NULL, "Chat", "HeaderOutgoing", pszText);
 			}
@@ -828,7 +827,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA
 
 			iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP));
 			if (iLen > 0) {
-				pszText = mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
+				pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR));
 				GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen+1);
 				DBWriteContactSettingTString(NULL, "Chat", "AddToGroup", pszText);
 			}
diff --git a/plugins/Chat/richutil.cpp b/plugins/Chat/richutil.cpp
index edb6bff003..1c5143b17c 100644
--- a/plugins/Chat/richutil.cpp
+++ b/plugins/Chat/richutil.cpp
@@ -64,7 +64,7 @@ TRichUtil *rlist_find(RList *list, HWND hwnd) {
 
 RList *rlist_append(RList *list, TRichUtil *data) {
 	RList *n;
-	RList *new_list = malloc(sizeof(RList));
+	RList *new_list = (RList *)malloc(sizeof(RList));
 	RList *attach_to = NULL;
 
 	new_list->next = NULL;
@@ -133,7 +133,7 @@ static RList *slist = NULL;
 static CRITICAL_SECTION csRich;
 
 static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-static RichUtil_ClearUglyBorder(TRichUtil *ru);
+static VOID RichUtil_ClearUglyBorder(TRichUtil *ru);
 
 void RichUtil_Load() {
 	mTheme = RIsWinVerXPPlus()?LoadLibraryA("uxtheme.dll"):0;
@@ -282,7 +282,7 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
 	return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
 }
 
-static RichUtil_ClearUglyBorder(TRichUtil *ru) {
+static VOID RichUtil_ClearUglyBorder(TRichUtil *ru) {
 	if (mTheme&&MyIsThemeActive()&&GetWindowLongPtr(ru->hwnd, GWL_EXSTYLE)&WS_EX_CLIENTEDGE) {
 		ru->hasUglyBorder = 1;
 		SetWindowLongPtr(ru->hwnd, GWL_EXSTYLE, GetWindowLongPtr(ru->hwnd, GWL_EXSTYLE)^WS_EX_CLIENTEDGE);
diff --git a/plugins/Chat/services.cpp b/plugins/Chat/services.cpp
index 4a9e785691..6f305cc906 100644
--- a/plugins/Chat/services.cpp
+++ b/plugins/Chat/services.cpp
@@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "m_fontservice.h"
 
-extern HANDLE		g_hInst;
 extern HICON      hIcons[30];
 extern HIMAGELIST	hImageList;
 extern HIMAGELIST	hIconsList;
@@ -334,7 +333,7 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
 		mi->iMaxText= gcr->iMaxText;
 		mi->nColorCount = gcr->nColors;
 		if ( gcr->nColors > 0) {
-			mi->crColors = mir_alloc(sizeof(COLORREF) * gcr->nColors);
+			mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * gcr->nColors);
 			memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF) * gcr->nColors);
 		}
 
diff --git a/plugins/Chat/tools.cpp b/plugins/Chat/tools.cpp
index ef24f40a13..fa8f28ead3 100644
--- a/plugins/Chat/tools.cpp
+++ b/plugins/Chat/tools.cpp
@@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 extern HICON        hIcons[30];
 extern BOOL         PopUpInstalled;
-extern HINSTANCE    g_hInst;
 extern FONTINFO     aFonts[OPTIONS_FONTCOUNT];
 extern HMENU        g_hMenu;
 extern HANDLE       hBuildMenuEvent ;
@@ -162,7 +161,7 @@ static int ShowPopup (HANDLE hContact, SESSION_INFO* si, HICON hIcon,  char* psz
 		pd.colorText = crBkg;
 	}
 
-	pd.PluginWindowProc = PopupDlgProc;
+	pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
 	pd.PluginData = si;
 	return PUAddPopUpT(&pd);
 }
@@ -477,9 +476,9 @@ BOOL IsHighlighted(SESSION_INFO* si, const TCHAR* pszText)
 					p3 += 1;
 
 				//find the end of the word
-				p2 = _tcschr(p3, ' ');
+				p2 = (TCHAR *)_tcschr(p3, ' ');
 				if (!p2)
-					p2 = _tcschr(p3, '\0');
+					p2 = (TCHAR *)_tcschr(p3, '\0');
 
 
 				if (p3 != p2) {
@@ -657,7 +656,7 @@ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce)
 					hFile = NULL;
 
 					// trim to whole lines, should help with broken log files I hope.
-					pBufferTemp = strchr(pBuffer, '\n');
+					pBufferTemp = (BYTE *)strchr((char *)pBuffer, '\n');
 					if ( pBufferTemp ) {
 						pBufferTemp++;
 						read -= pBufferTemp - pBuffer;
diff --git a/plugins/Chat/window.cpp b/plugins/Chat/window.cpp
index f59df07a30..2bb493ca49 100644
--- a/plugins/Chat/window.cpp
+++ b/plugins/Chat/window.cpp
@@ -26,7 +26,6 @@ extern HBRUSH		hEditBkgBrush;
 extern HBRUSH		hListBkgBrush;
 extern HBRUSH		hListSelectedBkgBrush;
 extern HANDLE		hSendEvent;
-extern HINSTANCE	g_hInst;
 extern HICON		hIcons[30];
 extern struct		CREOleCallback reOleCallback;
 extern HIMAGELIST	hImageList;
@@ -395,7 +394,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
 				if (iLen >0) {
 					TCHAR *pszName = NULL;
 					TCHAR *pszSelName = NULL;
-					pszText = mir_alloc(sizeof(TCHAR)*(iLen+100));
+					pszText = (TCHAR *)mir_alloc(sizeof(TCHAR)*(iLen+100));
 
 					gt.cb = iLen+99;
 					gt.flags = GT_DEFAULT;
@@ -410,7 +409,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
 					if ( dat->szTabSave[0] =='\0')
 						lstrcpyn( dat->szTabSave, pszText+start, end-start+1 );
 
-					pszSelName = mir_alloc( sizeof(TCHAR)*( end-start+1 ));
+					pszSelName = (TCHAR *)mir_alloc( sizeof(TCHAR)*( end-start+1 ));
 					lstrcpyn( pszSelName, pszText+start, end-start+1);
 					pszName = UM_FindUserAutoComplete(Parentsi->pUsers, dat->szTabSave, pszSelName);
 					if (pszName == NULL) {
@@ -1152,7 +1151,7 @@ int GetTextPixelSize( TCHAR* pszText, HFONT hFont, BOOL bWidth)
 		return 0;
 
 	hdc = GetDC(NULL);
-	hOldFont = SelectObject(hdc, hFont);
+	hOldFont = (HFONT)SelectObject(hdc, hFont);
 	i = DrawText(hdc, pszText , -1, &rc, DT_CALCRECT);
 	SelectObject(hdc, hOldFont);
 	ReleaseDC(NULL,hdc);
@@ -1180,7 +1179,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
 			HWND hNickList = GetDlgItem(hwndDlg,IDC_LIST);
 			si = (SESSION_INFO*)lParam;
 			si->pAccPropServicesForNickList = NULL;
-			CoCreateInstance(&CLSID_AccPropServices, NULL, CLSCTX_SERVER, &IID_IAccPropServices, &si->pAccPropServicesForNickList);
+			CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, (LPVOID *)si->pAccPropServicesForNickList);
 			TranslateDialogDefault(hwndDlg);
 			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)si);
 			OldSplitterProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_SPLITTERX),GWLP_WNDPROC,(LONG_PTR)SplitterSubclassProc);
@@ -1903,8 +1902,7 @@ END_REMOVETAB:
 					if (si->pAccPropServicesForNickList) 
 					{
 						wchar_t *nick = mir_t2u(ui->pszNick);
-						si->pAccPropServicesForNickList->lpVtbl->SetHwndPropStr(si->pAccPropServicesForNickList,
-							GetDlgItem(hwndDlg,IDC_LIST), OBJID_CLIENT, dis->itemID+1, PROPID_ACC_NAME, nick);
+						si->pAccPropServicesForNickList->SetHwndPropStr(GetDlgItem(hwndDlg,IDC_LIST), OBJID_CLIENT, dis->itemID+1, PROPID_ACC_NAME, nick);
 						mir_free(nick);
 					}
 				}
@@ -2061,7 +2059,7 @@ LABEL_SHOWWINDOW:
 			HWND ColorWindow;
 			RECT rc;
 			BOOL bFG = lParam == IDC_COLOR?TRUE:FALSE;
-			COLORCHOOSER * pCC = mir_alloc(sizeof(COLORCHOOSER));
+			COLORCHOOSER * pCC = (COLORCHOOSER *)mir_alloc(sizeof(COLORCHOOSER));
 
 			GetWindowRect(GetDlgItem(hwndDlg, bFG?IDC_COLOR:IDC_BKGCOLOR), &rc);
 			pCC->hWndTarget = GetDlgItem(hwndDlg, IDC_MESSAGE);
@@ -2341,7 +2339,7 @@ LABEL_SHOWWINDOW:
 							if (sel.cpMin != sel.cpMax)
 								break;
 							tr.chrg = ((ENLINK *) lParam)->chrg;
-							tr.lpstrText = mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 1));
+							tr.lpstrText = (LPTSTR)mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 1));
 							SendMessage(pNmhdr->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
 							pszUrl = mir_t2a( tr.lpstrText );
 
@@ -2713,7 +2711,7 @@ LABEL_SHOWWINDOW:
 		}
 		DestroyWindow( si->hwndTooltip );
 		si->hwndTooltip = NULL;
-		if (si->pAccPropServicesForNickList) si->pAccPropServicesForNickList->lpVtbl->Release(si->pAccPropServicesForNickList);
+		if (si->pAccPropServicesForNickList) si->pAccPropServicesForNickList->Release();
 		SetWindowLongPtr(hwndDlg,GWLP_USERDATA,0);
 		SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_SPLITTERX),GWLP_WNDPROC,(LONG_PTR)OldSplitterProc);
 		SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_SPLITTERY),GWLP_WNDPROC,(LONG_PTR)OldSplitterProc);
-- 
cgit v1.2.3