Author: ashaposhnikov Date: Fri Jun 23 07:04:43 2017 New Revision: 75168
URL: http://svn.reactos.org/svn/reactos?rev=75168&view=rev Log: [RAPPS] * Added individual icons loading for each app The icons are loaded by the Name field in the DB for the proof-of-concept. It falls back to default icon if none present. TODO: It would be best to make another entry there for icon name.
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/app... ============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] Fri Jun 23 07:04:43 2017 @@ -1,4 +1,4 @@ -/* PROJECT: ReactOS CE Applications Manager +/* PROJECT: ReactOS CE Applications Manager * LICENSE: GPL - See COPYING in the top level directory * AUTHORS: David Quintana gigaherz@gmail.com */ @@ -1126,71 +1126,72 @@ static BOOL CALLBACK s_EnumAvailableAppProc(PAPPLICATION_INFO Info) { INT Index; + HICON hIcon = NULL; + bool failed = false; + WCHAR szIconPath[MAX_PATH] = L""; + HIMAGELIST hImageListView = NULL; + hImageListView = ListView_GetImageList(hListView, LVSIL_SMALL);
if (!SearchPatternMatch(Info->szName, szSearchPattern) && !SearchPatternMatch(Info->szDesc, szSearchPattern)) { return TRUE; } - - Index = ListViewAddItem(Info->Category, 0, Info->szName, (LPARAM) Info); - - ListView_SetItemText(hListView, Index, 1, Info->szVersion); - ListView_SetItemText(hListView, Index, 2, Info->szDesc); - - return TRUE; - } - - VOID UpdateApplicationsList(INT EnumType) - { - WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN]; - HICON hIcon; - HIMAGELIST hImageListView; - - m_ListView->SendMessage(WM_SETREDRAW, FALSE, 0); - - if (EnumType == -1) EnumType = SelectedEnumType; - - if (IS_INSTALLED_ENUM(SelectedEnumType)) - FreeInstalledAppList(); - - (VOID) ListView_DeleteAllItems(hListView); - - /* Create image list */ - hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE, - LISTVIEW_ICON_SIZE, - GetSystemColorDepth() | ILC_MASK, - 0, 1); - - hIcon = (HICON) LoadImage(hInst, - MAKEINTRESOURCE(IDI_MAIN), + //TODO: Define another field for icon name in the DB + failed = !GetStorageDirectory(szIconPath, _countof(szIconPath)) + || FAILED(StringCbPrintfW(szIconPath, sizeof(szIconPath), L"%ls\rapps\icons\%ls.ico", szIconPath, Info->szName)); + if (!failed) { + //Load icon from file + hIcon = (HICON)LoadImage(NULL, + szIconPath, IMAGE_ICON, LISTVIEW_ICON_SIZE, LISTVIEW_ICON_SIZE, - LR_CREATEDIBSECTION); - - ImageList_AddIcon(hImageListView, hIcon); + LR_LOADFROMFILE); + } + if (GetLastError() != ERROR_SUCCESS) { + //Load default icon + hIcon = (HICON)LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN)); + } + Index = ImageList_AddIcon(hImageListView, hIcon); DestroyIcon(hIcon); - /* - if (IS_INSTALLED_ENUM(EnumType)) - { - / Enum installed applications and updates - EnumInstalledApplications(EnumType, TRUE, s_EnumInstalledAppProc); - EnumInstalledApplications(EnumType, FALSE, s_EnumInstalledAppProc); - } - - else */if (IS_AVAILABLE_ENUM(EnumType)) - { - /* Enum available applications */ - EnumAvailableApplications(EnumType, s_EnumAvailableAppProc); - } - - /* Set image list for ListView */ + + Index = ListViewAddItem(Info->Category, Index, Info->szName, (LPARAM) Info); hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
- /* Destroy old image list */ + ListView_SetItemText(hListView, Index, 1, Info->szVersion); + ListView_SetItemText(hListView, Index, 2, Info->szDesc); + return TRUE; + } + + + VOID UpdateApplicationsList(INT EnumType) + { + WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN]; + HIMAGELIST hImageListView = NULL; + + m_ListView->SendMessage(WM_SETREDRAW, FALSE, 0); + + if (EnumType < 0) EnumType = SelectedEnumType; + + if (IS_INSTALLED_ENUM(SelectedEnumType)) + FreeInstalledAppList(); + + (VOID) ListView_DeleteAllItems(hListView); + //Create new ImageList + hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE, + LISTVIEW_ICON_SIZE, + GetSystemColorDepth() | ILC_MASK, + 0, 1000); + hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL); + if (hImageListView) - ImageList_Destroy(hImageListView); + ImageList_Destroy(hImageListView); + + if (IS_AVAILABLE_ENUM(EnumType)) { + /* Enum available applications */ + EnumAvailableApplications(EnumType, s_EnumAvailableAppProc); + }
SelectedEnumType = EnumType;
@@ -1212,7 +1213,7 @@ public: static ATL::CWndClassInfo& GetWndClassInfo() { - DWORD csStyle = CS_VREDRAW |CS_HREDRAW; + DWORD csStyle = CS_VREDRAW | CS_HREDRAW; static ATL::CWndClassInfo wc = { { sizeof(WNDCLASSEX), csStyle, StartWindowProc,