From 492d1e96d1ea43e14e11d3d306ce3d60a0b2f5c4 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 23 Apr 2015 23:08:21 +0000 Subject: [PATCH] [RAPPS_NEW] * Turn the files into .CPP, to ease future changes. All the code remains class-free for now, with one exception. * Adapt the download progress dialog implementation to ATL/C++, which is a best match for COM classes. * Add an ATL CModule class to the process, necessary for CORE-9593 svn path=/trunk/; revision=67376 --- .../applications/rapps_new/CMakeLists.txt | 35 ++- .../rapps_new/{aboutdlg.c => aboutdlg.cpp} | 0 .../rapps_new/{available.c => available.cpp} | 2 +- .../{installdlg.c => installdlg.cpp} | 0 .../rapps_new/{installed.c => installed.cpp} | 6 +- .../rapps_new/{listview.c => listview.cpp} | 0 .../rapps_new/{loaddlg.c => loaddlg.cpp} | 260 +++++++----------- .../rapps_new/{misc.c => misc.cpp} | 7 +- reactos/base/applications/rapps_new/rapps.h | 6 +- .../rapps_new/{richedit.c => richedit.cpp} | 2 +- .../{settingsdlg.c => settingsdlg.cpp} | 0 .../rapps_new/{splitter.c => splitter.cpp} | 0 .../rapps_new/{statusbar.c => statusbar.cpp} | 0 .../rapps_new/{toolbar.c => toolbar.cpp} | 4 +- .../rapps_new/{treeview.c => treeview.cpp} | 0 .../rapps_new/{winmain.c => winmain.cpp} | 48 +++- 16 files changed, 184 insertions(+), 186 deletions(-) rename reactos/base/applications/rapps_new/{aboutdlg.c => aboutdlg.cpp} (100%) rename reactos/base/applications/rapps_new/{available.c => available.cpp} (98%) rename reactos/base/applications/rapps_new/{installdlg.c => installdlg.cpp} (100%) rename reactos/base/applications/rapps_new/{installed.c => installed.cpp} (97%) rename reactos/base/applications/rapps_new/{listview.c => listview.cpp} (100%) rename reactos/base/applications/rapps_new/{loaddlg.c => loaddlg.cpp} (66%) rename reactos/base/applications/rapps_new/{misc.c => misc.cpp} (98%) rename reactos/base/applications/rapps_new/{richedit.c => richedit.cpp} (98%) rename reactos/base/applications/rapps_new/{settingsdlg.c => settingsdlg.cpp} (100%) rename reactos/base/applications/rapps_new/{splitter.c => splitter.cpp} (100%) rename reactos/base/applications/rapps_new/{statusbar.c => statusbar.cpp} (100%) rename reactos/base/applications/rapps_new/{toolbar.c => toolbar.cpp} (98%) rename reactos/base/applications/rapps_new/{treeview.c => treeview.cpp} (100%) rename reactos/base/applications/rapps_new/{winmain.c => winmain.cpp} (96%) diff --git a/reactos/base/applications/rapps_new/CMakeLists.txt b/reactos/base/applications/rapps_new/CMakeLists.txt index 92192e01d72..985d021a25a 100644 --- a/reactos/base/applications/rapps_new/CMakeLists.txt +++ b/reactos/base/applications/rapps_new/CMakeLists.txt @@ -1,24 +1,29 @@ +project(RAPPS_NEW) + +set_cpp(WITH_RUNTIME) + +include_directories(${REACTOS_SOURCE_DIR}/lib/atl) list(APPEND SOURCE - aboutdlg.c - available.c - installdlg.c - installed.c - listview.c - loaddlg.c - misc.c - richedit.c - settingsdlg.c - splitter.c - statusbar.c - toolbar.c - treeview.c - winmain.c + aboutdlg.cpp + available.cpp + installdlg.cpp + installed.cpp + listview.cpp + loaddlg.cpp + misc.cpp + richedit.cpp + settingsdlg.cpp + splitter.cpp + statusbar.cpp + toolbar.cpp + treeview.cpp + winmain.cpp rapps.h) add_executable(rapps_new ${SOURCE} rapps.rc) set_module_type(rapps_new win32gui UNICODE) -target_link_libraries(rapps_new uuid) +target_link_libraries(rapps_new atlnew uuid wine) add_importlibs(rapps_new advapi32 comctl32 gdi32 wininet user32 shell32 shlwapi ole32 msvcrt kernel32 ntdll) add_pch(rapps_new rapps.h SOURCE) add_dependencies(rapps_new rappsmsg_new) diff --git a/reactos/base/applications/rapps_new/aboutdlg.c b/reactos/base/applications/rapps_new/aboutdlg.cpp similarity index 100% rename from reactos/base/applications/rapps_new/aboutdlg.c rename to reactos/base/applications/rapps_new/aboutdlg.cpp diff --git a/reactos/base/applications/rapps_new/available.c b/reactos/base/applications/rapps_new/available.cpp similarity index 98% rename from reactos/base/applications/rapps_new/available.c rename to reactos/base/applications/rapps_new/available.cpp index 166303ef831..dc1306652b0 100644 --- a/reactos/base/applications/rapps_new/available.c +++ b/reactos/base/applications/rapps_new/available.cpp @@ -223,7 +223,7 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc) } /* create a new entry */ - Info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(APPLICATION_INFO)); + Info = (PAPPLICATION_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(APPLICATION_INFO)); if(!Info) break; diff --git a/reactos/base/applications/rapps_new/installdlg.c b/reactos/base/applications/rapps_new/installdlg.cpp similarity index 100% rename from reactos/base/applications/rapps_new/installdlg.c rename to reactos/base/applications/rapps_new/installdlg.cpp diff --git a/reactos/base/applications/rapps_new/installed.c b/reactos/base/applications/rapps_new/installed.cpp similarity index 97% rename from reactos/base/applications/rapps_new/installed.c rename to reactos/base/applications/rapps_new/installed.cpp index 18cec23f998..5d71d19ebcc 100644 --- a/reactos/base/applications/rapps_new/installed.c +++ b/reactos/base/applications/rapps_new/installed.cpp @@ -9,7 +9,7 @@ #include "rapps.h" BOOL -GetApplicationString(HKEY hKey, LPWSTR lpKeyName, LPWSTR lpString) +GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR lpString) { DWORD dwSize = MAX_PATH; @@ -137,7 +137,7 @@ BOOL ShowInstalledAppInfo(INT Index) { WCHAR szText[MAX_PATH], szInfo[MAX_PATH]; - PINSTALLED_INFO Info = ListViewGetlParam(Index); + PINSTALLED_INFO Info = (PINSTALLED_INFO) ListViewGetlParam(Index); if (!Info || !Info->hSubKey) return FALSE; @@ -187,7 +187,7 @@ RemoveAppFromRegistry(INT Index) if (!IS_INSTALLED_ENUM(SelectedEnumType)) return; - Info = ListViewGetlParam(Index); + Info = (PINSTALLED_INFO) ListViewGetlParam(Index); if (!Info || !Info->hSubKey || (ItemIndex == -1)) return; if (!LoadStringW(hInst, IDS_APP_REG_REMOVE, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)) || diff --git a/reactos/base/applications/rapps_new/listview.c b/reactos/base/applications/rapps_new/listview.cpp similarity index 100% rename from reactos/base/applications/rapps_new/listview.c rename to reactos/base/applications/rapps_new/listview.cpp diff --git a/reactos/base/applications/rapps_new/loaddlg.c b/reactos/base/applications/rapps_new/loaddlg.cpp similarity index 66% rename from reactos/base/applications/rapps_new/loaddlg.c rename to reactos/base/applications/rapps_new/loaddlg.cpp index 3afa7acd591..34ae001f01a 100644 --- a/reactos/base/applications/rapps_new/loaddlg.c +++ b/reactos/base/applications/rapps_new/loaddlg.cpp @@ -26,193 +26,146 @@ */ #include "rapps.h" + +#include +#include + +#include +#include #include -#include +#include static PAPPLICATION_INFO AppInfo; static HICON hIcon = NULL; -typedef struct _IBindStatusCallbackImpl +class CDownloadDialog : + public CComObjectRootEx, + public IBindStatusCallback { - const IBindStatusCallbackVtbl *vtbl; - LONG ref; - HWND hDialog; - BOOL *pbCancelled; -} IBindStatusCallbackImpl; + HWND m_hDialog; + PBOOL m_pbCancelled; -static -HRESULT WINAPI -dlQueryInterface(IBindStatusCallback* This, REFIID riid, void** ppvObject) -{ - if (!ppvObject) return E_POINTER; - - if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IBindStatusCallback)) +public: + ~CDownloadDialog() { - IBindStatusCallback_AddRef(This); - *ppvObject = This; + DestroyWindow(m_hDialog); + } + + HRESULT Initialize(HWND Dlg, BOOL *pbCancelled) + { + m_hDialog = Dlg; + m_pbCancelled = pbCancelled; return S_OK; } - return E_NOINTERFACE; -} - -static -ULONG WINAPI -dlAddRef(IBindStatusCallback* iface) -{ - IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl*) iface; - return InterlockedIncrement(&This->ref); -} - -static -ULONG WINAPI -dlRelease(IBindStatusCallback* iface) -{ - IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl*) iface; - DWORD ref = InterlockedDecrement(&This->ref); - - if (!ref) + virtual HRESULT STDMETHODCALLTYPE OnStartBinding( + DWORD dwReserved, + IBinding *pib) { - DestroyWindow(This->hDialog); - HeapFree(GetProcessHeap(), 0, This); + return S_OK; } - return ref; -} - -static -HRESULT WINAPI -dlOnStartBinding(IBindStatusCallback* iface, DWORD dwReserved, IBinding* pib) -{ - return S_OK; -} - -static -HRESULT WINAPI -dlGetPriority(IBindStatusCallback* iface, LONG* pnPriority) -{ - return S_OK; -} - -static -HRESULT WINAPI -dlOnLowResource( IBindStatusCallback* iface, DWORD reserved) -{ - return S_OK; -} - -static -HRESULT WINAPI -dlOnProgress(IBindStatusCallback* iface, - ULONG ulProgress, - ULONG ulProgressMax, - ULONG ulStatusCode, - LPCWSTR szStatusText) -{ - IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface; - HWND Item; - LONG r; - WCHAR OldText[100]; - - Item = GetDlgItem(This->hDialog, IDC_DOWNLOAD_PROGRESS); - if (Item && ulProgressMax) + virtual HRESULT STDMETHODCALLTYPE GetPriority( + LONG *pnPriority) { - SendMessageW(Item, PBM_SETPOS, ((ULONGLONG)ulProgress * 100) / ulProgressMax, 0); + return S_OK; } - Item = GetDlgItem(This->hDialog, IDC_DOWNLOAD_STATUS); - if (Item && szStatusText) + virtual HRESULT STDMETHODCALLTYPE OnLowResource( + DWORD reserved) { - SendMessageW(Item, WM_GETTEXT, sizeof(OldText) / sizeof(OldText[0]), (LPARAM) OldText); - if (sizeof(OldText) / sizeof(OldText[0]) - 1 <= wcslen(OldText) || 0 != wcscmp(OldText, szStatusText)) + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OnProgress( + ULONG ulProgress, + ULONG ulProgressMax, + ULONG ulStatusCode, + LPCWSTR szStatusText) + { + HWND Item; + LONG r; + WCHAR OldText[100]; + + Item = GetDlgItem(m_hDialog, IDC_DOWNLOAD_PROGRESS); + if (Item && ulProgressMax) { - SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) szStatusText); + SendMessageW(Item, PBM_SETPOS, MulDiv(ulProgress, 100, ulProgressMax), 0); } + + Item = GetDlgItem(m_hDialog, IDC_DOWNLOAD_STATUS); + if (Item && szStatusText) + { + SendMessageW(Item, WM_GETTEXT, sizeof(OldText) / sizeof(OldText[0]), (LPARAM) OldText); + if (sizeof(OldText) / sizeof(OldText[0]) - 1 <= wcslen(OldText) || 0 != wcscmp(OldText, szStatusText)) + { + SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) szStatusText); + } + } + + SetLastError(0); + r = GetWindowLongPtrW(m_hDialog, GWLP_USERDATA); + if (0 != r || 0 != GetLastError()) + { + *m_pbCancelled = TRUE; + return E_ABORT; + } + + return S_OK; } - SetLastError(0); - r = GetWindowLongPtrW(This->hDialog, GWLP_USERDATA); - if (0 != r || 0 != GetLastError()) + virtual HRESULT STDMETHODCALLTYPE OnStopBinding( + HRESULT hresult, + LPCWSTR szError) { - *This->pbCancelled = TRUE; - return E_ABORT; + return S_OK; } - return S_OK; -} + virtual HRESULT STDMETHODCALLTYPE GetBindInfo( + DWORD *grfBINDF, + BINDINFO *pbindinfo) + { + return S_OK; + } -static -HRESULT WINAPI -dlOnStopBinding(IBindStatusCallback* iface, HRESULT hresult, LPCWSTR szError) -{ - return S_OK; -} + virtual HRESULT STDMETHODCALLTYPE OnDataAvailable( + DWORD grfBSCF, + DWORD dwSize, + FORMATETC *pformatetc, + STGMEDIUM *pstgmed) + { + return S_OK; + } -static -HRESULT WINAPI -dlGetBindInfo(IBindStatusCallback* iface, DWORD* grfBINDF, BINDINFO* pbindinfo) -{ - return S_OK; -} + virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable( + REFIID riid, + IUnknown *punk) + { + return S_OK; + } -static -HRESULT WINAPI -dlOnDataAvailable(IBindStatusCallback* iface, DWORD grfBSCF, - DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed) -{ - return S_OK; -} - -static -HRESULT WINAPI -dlOnObjectAvailable(IBindStatusCallback* iface, REFIID riid, IUnknown* punk) -{ - return S_OK; -} - -static const IBindStatusCallbackVtbl dlVtbl = -{ - dlQueryInterface, - dlAddRef, - dlRelease, - dlOnStartBinding, - dlGetPriority, - dlOnLowResource, - dlOnProgress, - dlOnStopBinding, - dlGetBindInfo, - dlOnDataAvailable, - dlOnObjectAvailable + BEGIN_COM_MAP(CDownloadDialog) + COM_INTERFACE_ENTRY_IID(IID_IBindStatusCallback, IBindStatusCallback) + END_COM_MAP() }; -static IBindStatusCallback* -CreateDl(HWND Dlg, BOOL *pbCancelled) +extern "C" +HRESULT WINAPI CDownloadDialog_Constructor(HWND Dlg, BOOL *pbCancelled, REFIID riid, LPVOID *ppv) { - IBindStatusCallbackImpl *This; - - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IBindStatusCallbackImpl)); - if (!This) - return NULL; - - This->vtbl = &dlVtbl; - This->ref = 1; - This->hDialog = Dlg; - This->pbCancelled = pbCancelled; - - return (IBindStatusCallback*) This; + return ShellObjectCreatorInit(Dlg, pbCancelled, riid, ppv); } static DWORD WINAPI ThreadFunc(LPVOID Context) { - IBindStatusCallback *dl = NULL; + CComPtr dl; WCHAR path[MAX_PATH]; LPWSTR p; HWND Dlg = (HWND) Context; - DWORD dwContentLen, dwBytesWritten, dwBytesRead, dwStatus; - DWORD dwCurrentBytesRead = 0; - DWORD dwStatusLen = sizeof(dwStatus); + ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus; + ULONG dwCurrentBytesRead = 0; + ULONG dwStatusLen = sizeof(dwStatus); BOOL bCancelled = FALSE; BOOL bTempfile = FALSE; BOOL bCab = FALSE; @@ -220,7 +173,7 @@ ThreadFunc(LPVOID Context) HINTERNET hFile = NULL; HANDLE hOut = INVALID_HANDLE_VALUE; unsigned char lpBuffer[4096]; - const LPWSTR lpszAgent = L"RApps/1.0"; + PCWSTR lpszAgent = L"RApps/1.0"; URL_COMPONENTS urlComponents; size_t urlLength; @@ -256,7 +209,7 @@ ThreadFunc(LPVOID Context) /* download it */ bTempfile = TRUE; - dl = CreateDl(Context, &bCancelled); + CDownloadDialog_Constructor(Dlg, &bCancelled, IID_PPV_ARG(IBindStatusCallback, &dl)); if (dl == NULL) goto end; @@ -307,7 +260,7 @@ ThreadFunc(LPVOID Context) goto end; urlComponents.dwSchemeLength = urlLength*sizeof(WCHAR); - urlComponents.lpszScheme = malloc(urlComponents.dwSchemeLength); + urlComponents.lpszScheme = (PWSTR)malloc(urlComponents.dwSchemeLength); if(!InternetCrackUrlW(AppInfo->szUrlDownload, urlLength+1, ICU_DECODE | ICU_ESCAPE, &urlComponents)) goto end; @@ -330,7 +283,7 @@ ThreadFunc(LPVOID Context) if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead)) goto end; if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL)) goto end; dwCurrentBytesRead += dwBytesRead; - IBindStatusCallback_OnProgress(dl, dwCurrentBytesRead, dwContentLen, 0, AppInfo->szUrlDownload); + dl->OnProgress(dwCurrentBytesRead, dwContentLen, 0, AppInfo->szUrlDownload); } while (dwBytesRead); @@ -353,9 +306,6 @@ end: InternetCloseHandle(hFile); InternetCloseHandle(hOpen); - if (dl) - IBindStatusCallback_Release(dl); - if (bTempfile) { if (bCancelled || (SettingsInfo.bDelInstaller && !bCab)) @@ -437,7 +387,7 @@ DownloadApplication(INT Index) } VOID -DownloadApplicationsDB(LPWSTR lpUrl) +DownloadApplicationsDB(LPCWSTR lpUrl) { APPLICATION_INFO IntInfo; diff --git a/reactos/base/applications/rapps_new/misc.c b/reactos/base/applications/rapps_new/misc.cpp similarity index 98% rename from reactos/base/applications/rapps_new/misc.c rename to reactos/base/applications/rapps_new/misc.cpp index e8d05ec881d..3375844d4c0 100644 --- a/reactos/base/applications/rapps_new/misc.c +++ b/reactos/base/applications/rapps_new/misc.cpp @@ -45,7 +45,8 @@ typedef struct struct FILELIST *FilterList; } SESSION; -HRESULT (WINAPI *pfnExtract)(SESSION *dest, LPCSTR szCabName); +typedef HRESULT(WINAPI *fnExtract)(SESSION *dest, LPCSTR szCabName); +fnExtract pfnExtract; INT @@ -126,7 +127,7 @@ CopyTextToClipboard(LPCWSTR lpszText) EmptyClipboard(); cchBuffer = wcslen(lpszText) + 1; ClipBuffer = GlobalAlloc(GMEM_DDESHARE, cchBuffer * sizeof(WCHAR)); - Buffer = GlobalLock(ClipBuffer); + Buffer = (PWCHAR)GlobalLock(ClipBuffer); hr = StringCchCopyW(Buffer, cchBuffer, lpszText); GlobalUnlock(ClipBuffer); @@ -268,7 +269,7 @@ ExtractFilesFromCab(LPWSTR lpCabName, LPWSTR lpOutputPath) hCabinetDll = LoadLibraryW(L"cabinet.dll"); if (hCabinetDll) { - pfnExtract = (void *) GetProcAddress(hCabinetDll, "Extract"); + pfnExtract = (fnExtract) GetProcAddress(hCabinetDll, "Extract"); if (pfnExtract) { ZeroMemory(&Dest, sizeof(SESSION)); diff --git a/reactos/base/applications/rapps_new/rapps.h b/reactos/base/applications/rapps_new/rapps.h index d92eafed56a..409a4b20316 100644 --- a/reactos/base/applications/rapps_new/rapps.h +++ b/reactos/base/applications/rapps_new/rapps.h @@ -1,6 +1,7 @@ #ifndef _RAPPS_H #define _RAPPS_H +#include #include #define WIN32_NO_STATUS @@ -16,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -133,7 +135,7 @@ BOOL InstallApplication(INT Index); /* installed.c */ typedef BOOL (CALLBACK *APPENUMPROC)(INT ItemIndex, LPWSTR lpName, PINSTALLED_INFO Info); BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc); -BOOL GetApplicationString(HKEY hKey, LPWSTR lpKeyName, LPWSTR lpString); +BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR lpString); BOOL ShowInstalledAppInfo(INT Index); BOOL UninstallApplication(INT Index, BOOL bModify); BOOL IsInstalledApplication(LPWSTR lpRegName, BOOL IsUserKey); @@ -158,7 +160,7 @@ PVOID ListViewGetlParam(INT Index); /* loaddlg.c */ BOOL DownloadApplication(INT Index); -VOID DownloadApplicationsDB(LPWSTR lpUrl); +VOID DownloadApplicationsDB(LPCWSTR lpUrl); /* misc.c */ INT GetSystemColorDepth(VOID); diff --git a/reactos/base/applications/rapps_new/richedit.c b/reactos/base/applications/rapps_new/richedit.cpp similarity index 98% rename from reactos/base/applications/rapps_new/richedit.c rename to reactos/base/applications/rapps_new/richedit.cpp index 970a328f0ce..b6f14333c76 100644 --- a/reactos/base/applications/rapps_new/richedit.c +++ b/reactos/base/applications/rapps_new/richedit.cpp @@ -23,7 +23,7 @@ RichEditOnLink(HWND hwnd, ENLINK *Link) { if (pLink) HeapFree(GetProcessHeap(), 0, pLink); - pLink = HeapAlloc(GetProcessHeap(), + pLink = (PWSTR)HeapAlloc(GetProcessHeap(), 0, (max(Link->chrg.cpMin, Link->chrg.cpMax) - min(Link->chrg.cpMin, Link->chrg.cpMax) + 1) * sizeof(WCHAR)); diff --git a/reactos/base/applications/rapps_new/settingsdlg.c b/reactos/base/applications/rapps_new/settingsdlg.cpp similarity index 100% rename from reactos/base/applications/rapps_new/settingsdlg.c rename to reactos/base/applications/rapps_new/settingsdlg.cpp diff --git a/reactos/base/applications/rapps_new/splitter.c b/reactos/base/applications/rapps_new/splitter.cpp similarity index 100% rename from reactos/base/applications/rapps_new/splitter.c rename to reactos/base/applications/rapps_new/splitter.cpp diff --git a/reactos/base/applications/rapps_new/statusbar.c b/reactos/base/applications/rapps_new/statusbar.cpp similarity index 100% rename from reactos/base/applications/rapps_new/statusbar.c rename to reactos/base/applications/rapps_new/statusbar.cpp diff --git a/reactos/base/applications/rapps_new/toolbar.c b/reactos/base/applications/rapps_new/toolbar.cpp similarity index 98% rename from reactos/base/applications/rapps_new/toolbar.c rename to reactos/base/applications/rapps_new/toolbar.cpp index f1bbc80f030..51ddef58e4f 100644 --- a/reactos/base/applications/rapps_new/toolbar.c +++ b/reactos/base/applications/rapps_new/toolbar.cpp @@ -67,9 +67,9 @@ ToolBarOnGetDispInfo(LPTOOLTIPTEXT lpttt) VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex) { - HANDLE hImage; + HICON hImage; - if (!(hImage = LoadImage(hInst, + if (!(hImage = (HICON) LoadImage(hInst, MAKEINTRESOURCE(ImageIndex), IMAGE_ICON, TOOLBAR_HEIGHT, diff --git a/reactos/base/applications/rapps_new/treeview.c b/reactos/base/applications/rapps_new/treeview.cpp similarity index 100% rename from reactos/base/applications/rapps_new/treeview.c rename to reactos/base/applications/rapps_new/treeview.cpp diff --git a/reactos/base/applications/rapps_new/winmain.c b/reactos/base/applications/rapps_new/winmain.cpp similarity index 96% rename from reactos/base/applications/rapps_new/winmain.c rename to reactos/base/applications/rapps_new/winmain.cpp index f721990e26e..59aec0a4b4f 100644 --- a/reactos/base/applications/rapps_new/winmain.c +++ b/reactos/base/applications/rapps_new/winmain.cpp @@ -9,6 +9,8 @@ #include "rapps.h" +#include +#include #include #define SEARCH_TIMER_ID 'SR' @@ -22,6 +24,40 @@ SETTINGS_INFO SettingsInfo; WCHAR szSearchPattern[MAX_STR_LEN] = L""; BOOL SearchEnabled = TRUE; +class CRAppsModule : public CComModule +{ +public: +}; + +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + +CRAppsModule gModule; +CAtlWinModule gWinModule; + +void *operator new (size_t, void *buf) +{ + return buf; +} + +static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize) +{ + if (bInitialize) + { + /* HACK - the global constructors don't run, so I placement new them here */ + new (&gModule) CRAppsModule; + new (&gWinModule) CAtlWinModule; + new (&_AtlBaseModule) CAtlBaseModule; + new (&_AtlComModule) CAtlComModule; + + gModule.Init(ObjectMap, hInstance, NULL); + } + else + { + gModule.Term(); + } +} + BOOL SearchPatternMatch(PCWSTR szHaystack, PCWSTR szNeedle) { @@ -108,7 +144,7 @@ FreeInstalledAppList(VOID) while (Count >= 0) { - Info = ListViewGetlParam(Count); + Info = (PINSTALLED_INFO)ListViewGetlParam(Count); if (Info) { RegCloseKey(Info->hSubKey); @@ -132,7 +168,7 @@ EnumInstalledAppProc(INT ItemIndex, LPWSTR lpName, PINSTALLED_INFO Info) return TRUE; } - ItemInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(INSTALLED_INFO)); + ItemInfo = (PINSTALLED_INFO) HeapAlloc(GetProcessHeap(), 0, sizeof(INSTALLED_INFO)); if (!ItemInfo) { RegCloseKey(Info->hSubKey); @@ -203,7 +239,7 @@ UpdateApplicationsList(INT EnumType) GetSystemColorDepth() | ILC_MASK, 0, 1); - hIcon = LoadImage(hInst, + hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, LISTVIEW_ICON_SIZE, @@ -274,7 +310,7 @@ AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex) INT Index; HICON hIcon; - hIcon = LoadImage(hInst, + hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IconIndex), IMAGE_ICON, TREEVIEW_ICON_SIZE, @@ -903,6 +939,8 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh HACCEL KeyBrd; MSG Msg; + InitializeAtlModule(hInstance, TRUE); + switch (GetUserDefaultUILanguage()) { case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT): @@ -989,5 +1027,7 @@ Exit: if (hMutex) CloseHandle(hMutex); + InitializeAtlModule(hInstance, FALSE); + return 0; }