[RAPPS] CMainWindow: Make EnumInstalledAppProc and EnumAvailableAppProc methods

This commit is contained in:
Giannis Adamopoulos 2019-04-28 06:39:02 +03:00 committed by Mark Jansen
parent d8b773b190
commit 700f54c37b
No known key found for this signature in database
GPG Key ID: B39240EE84BEAE8B
6 changed files with 36 additions and 25 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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)