https://git.reactos.org/?p=reactos.git;a=commitdiff;h=700f54c37b64427f807c0…
commit 700f54c37b64427f807c0ff95d7fffe95888c4d9
Author: Giannis Adamopoulos <gadamopoulos(a)reactos.org>
AuthorDate: Sun Apr 28 06:39:02 2019 +0300
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Tue Aug 20 00:43:46 2019 +0200
[RAPPS] CMainWindow: Make EnumInstalledAppProc and EnumAvailableAppProc methods
---
base/applications/rapps/available.cpp | 4 +--
base/applications/rapps/gui.cpp | 43 ++++++++++++++++++-----------
base/applications/rapps/include/available.h | 4 +--
base/applications/rapps/include/installed.h | 4 +--
base/applications/rapps/installed.cpp | 4 +--
base/applications/rapps/unattended.cpp | 2 +-
6 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/base/applications/rapps/available.cpp
b/base/applications/rapps/available.cpp
index 9a67aba42c0..16e4fc00775 100644
--- a/base/applications/rapps/available.cpp
+++ b/base/applications/rapps/available.cpp
@@ -320,7 +320,7 @@ BOOL CAvailableApps::ForceUpdateAppsDB()
return UpdateAppsDB();
}
-BOOL CAvailableApps::Enum(INT EnumType, AVAILENUMPROC lpEnumProc)
+BOOL CAvailableApps::Enum(INT EnumType, AVAILENUMPROC lpEnumProc, PVOID param)
{
HANDLE hFind = INVALID_HANDLE_VALUE;
@@ -381,7 +381,7 @@ skip_if_cached:
Info->RefreshAppInfo();
if (lpEnumProc)
- lpEnumProc(Info, m_Strings.szAppsPath.GetString());
+ lpEnumProc(Info, m_Strings.szAppsPath.GetString(), param);
}
} while (FindNextFileW(hFind, &FindFileData) != 0);
diff --git a/base/applications/rapps/gui.cpp b/base/applications/rapps/gui.cpp
index cf8ef0f3126..89eb62efb24 100644
--- a/base/applications/rapps/gui.cpp
+++ b/base/applications/rapps/gui.cpp
@@ -554,14 +554,14 @@ public:
return (InsertColumn(Index, &Column) == -1) ? FALSE : TRUE;
}
- INT AddItem(INT ItemIndex, INT IconIndex, LPWSTR lpText, LPARAM lParam)
+ INT AddItem(INT ItemIndex, INT IconIndex, LPCWSTR lpText, LPARAM lParam)
{
LVITEMW Item;
ZeroMemory(&Item, sizeof(Item));
Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
- Item.pszText = lpText;
+ Item.pszText = const_cast<LPWSTR>(lpText);
Item.lParam = lParam;
Item.iItem = ItemIndex;
Item.iImage = IconIndex;
@@ -1614,7 +1614,7 @@ private:
return StrStrIW(szHaystack, szNeedle) != NULL;
}
- static BOOL CALLBACK s_EnumInstalledAppProc(INT ItemIndex, ATL::CStringW
&m_szName, PINSTALLED_INFO Info)
+ BOOL CALLBACK EnumInstalledAppProc(INT ItemIndex, ATL::CStringW &m_szName,
PINSTALLED_INFO Info)
{
PINSTALLED_INFO ItemInfo;
ATL::CStringW szText;
@@ -1633,20 +1633,20 @@ private:
return FALSE;
}
- Index = ListViewAddItem(ItemIndex, 0, m_szName, (LPARAM) ItemInfo);
+ Index = m_ListView->AddItem(ItemIndex, 0, m_szName.GetString(), (LPARAM)
ItemInfo);
/* Get version info */
ItemInfo->GetApplicationString(L"DisplayVersion", szText);
- ListView_SetItemText(hListView, Index, 1,
const_cast<LPWSTR>(szText.GetString()));
+ m_ListView->SetItemText(Index, 1, szText.GetString());
/* Get comments */
ItemInfo->GetApplicationString(L"Comments", szText);
- ListView_SetItemText(hListView, Index, 2,
const_cast<LPWSTR>(szText.GetString()));
+ m_ListView->SetItemText(Index, 2, szText.GetString());
return TRUE;
}
- static BOOL CALLBACK s_EnumAvailableAppProc(CAvailableApplicationInfo* Info, LPCWSTR
szFolderPath)
+ BOOL EnumAvailableAppProc(CAvailableApplicationInfo* Info, LPCWSTR szFolderPath)
{
INT Index;
HICON hIcon = NULL;
@@ -1678,16 +1678,27 @@ private:
Index = ImageList_AddIcon(hImageListView, hIcon);
DestroyIcon(hIcon);
- Index = ListViewAddItem(Info->m_Category, Index,
Info->m_szName.GetString(), (LPARAM) Info);
- ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
-
- ListView_SetItemText(hListView, Index, 1,
const_cast<LPWSTR>(Info->m_szVersion.GetString()));
- ListView_SetItemText(hListView, Index, 2,
const_cast<LPWSTR>(Info->m_szDesc.GetString()));
- ListView_SetCheckState(hListView, Index, Info->m_IsSelected);
+ Index = m_ListView->AddItem(Info->m_Category, Index,
Info->m_szName.GetString(), (LPARAM) Info);
+ m_ListView->SetImageList(hImageListView, LVSIL_SMALL);
+ m_ListView->SetItemText(Index, 1, Info->m_szVersion.GetString());
+ m_ListView->SetItemText(Index, 2, Info->m_szDesc.GetString());
+ m_ListView->SetCheckState(Index, Info->m_IsSelected);
return TRUE;
}
+ static BOOL CALLBACK s_EnumInstalledAppProc(INT ItemIndex, ATL::CStringW
&m_szName, PINSTALLED_INFO Info, PVOID param)
+ {
+ CMainWindow* pThis = (CMainWindow*)param;
+ return pThis->EnumInstalledAppProc(ItemIndex, m_szName, Info);
+ }
+
+ static BOOL CALLBACK s_EnumAvailableAppProc(CAvailableApplicationInfo* Info, LPCWSTR
szFolderPath, PVOID param)
+ {
+ CMainWindow* pThis = (CMainWindow*)param;
+ return pThis->EnumAvailableAppProc(Info, szFolderPath);
+ }
+
VOID UpdateStatusBarText()
{
if (m_StatusBar)
@@ -1745,8 +1756,8 @@ private:
DestroyIcon(hIcon);
// Enum installed applications and updates
- EnumInstalledApplications(EnumType, TRUE, s_EnumInstalledAppProc);
- EnumInstalledApplications(EnumType, FALSE, s_EnumInstalledAppProc);
+ EnumInstalledApplications(EnumType, TRUE, s_EnumInstalledAppProc, this);
+ EnumInstalledApplications(EnumType, FALSE, s_EnumInstalledAppProc, this);
}
else if (IsAvailableEnum(EnumType))
{
@@ -1756,7 +1767,7 @@ private:
}
// Enum available applications
- m_AvailableApps.Enum(EnumType, s_EnumAvailableAppProc);
+ m_AvailableApps.Enum(EnumType, s_EnumAvailableAppProc, this);
}
SelectedEnumType = EnumType;
diff --git a/base/applications/rapps/include/available.h
b/base/applications/rapps/include/available.h
index c0b0f2017fb..f5beb9e44cf 100644
--- a/base/applications/rapps/include/available.h
+++ b/base/applications/rapps/include/available.h
@@ -79,7 +79,7 @@ private:
inline BOOL FindInLanguages(LCID what) const;
};
-typedef BOOL(CALLBACK *AVAILENUMPROC)(CAvailableApplicationInfo *Info, LPCWSTR
szFolderPath);
+typedef BOOL(CALLBACK *AVAILENUMPROC)(CAvailableApplicationInfo *Info, LPCWSTR
szFolderPath, PVOID param);
struct AvailableStrings
{
@@ -106,7 +106,7 @@ public:
static VOID DeleteCurrentAppsDB();
VOID FreeCachedEntries();
- BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc);
+ BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc, PVOID param);
CAvailableApplicationInfo* FindInfo(const ATL::CStringW& szAppName) const;
ATL::CSimpleArray<CAvailableApplicationInfo> FindInfoList(const
ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
diff --git a/base/applications/rapps/include/installed.h
b/base/applications/rapps/include/installed.h
index e5293c2761b..876c7423522 100644
--- a/base/applications/rapps/include/installed.h
+++ b/base/applications/rapps/include/installed.h
@@ -13,9 +13,9 @@ struct INSTALLED_INFO
};
typedef INSTALLED_INFO *PINSTALLED_INFO;
-typedef BOOL(CALLBACK *APPENUMPROC)(INT ItemIndex, ATL::CStringW &Name,
PINSTALLED_INFO Info);
+typedef BOOL(CALLBACK *APPENUMPROC)(INT ItemIndex, ATL::CStringW &Name,
PINSTALLED_INFO Info, PVOID param);
-BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc);
+BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc,
PVOID param);
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString);
BOOL UninstallApplication(INT Index, BOOL bModify);
diff --git a/base/applications/rapps/installed.cpp
b/base/applications/rapps/installed.cpp
index 83fdbe4e8a1..fb0bf03219f 100644
--- a/base/applications/rapps/installed.cpp
+++ b/base/applications/rapps/installed.cpp
@@ -129,7 +129,7 @@ VOID RemoveAppFromRegistry(INT Index)
}
}
-BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc)
+BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc,
PVOID param)
{
DWORD dwSize = MAX_PATH, dwType, dwValue;
BOOL bIsSystemComponent, bIsUpdate;
@@ -199,7 +199,7 @@ BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey,
APPENUMPROC lpEnumP
((EnumType == ENUM_INSTALLED_APPLICATIONS) &&
(!bIsUpdate)) || /* Applications only */
((EnumType == ENUM_UPDATES) && (bIsUpdate))) /* Updates
only */
{
- if (!lpEnumProc(ItemIndex, szDisplayName, &Info))
+ if (!lpEnumProc(ItemIndex, szDisplayName, &Info, param))
break;
}
else
diff --git a/base/applications/rapps/unattended.cpp
b/base/applications/rapps/unattended.cpp
index 2988ff68c44..d5428cae410 100644
--- a/base/applications/rapps/unattended.cpp
+++ b/base/applications/rapps/unattended.cpp
@@ -62,7 +62,7 @@ BOOL UseCmdParameters(LPWSTR lpCmdLine)
CAvailableApps apps;
apps.UpdateAppsDB();
- apps.Enum(ENUM_ALL_AVAILABLE, NULL);
+ apps.Enum(ENUM_ALL_AVAILABLE, NULL, NULL);
ATL::CSimpleArray<CAvailableApplicationInfo> arrAppInfo =
apps.FindInfoList(arrNames);
if (arrAppInfo.GetSize() > 0)