2020-06-05 15:32:08 +00:00
|
|
|
/*
|
2017-09-09 20:38:06 +00:00
|
|
|
* PROJECT: ReactOS Applications Manager
|
2020-07-31 19:57:35 +00:00
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
2017-09-09 20:38:06 +00:00
|
|
|
* PURPOSE: GUI classes for RAPPS
|
2023-02-28 00:00:29 +00:00
|
|
|
* COPYRIGHT: Copyright 2015 David Quintana (gigaherz@gmail.com)
|
|
|
|
* Copyright 2017 Alexander Shaposhnikov (sanchaez@reactos.org)
|
|
|
|
* Copyright 2020 He Yang (1160386205@qq.com)
|
2015-04-27 15:01:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "rapps.h"
|
2017-08-02 12:50:53 +00:00
|
|
|
#include "rosui.h"
|
|
|
|
#include "crichedit.h"
|
2020-06-21 10:26:41 +00:00
|
|
|
#include "asyncinet.h"
|
2020-07-24 08:07:43 +00:00
|
|
|
#include "gui.h"
|
2015-04-27 15:01:40 +00:00
|
|
|
#include <shlobj_undoc.h>
|
|
|
|
#include <shlguid_undoc.h>
|
|
|
|
|
|
|
|
#include <atlbase.h>
|
|
|
|
#include <atlcom.h>
|
2020-06-14 13:22:58 +00:00
|
|
|
#include <atltypes.h>
|
2015-04-27 15:01:40 +00:00
|
|
|
#include <atlwin.h>
|
|
|
|
#include <wininet.h>
|
|
|
|
#include <shellutils.h>
|
2021-12-26 01:15:30 +00:00
|
|
|
#include <ui/rosctrls.h>
|
2020-06-14 13:22:58 +00:00
|
|
|
#include <gdiplus.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2015-04-29 00:07:54 +00:00
|
|
|
#define SEARCH_TIMER_ID 'SR'
|
2020-07-24 08:07:43 +00:00
|
|
|
#define TREEVIEW_ICON_SIZE 24
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
// **** CSideTreeView ****
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
CSideTreeView::CSideTreeView()
|
|
|
|
: CUiWindow(),
|
|
|
|
hImageTreeView(ImageList_Create(TREEVIEW_ICON_SIZE, TREEVIEW_ICON_SIZE, GetSystemColorDepth() | ILC_MASK, 0, 1))
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
HTREEITEM
|
|
|
|
CSideTreeView::AddItem(HTREEITEM hParent, CStringW &Text, INT Image, INT SelectedImage, LPARAM lParam)
|
2020-07-21 14:13:39 +00:00
|
|
|
{
|
2020-07-24 08:07:43 +00:00
|
|
|
return CUiWindow<CTreeView>::AddItem(hParent, const_cast<LPWSTR>(Text.GetString()), Image, SelectedImage, lParam);
|
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
HTREEITEM
|
|
|
|
CSideTreeView::AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
CStringW szText;
|
2020-08-25 09:06:30 +00:00
|
|
|
INT Index = 0;
|
2020-07-24 08:07:43 +00:00
|
|
|
HICON hIcon;
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
hIcon = (HICON)LoadImageW(
|
|
|
|
hInst, MAKEINTRESOURCE(IconIndex), IMAGE_ICON, TREEVIEW_ICON_SIZE, TREEVIEW_ICON_SIZE, LR_CREATEDIBSECTION);
|
2020-07-24 08:07:43 +00:00
|
|
|
if (hIcon)
|
|
|
|
{
|
|
|
|
Index = ImageList_AddIcon(hImageTreeView, hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
2020-07-21 14:13:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
szText.LoadStringW(TextIndex);
|
|
|
|
return AddItem(hRootItem, szText, Index, Index, TextIndex);
|
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
HIMAGELIST
|
|
|
|
CSideTreeView::SetImageList()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
return CUiWindow<CTreeView>::SetImageList(hImageTreeView, TVSIL_NORMAL);
|
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CSideTreeView::DestroyImageList()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
if (hImageTreeView)
|
|
|
|
ImageList_Destroy(hImageTreeView);
|
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
CSideTreeView::~CSideTreeView()
|
2020-07-21 14:13:39 +00:00
|
|
|
{
|
2020-07-24 08:07:43 +00:00
|
|
|
DestroyImageList();
|
|
|
|
}
|
|
|
|
// **** CSideTreeView ****
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
// **** CMainWindow ****
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2024-03-22 17:20:35 +00:00
|
|
|
CMainWindow::CMainWindow(CAppDB *db, BOOL bAppwiz) : m_ClientPanel(NULL), m_Db(db), m_bAppwizMode(bAppwiz), SelectedEnumType(ENUM_ALL_INSTALLED)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
CMainWindow::~CMainWindow()
|
|
|
|
{
|
|
|
|
LayoutCleanup();
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::InitCategoriesList()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-05-21 22:40:56 +00:00
|
|
|
HTREEITEM hRootItemAvailable;
|
2020-07-24 08:07:43 +00:00
|
|
|
|
|
|
|
hRootItemInstalled = m_TreeView->AddCategory(TVI_ROOT, IDS_INSTALLED, IDI_CATEGORY);
|
|
|
|
m_TreeView->AddCategory(hRootItemInstalled, IDS_APPLICATIONS, IDI_APPS);
|
|
|
|
m_TreeView->AddCategory(hRootItemInstalled, IDS_UPDATES, IDI_APPUPD);
|
|
|
|
|
2024-03-22 17:20:35 +00:00
|
|
|
// Do not show any other categories in APPWIZ-mode.
|
|
|
|
if (m_bAppwizMode)
|
|
|
|
goto Finish;
|
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
m_TreeView->AddCategory(TVI_ROOT, IDS_SELECTEDFORINST, IDI_SELECTEDFORINST);
|
|
|
|
|
|
|
|
hRootItemAvailable = m_TreeView->AddCategory(TVI_ROOT, IDS_AVAILABLEFORINST, IDI_CATEGORY);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_AUDIO, IDI_CAT_AUDIO);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_VIDEO, IDI_CAT_VIDEO);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_GRAPHICS, IDI_CAT_GRAPHICS);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_GAMES, IDI_CAT_GAMES);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_INTERNET, IDI_CAT_INTERNET);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_OFFICE, IDI_CAT_OFFICE);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_DEVEL, IDI_CAT_DEVEL);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_EDU, IDI_CAT_EDU);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_ENGINEER, IDI_CAT_ENGINEER);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_FINANCE, IDI_CAT_FINANCE);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_SCIENCE, IDI_CAT_SCIENCE);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_TOOLS, IDI_CAT_TOOLS);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_DRIVERS, IDI_CAT_DRIVERS);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_LIBS, IDI_CAT_LIBS);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_THEMES, IDI_CAT_THEMES);
|
|
|
|
m_TreeView->AddCategory(hRootItemAvailable, IDS_CAT_OTHER, IDI_CAT_OTHER);
|
|
|
|
|
2024-03-22 17:20:35 +00:00
|
|
|
Finish:
|
2020-07-24 08:07:43 +00:00
|
|
|
m_TreeView->SetImageList();
|
|
|
|
m_TreeView->Expand(hRootItemInstalled, TVE_EXPAND);
|
2024-03-22 17:20:35 +00:00
|
|
|
if (!m_bAppwizMode)
|
|
|
|
m_TreeView->Expand(hRootItemAvailable, TVE_EXPAND);
|
|
|
|
m_TreeView->SelectItem(m_bAppwizMode ? hRootItemInstalled : hRootItemAvailable);
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::CreateStatusBar()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
m_StatusBar = new CUiWindow<CStatusBar>();
|
|
|
|
m_StatusBar->m_VerticalAlignment = UiAlign_RightBtm;
|
|
|
|
m_StatusBar->m_HorizontalAlignment = UiAlign_Stretch;
|
|
|
|
m_ClientPanel->Children().Append(m_StatusBar);
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
return m_StatusBar->Create(m_hWnd, (HMENU)IDC_STATUSBAR) != NULL;
|
|
|
|
}
|
2017-07-10 21:02:24 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::CreateTreeView()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
m_TreeView = new CSideTreeView();
|
|
|
|
m_TreeView->m_VerticalAlignment = UiAlign_Stretch;
|
|
|
|
m_TreeView->m_HorizontalAlignment = UiAlign_Stretch;
|
|
|
|
m_VSplitter->First().Append(m_TreeView);
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
return m_TreeView->Create(m_hWnd) != NULL;
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::CreateApplicationView()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
m_ApplicationView = new CApplicationView(this); // pass this to ApplicationView for callback purpose
|
|
|
|
m_ApplicationView->m_VerticalAlignment = UiAlign_Stretch;
|
|
|
|
m_ApplicationView->m_HorizontalAlignment = UiAlign_Stretch;
|
|
|
|
m_VSplitter->Second().Append(m_ApplicationView);
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
return m_ApplicationView->Create(m_hWnd) != NULL;
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::CreateVSplitter()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
m_VSplitter = new CUiSplitPanel();
|
|
|
|
m_VSplitter->m_VerticalAlignment = UiAlign_Stretch;
|
|
|
|
m_VSplitter->m_HorizontalAlignment = UiAlign_Stretch;
|
|
|
|
m_VSplitter->m_DynamicFirst = FALSE;
|
|
|
|
m_VSplitter->m_Horizontal = FALSE;
|
|
|
|
m_VSplitter->m_MinFirst = 0;
|
2020-07-29 10:50:57 +00:00
|
|
|
|
|
|
|
// TODO: m_MinSecond should be calculate dynamically instead of hard-coded
|
|
|
|
m_VSplitter->m_MinSecond = 480;
|
2020-07-24 08:07:43 +00:00
|
|
|
m_VSplitter->m_Pos = 240;
|
|
|
|
m_ClientPanel->Children().Append(m_VSplitter);
|
|
|
|
|
|
|
|
return m_VSplitter->Create(m_hWnd) != NULL;
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::CreateLayout()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
BOOL b = TRUE;
|
|
|
|
bUpdating = TRUE;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
m_ClientPanel = new CUiPanel();
|
|
|
|
m_ClientPanel->m_VerticalAlignment = UiAlign_Stretch;
|
|
|
|
m_ClientPanel->m_HorizontalAlignment = UiAlign_Stretch;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
// Top level
|
|
|
|
b = b && CreateStatusBar();
|
|
|
|
b = b && CreateVSplitter();
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
// Inside V Splitter
|
|
|
|
b = b && CreateTreeView();
|
|
|
|
b = b && CreateApplicationView();
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
if (b)
|
|
|
|
{
|
|
|
|
RECT rBottom;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
/* Size status bar */
|
|
|
|
m_StatusBar->SendMessageW(WM_SIZE, 0, 0);
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
::GetWindowRect(m_StatusBar->m_hWnd, &rBottom);
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
m_VSplitter->m_Margin.bottom = rBottom.bottom - rBottom.top;
|
2015-04-27 15:01:40 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
bUpdating = FALSE;
|
|
|
|
return b;
|
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::LayoutCleanup()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
delete m_TreeView;
|
|
|
|
delete m_ApplicationView;
|
|
|
|
delete m_VSplitter;
|
|
|
|
delete m_StatusBar;
|
|
|
|
return;
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::InitControls()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
if (CreateLayout())
|
|
|
|
{
|
|
|
|
InitCategoriesList();
|
|
|
|
UpdateStatusBarText();
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
return TRUE;
|
2015-04-27 15:01:40 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-14 15:56:19 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
if (wParam == SIZE_MINIMIZED)
|
|
|
|
return;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
/* Size status bar */
|
|
|
|
m_StatusBar->SendMessage(WM_SIZE, 0, 0);
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
RECT r = {0, 0, LOWORD(lParam), HIWORD(lParam)};
|
2020-07-24 08:07:43 +00:00
|
|
|
HDWP hdwp = NULL;
|
|
|
|
INT count = m_ClientPanel->CountSizableChildren();
|
2017-07-12 22:59:26 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
hdwp = BeginDeferWindowPos(count);
|
|
|
|
if (hdwp)
|
|
|
|
{
|
|
|
|
hdwp = m_ClientPanel->OnParentSize(r, hdwp);
|
2017-07-12 22:59:26 +00:00
|
|
|
if (hdwp)
|
|
|
|
{
|
2020-07-24 08:07:43 +00:00
|
|
|
EndDeferWindowPos(hdwp);
|
2017-07-12 22:59:26 +00:00
|
|
|
}
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::RemoveSelectedAppFromRegistry()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
if (!IsInstalledEnum(SelectedEnumType))
|
|
|
|
return FALSE;
|
2019-04-28 03:45:12 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
CStringW szMsgText, szMsgTitle;
|
2019-04-28 03:45:12 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
if (!szMsgText.LoadStringW(IDS_APP_REG_REMOVE) || !szMsgTitle.LoadStringW(IDS_INFORMATION))
|
2020-07-24 08:07:43 +00:00
|
|
|
return FALSE;
|
2019-04-28 03:45:12 +00:00
|
|
|
|
2024-01-01 01:12:51 +00:00
|
|
|
CAppInfo *InstalledApp = (CAppInfo *)m_ApplicationView->GetFocusedItemData();
|
|
|
|
if (!InstalledApp)
|
|
|
|
return FALSE;
|
2021-09-13 01:33:14 +00:00
|
|
|
|
2024-01-01 01:12:51 +00:00
|
|
|
if (MessageBoxW(szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
|
2024-05-08 21:58:54 +00:00
|
|
|
return m_Db->RemoveInstalledAppFromRegistry(InstalledApp) == ERROR_SUCCESS;
|
2019-04-28 03:45:12 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-28 13:47:23 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::UninstallSelectedApp(BOOL bModify)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
if (!IsInstalledEnum(SelectedEnumType))
|
|
|
|
return FALSE;
|
2019-04-28 13:47:23 +00:00
|
|
|
|
2023-02-28 00:00:29 +00:00
|
|
|
CAppInfo *InstalledApp = (CAppInfo *)m_ApplicationView->GetFocusedItemData();
|
2020-09-15 20:50:12 +00:00
|
|
|
if (!InstalledApp)
|
|
|
|
return FALSE;
|
2020-07-24 08:07:43 +00:00
|
|
|
|
2024-05-08 21:58:54 +00:00
|
|
|
return InstalledApp->UninstallApplication(bModify ? UCF_MODIFY : UCF_NONE);
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2024-01-10 02:36:30 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::CheckAvailable()
|
|
|
|
{
|
|
|
|
if (m_Db->GetAvailableCount() == 0)
|
|
|
|
{
|
|
|
|
m_Db->RemoveCached();
|
|
|
|
m_Db->UpdateAvailable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
theResult = 0;
|
|
|
|
switch (Msg)
|
2015-04-27 15:01:40 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_CREATE:
|
|
|
|
if (!InitControls())
|
|
|
|
::PostMessageW(hwnd, WM_CLOSE, 0, 0);
|
2024-09-26 16:58:30 +00:00
|
|
|
::PostMessageW(hwnd, DM_REPOSITION, 0, 0);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
{
|
2024-09-26 16:58:30 +00:00
|
|
|
hMainWnd = NULL;
|
2023-02-20 18:30:02 +00:00
|
|
|
SaveSettings(hwnd, &SettingsInfo);
|
|
|
|
FreeLogs();
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
delete m_ClientPanel;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
PostQuitMessage(0);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2024-09-26 16:58:30 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
ShowWindow(SW_HIDE);
|
|
|
|
return g_Busy;
|
|
|
|
|
|
|
|
case WM_NOTIFY_OPERATIONCOMPLETED:
|
|
|
|
if (!g_Busy && !IsWindowVisible())
|
|
|
|
SendMessage(WM_CLOSE, 0, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DM_REPOSITION:
|
|
|
|
EmulateDialogReposition(hwnd); // We are not a real dialog, we need help from a real one
|
|
|
|
break;
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
OnCommand(wParam, lParam);
|
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_NOTIFY:
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
LPNMHDR data = (LPNMHDR)lParam;
|
|
|
|
|
|
|
|
switch (data->code)
|
2015-04-27 15:01:40 +00:00
|
|
|
{
|
2024-03-22 17:20:35 +00:00
|
|
|
case TVN_ITEMEXPANDING:
|
|
|
|
{
|
|
|
|
if (data->hwndFrom == m_TreeView->m_hWnd)
|
|
|
|
{
|
|
|
|
// APPWIZ-mode: forbid item collapse.
|
|
|
|
// FIXME: Prevent collapse (COMCTL32 is buggy)
|
|
|
|
// https://bugs.winehq.org/show_bug.cgi?id=53727
|
|
|
|
if (m_bAppwizMode && (((LPNMTREEVIEW)lParam)->action & TVE_TOGGLE) == TVE_COLLAPSE)
|
|
|
|
{
|
|
|
|
theResult = TRUE;
|
|
|
|
return TRUE; // Handled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case TVN_SELCHANGED:
|
2015-04-27 15:01:40 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
if (data->hwndFrom == m_TreeView->m_hWnd)
|
|
|
|
{
|
|
|
|
switch (((LPNMTREEVIEW)lParam)->itemNew.lParam)
|
|
|
|
{
|
|
|
|
case IDS_INSTALLED:
|
|
|
|
UpdateApplicationsList(ENUM_ALL_INSTALLED);
|
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_APPLICATIONS:
|
|
|
|
UpdateApplicationsList(ENUM_INSTALLED_APPLICATIONS);
|
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_UPDATES:
|
|
|
|
UpdateApplicationsList(ENUM_UPDATES);
|
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_AVAILABLEFORINST:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_ALL_AVAILABLE, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_AUDIO:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_AUDIO, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_DEVEL:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_DEVEL, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_DRIVERS:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_DRIVERS, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_EDU:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_EDU, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_ENGINEER:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_ENGINEER, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_FINANCE:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_FINANCE, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_GAMES:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_GAMES, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_GRAPHICS:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_GRAPHICS, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_INTERNET:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_INTERNET, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_LIBS:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_LIBS, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_OFFICE:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_OFFICE, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_OTHER:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_OTHER, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_SCIENCE:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_SCIENCE, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_TOOLS:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_TOOLS, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_VIDEO:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_VIDEO, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2018-01-02 20:45:59 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_CAT_THEMES:
|
2024-01-10 02:36:30 +00:00
|
|
|
UpdateApplicationsList(ENUM_CAT_THEMES, FALSE, TRUE);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2019-03-28 21:06:46 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case IDS_SELECTEDFORINST:
|
|
|
|
UpdateApplicationsList(ENUM_CAT_SELECTED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
}
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
2015-04-27 15:01:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_SIZE:
|
|
|
|
OnSize(hwnd, wParam, lParam);
|
|
|
|
break;
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_SIZING:
|
|
|
|
{
|
|
|
|
LPRECT pRect = (LPRECT)lParam;
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
if (pRect->right - pRect->left < 565)
|
|
|
|
pRect->right = pRect->left + 565;
|
2020-07-24 08:07:43 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
if (pRect->bottom - pRect->top < 300)
|
|
|
|
pRect->bottom = pRect->top + 300;
|
2020-07-24 08:07:43 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_SYSCOLORCHANGE:
|
2015-04-29 00:07:54 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
/* Forward WM_SYSCOLORCHANGE to common controls */
|
|
|
|
m_ApplicationView->SendMessageW(WM_SYSCOLORCHANGE, wParam, lParam);
|
|
|
|
m_TreeView->SendMessageW(WM_SYSCOLORCHANGE, wParam, lParam);
|
2015-04-29 00:07:54 +00:00
|
|
|
}
|
2020-07-24 08:07:43 +00:00
|
|
|
break;
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2024-06-13 00:20:41 +00:00
|
|
|
case WM_SETTINGCHANGE:
|
|
|
|
if (wParam == SPI_SETNONCLIENTMETRICS || wParam == SPI_SETICONMETRICS)
|
|
|
|
{
|
|
|
|
DestroyIcon(g_hDefaultPackageIcon);
|
|
|
|
g_hDefaultPackageIcon = NULL; // Trigger imagelist recreation on next load
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case WM_TIMER:
|
|
|
|
if (wParam == SEARCH_TIMER_ID)
|
|
|
|
{
|
|
|
|
::KillTimer(hwnd, SEARCH_TIMER_ID);
|
2020-07-24 08:07:43 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
UpdateApplicationsList(SelectedEnumType);
|
|
|
|
}
|
|
|
|
break;
|
2020-05-14 12:28:57 +00:00
|
|
|
}
|
2023-02-20 18:30:02 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::ShowAboutDlg()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
CStringW szApp;
|
|
|
|
CStringW szAuthors;
|
2020-07-24 08:07:43 +00:00
|
|
|
|
|
|
|
szApp.LoadStringW(IDS_APPTITLE);
|
|
|
|
szAuthors.LoadStringW(IDS_APP_AUTHORS);
|
2023-08-09 09:53:13 +00:00
|
|
|
ShellAboutW(m_hWnd, szApp, szAuthors,
|
|
|
|
LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN)));
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::OnCommand(WPARAM wParam, LPARAM lParam)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
const BOOL bReload = TRUE;
|
2020-07-24 08:07:43 +00:00
|
|
|
WORD wCommand = LOWORD(wParam);
|
2020-05-14 12:28:57 +00:00
|
|
|
|
2020-07-29 10:50:57 +00:00
|
|
|
if (!lParam)
|
2015-04-29 00:07:54 +00:00
|
|
|
{
|
2020-07-29 10:50:57 +00:00
|
|
|
switch (wCommand)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
case ID_SETTINGS:
|
|
|
|
CreateSettingsDlg(m_hWnd);
|
|
|
|
break;
|
2020-07-24 08:07:43 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case ID_EXIT:
|
|
|
|
PostMessageW(WM_CLOSE, 0, 0);
|
|
|
|
break;
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case ID_SEARCH:
|
|
|
|
m_ApplicationView->SetFocusOnSearchBar();
|
|
|
|
break;
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
case ID_INSTALL:
|
|
|
|
if (IsAvailableEnum(SelectedEnumType))
|
2017-08-26 22:43:05 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
if (!m_Selected.IsEmpty())
|
2020-07-29 10:50:57 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
if (DownloadListOfApplications(m_Selected, FALSE))
|
2020-07-29 10:50:57 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
m_Selected.RemoveAll();
|
|
|
|
UpdateApplicationsList(SelectedEnumType);
|
2020-07-29 10:50:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-02-28 00:00:29 +00:00
|
|
|
CAppInfo *App = (CAppInfo *)m_ApplicationView->GetFocusedItemData();
|
2023-02-20 18:30:02 +00:00
|
|
|
if (App)
|
|
|
|
{
|
|
|
|
InstallApplication(App);
|
|
|
|
}
|
2020-07-29 10:50:57 +00:00
|
|
|
}
|
2017-08-26 22:43:05 +00:00
|
|
|
}
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_UNINSTALL:
|
|
|
|
if (UninstallSelectedApp(FALSE))
|
|
|
|
UpdateApplicationsList(SelectedEnumType, bReload);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODIFY:
|
|
|
|
if (UninstallSelectedApp(TRUE))
|
|
|
|
UpdateApplicationsList(SelectedEnumType, bReload);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_REGREMOVE:
|
|
|
|
if (RemoveSelectedAppFromRegistry())
|
|
|
|
UpdateApplicationsList(SelectedEnumType, bReload);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_REFRESH:
|
2024-05-10 15:59:19 +00:00
|
|
|
UpdateApplicationsList(SelectedEnumType, bReload);
|
2023-02-20 18:30:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_RESETDB:
|
|
|
|
m_Db->RemoveCached();
|
|
|
|
UpdateApplicationsList(SelectedEnumType, bReload);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_HELP:
|
|
|
|
MessageBoxW(L"Help not implemented yet", NULL, MB_OK);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_ABOUT:
|
|
|
|
ShowAboutDlg();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CHECK_ALL:
|
|
|
|
m_ApplicationView->CheckAll();
|
|
|
|
break;
|
2023-05-21 22:40:56 +00:00
|
|
|
|
|
|
|
case ID_ACTIVATE_APPWIZ:
|
|
|
|
if (hRootItemInstalled)
|
|
|
|
m_TreeView->SelectItem(hRootItemInstalled);
|
|
|
|
break;
|
2020-07-29 10:50:57 +00:00
|
|
|
}
|
2015-04-29 00:07:54 +00:00
|
|
|
}
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::UpdateStatusBarText()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
if (m_StatusBar)
|
2015-04-29 00:07:54 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
CStringW szBuffer;
|
2024-09-15 19:12:36 +00:00
|
|
|
szBuffer.Format(IDS_APPS_COUNT, m_ApplicationView->GetItemCount());
|
|
|
|
|
|
|
|
// Append the number of selected apps if not in APPWIZ-mode.
|
|
|
|
if (!m_bAppwizMode)
|
|
|
|
{
|
|
|
|
CStringW szBuffer2;
|
|
|
|
szBuffer2.Format(IDS_APPS_SELECT_COUNT, m_Selected.GetCount());
|
|
|
|
szBuffer += szBuffer2;
|
|
|
|
}
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
m_StatusBar->SetText(szBuffer);
|
2015-04-29 00:07:54 +00:00
|
|
|
}
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
2023-02-28 00:00:29 +00:00
|
|
|
CMainWindow::AddApplicationsToView(CAtlList<CAppInfo *> &List)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
POSITION CurrentListPosition = List.GetHeadPosition();
|
|
|
|
while (CurrentListPosition)
|
2015-04-29 00:07:54 +00:00
|
|
|
{
|
2023-02-28 00:00:29 +00:00
|
|
|
CAppInfo *Info = List.GetNext(CurrentListPosition);
|
2023-02-20 18:30:02 +00:00
|
|
|
if (szSearchPattern.IsEmpty() || SearchPatternMatch(Info->szDisplayName, szSearchPattern) ||
|
|
|
|
SearchPatternMatch(Info->szComments, szSearchPattern))
|
|
|
|
{
|
|
|
|
BOOL bSelected = m_Selected.Find(Info) != NULL;
|
|
|
|
m_ApplicationView->AddApplication(Info, bSelected);
|
|
|
|
}
|
2015-04-29 00:07:54 +00:00
|
|
|
}
|
2024-06-13 00:20:41 +00:00
|
|
|
m_ApplicationView->AddApplication(NULL, FALSE); // Tell the list we are done
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
2024-01-10 02:36:30 +00:00
|
|
|
CMainWindow::UpdateApplicationsList(AppsCategories EnumType, BOOL bReload, BOOL bCheckAvailable)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2024-03-22 17:20:35 +00:00
|
|
|
// Only installed applications should be enumerated in APPWIZ-mode.
|
|
|
|
if (m_bAppwizMode && !IsInstalledEnum(EnumType))
|
|
|
|
{
|
|
|
|
ATLASSERT(FALSE && "Should not be called in APPWIZ-mode");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
bUpdating = TRUE;
|
|
|
|
|
2024-06-13 00:20:41 +00:00
|
|
|
if (HCURSOR hCursor = LoadCursor(NULL, IDC_APPSTARTING))
|
|
|
|
{
|
|
|
|
// The database (.ini files) is parsed on the UI thread, let the user know we are busy
|
|
|
|
SetCursor(hCursor);
|
|
|
|
PostMessage(WM_SETCURSOR, (WPARAM)m_hWnd, MAKELONG(HTCLIENT, WM_MOUSEMOVE));
|
|
|
|
}
|
|
|
|
|
2024-01-10 02:36:30 +00:00
|
|
|
if (bCheckAvailable)
|
|
|
|
CheckAvailable();
|
|
|
|
|
2024-08-22 21:21:59 +00:00
|
|
|
BOOL TryRestoreSelection = SelectedEnumType == EnumType;
|
2023-02-20 18:30:02 +00:00
|
|
|
if (SelectedEnumType != EnumType)
|
2020-07-24 08:07:43 +00:00
|
|
|
SelectedEnumType = EnumType;
|
2023-02-20 18:30:02 +00:00
|
|
|
|
2024-08-22 21:21:59 +00:00
|
|
|
CApplicationView::RESTORELISTSELECTION RestoreSelection;
|
|
|
|
if (TryRestoreSelection)
|
|
|
|
m_ApplicationView->GetRestoreListSelectionData(RestoreSelection);
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
if (bReload)
|
|
|
|
m_Selected.RemoveAll();
|
2020-07-21 14:13:39 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
m_ApplicationView->SetRedraw(FALSE);
|
|
|
|
if (IsInstalledEnum(EnumType))
|
2020-07-21 14:13:39 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
if (bReload)
|
|
|
|
m_Db->UpdateInstalled();
|
|
|
|
|
2020-07-29 10:50:57 +00:00
|
|
|
// set the display type of application-view. this will remove all the item in application-view too.
|
|
|
|
m_ApplicationView->SetDisplayAppType(AppViewTypeInstalledApps);
|
2019-04-28 03:39:02 +00:00
|
|
|
|
2023-02-28 00:00:29 +00:00
|
|
|
CAtlList<CAppInfo *> List;
|
2023-02-20 18:30:02 +00:00
|
|
|
m_Db->GetApps(List, EnumType);
|
|
|
|
AddApplicationsToView(List);
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
|
|
|
else if (IsAvailableEnum(EnumType))
|
2017-07-26 13:30:46 +00:00
|
|
|
{
|
2024-03-22 17:20:35 +00:00
|
|
|
// We shouldn't get there in APPWIZ-mode.
|
|
|
|
ATLASSERT(!m_bAppwizMode);
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
if (bReload)
|
|
|
|
m_Db->UpdateAvailable();
|
|
|
|
|
2020-07-29 10:50:57 +00:00
|
|
|
// set the display type of application-view. this will remove all the item in application-view too.
|
|
|
|
m_ApplicationView->SetDisplayAppType(AppViewTypeAvailableApps);
|
2017-07-26 13:30:46 +00:00
|
|
|
|
2021-09-13 01:33:14 +00:00
|
|
|
// enum available softwares
|
2023-02-20 18:30:02 +00:00
|
|
|
if (EnumType == ENUM_CAT_SELECTED)
|
|
|
|
{
|
|
|
|
AddApplicationsToView(m_Selected);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-02-28 00:00:29 +00:00
|
|
|
CAtlList<CAppInfo *> List;
|
2023-02-20 18:30:02 +00:00
|
|
|
m_Db->GetApps(List, EnumType);
|
|
|
|
AddApplicationsToView(List);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ATLASSERT(0 && "This should be unreachable!");
|
2017-07-26 13:30:46 +00:00
|
|
|
}
|
2024-08-22 21:21:59 +00:00
|
|
|
|
|
|
|
if (TryRestoreSelection)
|
|
|
|
m_ApplicationView->RestoreListSelection(RestoreSelection);
|
2020-07-24 08:07:43 +00:00
|
|
|
m_ApplicationView->SetRedraw(TRUE);
|
|
|
|
m_ApplicationView->RedrawWindow(0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN); // force the child window to repaint
|
|
|
|
UpdateStatusBarText();
|
2021-12-30 19:17:32 +00:00
|
|
|
|
|
|
|
CStringW text;
|
|
|
|
if (m_ApplicationView->GetItemCount() == 0 && !szSearchPattern.IsEmpty())
|
|
|
|
{
|
|
|
|
text.LoadString(IDS_NO_SEARCH_RESULTS);
|
|
|
|
}
|
|
|
|
m_ApplicationView->SetWatermark(text);
|
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
bUpdating = FALSE;
|
|
|
|
}
|
2017-06-23 07:04:43 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
ATL::CWndClassInfo &
|
|
|
|
CMainWindow::GetWndClassInfo()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
DWORD csStyle = CS_VREDRAW | CS_HREDRAW;
|
2023-02-20 18:30:02 +00:00
|
|
|
static ATL::CWndClassInfo wc = {
|
|
|
|
{sizeof(WNDCLASSEX), csStyle, StartWindowProc, 0, 0, NULL,
|
|
|
|
LoadIconW(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCEW(IDI_MAIN)), LoadCursorW(NULL, IDC_ARROW),
|
|
|
|
(HBRUSH)(COLOR_BTNFACE + 1), MAKEINTRESOURCEW(IDR_MAINMENU), szWindowClass, NULL},
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
IDC_ARROW,
|
|
|
|
TRUE,
|
|
|
|
0,
|
|
|
|
_T("")};
|
2020-07-24 08:07:43 +00:00
|
|
|
return wc;
|
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
HWND
|
|
|
|
CMainWindow::Create()
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2024-09-26 16:06:13 +00:00
|
|
|
const CStringW szWindowName(MAKEINTRESOURCEW(m_bAppwizMode ? IDS_APPWIZ_TITLE : IDS_APPTITLE));
|
2020-07-24 08:07:43 +00:00
|
|
|
|
|
|
|
RECT r = {
|
|
|
|
(SettingsInfo.bSaveWndPos ? SettingsInfo.Left : CW_USEDEFAULT),
|
|
|
|
(SettingsInfo.bSaveWndPos ? SettingsInfo.Top : CW_USEDEFAULT),
|
2023-02-20 18:30:02 +00:00
|
|
|
(SettingsInfo.bSaveWndPos ? SettingsInfo.Width : 680), (SettingsInfo.bSaveWndPos ? SettingsInfo.Height : 450)};
|
2020-07-24 08:07:43 +00:00
|
|
|
r.right += r.left;
|
|
|
|
r.bottom += r.top;
|
2015-04-29 00:07:54 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
return CWindowImpl::Create(
|
|
|
|
NULL, r, szWindowName.GetString(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// this function is called when a item of application-view is checked/unchecked
|
|
|
|
// CallbackParam is the param passed to application-view when adding the item (the one getting focus now).
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
|
|
|
CMainWindow::ItemCheckStateChanged(BOOL bChecked, LPVOID CallbackParam)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
if (bUpdating)
|
|
|
|
return;
|
2017-08-27 00:00:45 +00:00
|
|
|
|
2023-02-28 00:00:29 +00:00
|
|
|
CAppInfo *Info = (CAppInfo *)CallbackParam;
|
2023-02-20 18:30:02 +00:00
|
|
|
|
|
|
|
if (bChecked)
|
|
|
|
{
|
|
|
|
m_Selected.AddTail(Info);
|
2015-04-27 15:01:40 +00:00
|
|
|
}
|
2020-07-24 08:07:43 +00:00
|
|
|
else
|
2015-04-27 15:01:40 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
POSITION Pos = m_Selected.Find(Info);
|
|
|
|
ATLASSERT(Pos != NULL);
|
|
|
|
|
|
|
|
if (Pos != NULL)
|
|
|
|
{
|
|
|
|
m_Selected.RemoveAt(Pos);
|
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
}
|
2023-02-20 18:30:02 +00:00
|
|
|
|
|
|
|
UpdateStatusBarText();
|
2020-07-24 08:07:43 +00:00
|
|
|
}
|
2020-02-09 16:54:18 +00:00
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
// this function is called when one or more application(s) should be installed
|
2020-07-24 08:07:43 +00:00
|
|
|
// if Info is not zero, this app should be installed. otherwise those checked apps should be installed
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
2023-02-28 00:00:29 +00:00
|
|
|
CMainWindow::InstallApplication(CAppInfo *Info)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
if (Info)
|
2020-07-21 14:13:39 +00:00
|
|
|
{
|
2021-10-03 18:35:13 +00:00
|
|
|
if (DownloadApplication(Info))
|
2020-07-21 14:13:39 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
UpdateApplicationsList(SelectedEnumType);
|
2020-07-21 14:13:39 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2020-07-24 08:07:43 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
BOOL
|
|
|
|
CMainWindow::SearchTextChanged(CStringW &SearchText)
|
2020-07-29 10:50:57 +00:00
|
|
|
{
|
|
|
|
if (szSearchPattern == SearchText)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
szSearchPattern = SearchText;
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
DWORD dwDelay = 0;
|
2020-07-29 10:50:57 +00:00
|
|
|
SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
|
|
|
|
SetTimer(SEARCH_TIMER_ID, dwDelay);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
void
|
|
|
|
CMainWindow::HandleTabOrder(int direction)
|
2020-07-24 08:07:43 +00:00
|
|
|
{
|
|
|
|
ATL::CSimpleArray<HWND> TabOrderHwndList;
|
2020-02-09 16:54:18 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
m_TreeView->AppendTabOrderWindow(direction, TabOrderHwndList);
|
|
|
|
m_ApplicationView->AppendTabOrderWindow(direction, TabOrderHwndList);
|
2020-02-09 16:54:18 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
if (TabOrderHwndList.GetSize() == 0)
|
|
|
|
{
|
|
|
|
// in case the list is empty
|
|
|
|
return;
|
2020-02-09 16:54:18 +00:00
|
|
|
}
|
2015-04-27 15:01:40 +00:00
|
|
|
|
2020-07-24 08:07:43 +00:00
|
|
|
int FocusIndex;
|
|
|
|
|
|
|
|
if ((FocusIndex = TabOrderHwndList.Find(GetFocus())) == -1)
|
|
|
|
{
|
|
|
|
FocusIndex = 0; // focus the first window in the list
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FocusIndex += direction;
|
2023-02-20 18:30:02 +00:00
|
|
|
FocusIndex +=
|
|
|
|
TabOrderHwndList.GetSize(); // FocusIndex might be negative. we don't want to mod a negative number
|
2020-07-24 08:07:43 +00:00
|
|
|
FocusIndex %= TabOrderHwndList.GetSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
::SetFocus(TabOrderHwndList[FocusIndex]);
|
|
|
|
return;
|
2020-07-21 14:13:39 +00:00
|
|
|
}
|
2020-07-24 08:07:43 +00:00
|
|
|
// **** CMainWindow ****
|
|
|
|
|
2023-02-20 18:30:02 +00:00
|
|
|
VOID
|
2023-05-23 20:50:04 +00:00
|
|
|
MainWindowLoop(CMainWindow *wnd, INT nShowCmd)
|
2019-04-28 03:10:45 +00:00
|
|
|
{
|
|
|
|
HACCEL KeyBrd;
|
|
|
|
MSG Msg;
|
|
|
|
|
2019-04-28 03:30:32 +00:00
|
|
|
hMainWnd = wnd->Create();
|
|
|
|
if (!hMainWnd)
|
|
|
|
return;
|
2019-04-28 03:10:45 +00:00
|
|
|
|
2019-04-28 03:30:32 +00:00
|
|
|
/* Maximize it if we must */
|
2019-04-28 15:15:55 +00:00
|
|
|
wnd->ShowWindow((SettingsInfo.bSaveWndPos && SettingsInfo.Maximized) ? SW_MAXIMIZE : nShowCmd);
|
|
|
|
wnd->UpdateWindow();
|
2019-04-28 03:10:45 +00:00
|
|
|
|
2019-04-28 03:30:32 +00:00
|
|
|
/* Load the menu hotkeys */
|
|
|
|
KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
|
|
|
|
|
|
|
|
/* Message Loop */
|
|
|
|
while (GetMessageW(&Msg, NULL, 0, 0))
|
|
|
|
{
|
|
|
|
if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
|
2019-04-28 03:10:45 +00:00
|
|
|
{
|
2023-02-20 18:30:02 +00:00
|
|
|
if (Msg.message == WM_CHAR && Msg.wParam == VK_TAB)
|
2020-02-09 16:54:18 +00:00
|
|
|
{
|
|
|
|
// Move backwards if shift is held down
|
|
|
|
int direction = (GetKeyState(VK_SHIFT) & 0x8000) ? -1 : 1;
|
|
|
|
|
|
|
|
wnd->HandleTabOrder(direction);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-04-28 03:30:32 +00:00
|
|
|
TranslateMessage(&Msg);
|
|
|
|
DispatchMessageW(&Msg);
|
2019-04-28 03:10:45 +00:00
|
|
|
}
|
2019-04-28 03:30:32 +00:00
|
|
|
}
|
2019-04-28 03:10:45 +00:00
|
|
|
}
|