mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 06:15:52 +00:00
Dmitry Chapyshev <lentind@yandex.ru>
- Get rid of hardcoded path to downloader.xml, it properly gets the path now. Also changed the logic slightly: now the file is firstly being searched in the local folder, and only then in system32. - Do a Settings dialog (choose a directory where to download files to, if a user wants to remove installation files after the app has been installed), all options are stored / loaded from the registry. Only the "Update server" option does not work now. - A few GUI/designs fixes and improvements, now it looks better. - Add a button for Settings in the main waindow. - Fixed code formatting in a few places. - Change bitmap to icons on the Update and Help buttons, imho it's the proper way. - Add 3 new categories to the list. - Other misc fixes. - All translated resources are updated, so no translations are lost! svn path=/trunk/; revision=29614
This commit is contained in:
parent
bda7147058
commit
ef1f939e4f
22 changed files with 790 additions and 246 deletions
|
@ -8,14 +8,14 @@
|
|||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <shlwapi.h>
|
||||
#include <shlobj.h>
|
||||
#include "resources.h"
|
||||
#include "structures.h"
|
||||
|
||||
#define XML_PATH "C:\\ReactOS\\system32\\downloader.xml"
|
||||
|
||||
HWND hwnd, hCategories, hApps, hDownloadButton, hUninstallButton, hUpdateButton, hHelpButton;
|
||||
HWND hwnd, hCategories, hApps, hDownloadButton, hUninstallButton, hUpdateButton, hHelpButton, hProfButton;
|
||||
HBITMAP hLogo, hUnderline;
|
||||
WCHAR* DescriptionHeadline = L"";
|
||||
WCHAR* DescriptionText = L"";
|
||||
|
@ -30,7 +30,8 @@ VOID FreeTree (struct Category* Node);
|
|||
WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
|
||||
|
||||
|
||||
BOOL getUninstaller(WCHAR* RegName, WCHAR* Uninstaller) {
|
||||
BOOL
|
||||
getUninstaller(WCHAR* RegName, WCHAR* Uninstaller) {
|
||||
|
||||
const DWORD ArraySize = 200;
|
||||
|
||||
|
@ -69,7 +70,8 @@ BOOL getUninstaller(WCHAR* RegName, WCHAR* Uninstaller) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void ShowMessage (WCHAR* title, WCHAR* message)
|
||||
void
|
||||
ShowMessage (WCHAR* title, WCHAR* message)
|
||||
{
|
||||
DescriptionHeadline = title;
|
||||
DescriptionText = message;
|
||||
|
@ -77,7 +79,8 @@ void ShowMessage (WCHAR* title, WCHAR* message)
|
|||
UpdateWindow(hwnd);
|
||||
}
|
||||
|
||||
void AddItems (HWND hwnd, struct Category* Category, struct Category* Parent)
|
||||
void
|
||||
AddItems(HWND hwnd, struct Category* Category, struct Category* Parent)
|
||||
{
|
||||
TV_INSERTSTRUCTW Insert;
|
||||
|
||||
|
@ -99,7 +102,8 @@ void AddItems (HWND hwnd, struct Category* Category, struct Category* Parent)
|
|||
AddItems (hwnd,Category->Children,Category);
|
||||
}
|
||||
|
||||
void CategoryChoosen (HWND hwnd, struct Category* Category)
|
||||
void
|
||||
CategoryChoosen(HWND hwnd, struct Category* Category)
|
||||
{
|
||||
struct Application* CurrentApplication;
|
||||
TV_INSERTSTRUCTW Insert;
|
||||
|
@ -139,39 +143,84 @@ void CategoryChoosen (HWND hwnd, struct Category* Category)
|
|||
}
|
||||
}
|
||||
|
||||
BOOL SetupControls (HWND hwnd)
|
||||
BOOL
|
||||
SetupControls (HWND hwnd)
|
||||
{
|
||||
TV_INSERTSTRUCTW Insert = {0};
|
||||
HIMAGELIST hImageList;
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
WCHAR Cats[MAX_STRING_LENGHT], Apps[MAX_STRING_LENGHT];
|
||||
TCHAR Buf[MAX_PATH];
|
||||
char Tmp[MAX_PATH];
|
||||
int i;
|
||||
|
||||
// Getting downloader.xml path
|
||||
if(!GetSystemDirectory(Buf,sizeof(Buf)/sizeof(char))) return FALSE;
|
||||
lstrcat((LPTSTR)Buf, L"\\downloader.xml");
|
||||
for (i = 0; i < _tcslen(Buf) + 1; i++) Tmp[i] = Buf[i];
|
||||
|
||||
// Parse the XML file
|
||||
if (ProcessXML (XML_PATH, &Root) == FALSE)
|
||||
if (!ProcessXML(Tmp, &Root))
|
||||
return FALSE;
|
||||
|
||||
LoadStringW(hInstance, IDS_CATS_TITLE, Cats, MAX_STRING_LENGHT);
|
||||
LoadStringW(hInstance, IDS_APPS_TITLE, Apps, MAX_STRING_LENGHT);
|
||||
LoadStringW(hInstance, IDS_CATS_TITLE, Cats, MAX_STRING_LENGHT);
|
||||
LoadStringW(hInstance, IDS_APPS_TITLE, Apps, MAX_STRING_LENGHT);
|
||||
|
||||
// Set up the controls
|
||||
hCategories = CreateWindowExW(0, WC_TREEVIEWW, Cats, WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
|
||||
hCategories = CreateWindowExW(0, WC_TREEVIEWW, Cats,
|
||||
WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
|
||||
0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
|
||||
|
||||
hApps = CreateWindowExW(0, WC_TREEVIEWW, Apps,
|
||||
WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
|
||||
0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
|
||||
|
||||
hApps = CreateWindowExW(0, WC_TREEVIEWW, Apps, WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
|
||||
0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
|
||||
hLogo = LoadBitmap(GetModuleHandle(NULL),
|
||||
MAKEINTRESOURCE(IDB_LOGO));
|
||||
hUnderline = LoadBitmap(GetModuleHandle(NULL),
|
||||
MAKEINTRESOURCE(IDB_UNDERLINE));
|
||||
|
||||
hLogo = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_LOGO));
|
||||
hUnderline = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_UNDERLINE));
|
||||
|
||||
hHelpButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 550, 10, 40, 40, hwnd, 0, hInstance, NULL);
|
||||
hUpdateButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 500, 10, 40, 40, hwnd, 0, hInstance, NULL);
|
||||
hDownloadButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 330, 505, 140, 33, hwnd, 0, hInstance, NULL);
|
||||
hUninstallButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 260, 505, 140, 33, hwnd, 0, hInstance, NULL);
|
||||
|
||||
SendMessageW(hHelpButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_HELP)));
|
||||
SendMessageW(hUpdateButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UPDATE)));
|
||||
SendMessageW(hDownloadButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_DOWNLOAD)));
|
||||
SendMessageW(hUninstallButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UNINSTALL)));
|
||||
hHelpButton = CreateWindowW(L"Button", L"",
|
||||
WS_CHILD | WS_VISIBLE | BS_ICON,
|
||||
550, 10, 40, 40,
|
||||
hwnd, 0, hInstance, NULL);
|
||||
hUpdateButton = CreateWindowW(L"Button", L"",
|
||||
WS_CHILD | WS_VISIBLE | BS_ICON,
|
||||
450, 10, 40, 40,
|
||||
hwnd, 0, hInstance, NULL);
|
||||
hProfButton = CreateWindowW(L"Button", L"",
|
||||
WS_CHILD | WS_VISIBLE | BS_ICON,
|
||||
500, 10, 40, 40,
|
||||
hwnd, 0, hInstance, NULL);
|
||||
hDownloadButton = CreateWindowW(L"Button", L"",
|
||||
WS_CHILD | WS_VISIBLE | BS_BITMAP,
|
||||
330, 505, 140, 33,
|
||||
hwnd, 0, hInstance, NULL);
|
||||
hUninstallButton = CreateWindowW(L"Button", L"",
|
||||
WS_CHILD | WS_VISIBLE | BS_BITMAP,
|
||||
260, 505, 140, 33,
|
||||
hwnd, 0, hInstance, NULL);
|
||||
|
||||
SendMessageW(hProfButton,
|
||||
BM_SETIMAGE,
|
||||
(WPARAM)IMAGE_ICON,
|
||||
(LPARAM)(HANDLE)LoadIcon(hInstance,MAKEINTRESOURCE(IDI_PROF)));
|
||||
SendMessageW(hHelpButton,
|
||||
BM_SETIMAGE,
|
||||
(WPARAM)IMAGE_ICON,
|
||||
(LPARAM)(HANDLE)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_HELP)));
|
||||
SendMessageW(hUpdateButton,
|
||||
BM_SETIMAGE,
|
||||
(WPARAM)IMAGE_ICON,
|
||||
(LPARAM)(HANDLE)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_UPDATE)));
|
||||
SendMessageW(hDownloadButton,
|
||||
BM_SETIMAGE,
|
||||
(WPARAM)IMAGE_BITMAP,
|
||||
(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_DOWNLOAD)));
|
||||
SendMessageW(hUninstallButton,
|
||||
BM_SETIMAGE,
|
||||
(WPARAM)IMAGE_BITMAP,
|
||||
(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UNINSTALL)));
|
||||
ShowWindow(hUninstallButton, SW_HIDE);
|
||||
|
||||
// Set deflaut entry for hApps
|
||||
|
@ -186,17 +235,34 @@ BOOL SetupControls (HWND hwnd)
|
|||
SendMessageW(hCategories, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)(HIMAGELIST)hImageList);
|
||||
SendMessageW(hApps, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)(HIMAGELIST)hImageList);
|
||||
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_0)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_1)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_2)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_3)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_4)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_5)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_6)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_7)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_8)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_9)), NULL);
|
||||
ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_10)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_0)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_1)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_2)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_3)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_4)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_5)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_6)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_7)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_8)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_9)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_10)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_11)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_12)), NULL);
|
||||
ImageList_Add(hImageList,
|
||||
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_13)), NULL);
|
||||
|
||||
// Fill the TreeViews
|
||||
AddItems (hCategories, Root.Children, NULL);
|
||||
|
@ -204,13 +270,15 @@ BOOL SetupControls (HWND hwnd)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void ResizeControl (HWND hwnd, int x1, int y1, int x2, int y2)
|
||||
static void
|
||||
ResizeControl (HWND hwnd, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
// Make resizing a little easier
|
||||
MoveWindow(hwnd, x1, y1, x2-x1, y2-y1, TRUE);
|
||||
}
|
||||
|
||||
static void DrawBitmap (HDC hdc, int x, int y, HBITMAP hBmp)
|
||||
static void
|
||||
DrawBitmap (HDC hdc, int x, int y, HBITMAP hBmp)
|
||||
{
|
||||
BITMAP bm;
|
||||
HDC hdcMem = CreateCompatibleDC(hdc);
|
||||
|
@ -222,7 +290,8 @@ static void DrawBitmap (HDC hdc, int x, int y, HBITMAP hBmp)
|
|||
DeleteDC(hdcMem);
|
||||
}
|
||||
|
||||
static void DrawDescription (HDC hdc, RECT DescriptionRect)
|
||||
static void
|
||||
DrawDescription (HDC hdc, RECT DescriptionRect)
|
||||
{
|
||||
int i;
|
||||
HFONT Font;
|
||||
|
@ -237,16 +306,16 @@ static void DrawDescription (HDC hdc, RECT DescriptionRect)
|
|||
|
||||
// Headline
|
||||
Font = CreateFont(-16 , 0, 0, 0, FW_EXTRABOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
|
||||
SelectObject(hdc, Font);
|
||||
DrawTextW(hdc, DescriptionHeadline, lstrlenW(DescriptionHeadline), &Rect, DT_SINGLELINE|DT_NOPREFIX);
|
||||
DeleteObject(Font);
|
||||
|
||||
// Description
|
||||
Font = CreateFont(-13 , 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
|
||||
SelectObject(hdc, Font);
|
||||
Rect.top += 40;
|
||||
Rect.top += 50;
|
||||
Rect.bottom = DescriptionRect.bottom-2;
|
||||
DrawTextW(hdc, DescriptionText, lstrlenW(DescriptionText), &Rect, DT_WORDBREAK|DT_NOPREFIX); // ToDo: Call TabbedTextOut to draw a nice table
|
||||
DeleteObject(Font);
|
||||
|
@ -257,7 +326,7 @@ void showUninstaller() {
|
|||
int Split_Vertical = 200;
|
||||
RECT Rect;
|
||||
|
||||
GetClientRect(hwnd,&Rect);
|
||||
GetClientRect(hwnd,&Rect);
|
||||
ShowWindow(hUninstallButton,SW_SHOW);
|
||||
MoveWindow(hDownloadButton,(Split_Vertical+Rect.right-Rect.left)/2,Rect.bottom-Rect.top-45,140,35,TRUE);;
|
||||
}
|
||||
|
@ -266,7 +335,7 @@ void hideUninstaller() {
|
|||
int Split_Vertical = 200;
|
||||
RECT Rect;
|
||||
|
||||
GetClientRect(hwnd,&Rect);
|
||||
GetClientRect(hwnd,&Rect);
|
||||
ShowWindow(hUninstallButton,SW_HIDE);
|
||||
MoveWindow(hDownloadButton,(Split_Vertical+Rect.right-Rect.left)/2-70,Rect.bottom-Rect.top-45,140,35,TRUE);
|
||||
}
|
||||
|
@ -281,10 +350,257 @@ void startUninstaller(WCHAR* Uninstaller) {
|
|||
CloseHandle(pi.hThread);
|
||||
// WaitForSingleObject(pi.hProcess, INFINITE); // If you want to wait for the Unistaller
|
||||
CloseHandle(pi.hProcess);
|
||||
hideUninstaller();
|
||||
hideUninstaller();
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
BOOL
|
||||
SaveSettings(HWND hwnd)
|
||||
{
|
||||
HKEY hKey;
|
||||
TCHAR szBuf[MAX_PATH];
|
||||
|
||||
if (RegOpenKey(HKEY_LOCAL_MACHINE,
|
||||
TEXT("Software\\ReactOS\\Download!"),
|
||||
&hKey) != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
SendMessage(GetDlgItem(hwnd, IDC_DOWNLOAD_FOLDER_EDIT), WM_GETTEXT, sizeof(szBuf)/sizeof(TCHAR), (LPARAM)szBuf);
|
||||
if (GetFileAttributes(szBuf) == 0xFFFFFFFF)
|
||||
if (!CreateDirectory((LPCTSTR)szBuf,NULL))
|
||||
{
|
||||
LoadString(GetModuleHandle(NULL), IDS_UNABLECREATE_FOLDER, szBuf, sizeof(szBuf) / sizeof(TCHAR));
|
||||
MessageBox(hwnd, (LPCTSTR)szBuf, NULL, MB_ICONSTOP);
|
||||
return FALSE;
|
||||
}
|
||||
if (RegSetValueEx(hKey,
|
||||
L"DownloadFolder",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuf,
|
||||
(DWORD)(sizeof(szBuf) / sizeof(TCHAR))))
|
||||
return FALSE;
|
||||
|
||||
SendMessage(GetDlgItem(hwnd, IDC_UPDATE_SERVER_EDIT), WM_GETTEXT, sizeof(szBuf)/sizeof(TCHAR), (LPARAM)szBuf);
|
||||
if (RegSetValueEx(hKey,
|
||||
L"UpdateServer",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuf,
|
||||
(DWORD)(sizeof(szBuf) / sizeof(TCHAR))))
|
||||
return FALSE;
|
||||
|
||||
DWORD dwValue;
|
||||
if (SendMessage(GetDlgItem(hwnd, IDC_DELINST_FILES_CHECKBOX), BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
dwValue = 0x1;
|
||||
else
|
||||
dwValue = 0x0;
|
||||
if (RegSetValueEx(hKey,
|
||||
L"DeleteInstaller",
|
||||
0,
|
||||
REG_DWORD,
|
||||
(LPBYTE)&dwValue,
|
||||
sizeof(DWORD)))
|
||||
return FALSE;
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InitProfDlg(HWND hwnd)
|
||||
{
|
||||
HKEY hKey;
|
||||
TCHAR Buf[MAX_PATH];
|
||||
DWORD dwDisp, dwSize;
|
||||
|
||||
if (RegOpenKey(HKEY_LOCAL_MACHINE,
|
||||
TEXT("Software\\ReactOS\\Download!"),
|
||||
&hKey) != ERROR_SUCCESS)
|
||||
{
|
||||
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Software\\ReactOS\\Download!",
|
||||
0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE, NULL, &hKey, &dwDisp))
|
||||
{
|
||||
LoadString(GetModuleHandle(NULL), IDS_NOTCREATE_REGKEY, Buf, sizeof(Buf) / sizeof(TCHAR));
|
||||
MessageBox(hwnd, (LPCTSTR)Buf, NULL, MB_ICONSTOP);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
dwSize = MAX_PATH;
|
||||
if (RegQueryValueEx(hKey,
|
||||
L"DownloadFolder",
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)&Buf,
|
||||
&dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
SendMessage(GetDlgItem(hwnd, IDC_DOWNLOAD_FOLDER_EDIT), WM_SETTEXT, -1, (LPARAM)Buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GetWindowsDirectory(Buf, sizeof(Buf) / sizeof(TCHAR))) return FALSE;
|
||||
|
||||
TCHAR DPath[256];
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (i == 3)
|
||||
{
|
||||
DPath[i] = '\0';
|
||||
break;
|
||||
}
|
||||
DPath[i] = Buf[i];
|
||||
}
|
||||
LoadString(GetModuleHandle(NULL), IDS_DOWNLOAD_FOLDER, Buf, sizeof(Buf) / sizeof(TCHAR));
|
||||
lstrcat((LPTSTR)DPath, Buf);
|
||||
if (RegSetValueEx(hKey,
|
||||
L"DownloadFolder",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)DPath,
|
||||
(DWORD)(sizeof(DPath) / sizeof(TCHAR))))
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
if (GetFileAttributes(DPath) == 0xFFFFFFFF)
|
||||
if (!CreateDirectory((LPCTSTR)DPath,NULL)) return FALSE;
|
||||
SendMessage(GetDlgItem(hwnd, IDC_DOWNLOAD_FOLDER_EDIT), WM_SETTEXT, -1, (LPARAM)DPath);
|
||||
}
|
||||
}
|
||||
|
||||
dwSize = MAX_PATH;
|
||||
if (RegQueryValueEx(hKey,
|
||||
L"UpdateServer",
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)&Buf,
|
||||
&dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
SendMessage(GetDlgItem(hwnd, IDC_UPDATE_SERVER_EDIT), WM_SETTEXT, -1, (LPARAM)Buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadString(GetModuleHandle(NULL), IDS_UPDATE_URL, Buf, sizeof(Buf) / sizeof(TCHAR));
|
||||
if (RegSetValueEx(hKey,
|
||||
L"UpdateServer",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)Buf,
|
||||
(DWORD)(sizeof(Buf) / sizeof(TCHAR))))
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
SendMessage(GetDlgItem(hwnd, IDC_UPDATE_SERVER_EDIT), WM_SETTEXT, -1, (LPARAM)Buf);
|
||||
}
|
||||
}
|
||||
|
||||
DWORD dwValue, dwType = REG_DWORD;
|
||||
dwSize = sizeof(DWORD);
|
||||
if (RegQueryValueEx(hKey,
|
||||
L"DeleteInstaller",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&dwValue,
|
||||
&dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
if (dwValue == 0x1)
|
||||
SendMessage(GetDlgItem(hwnd, IDC_DELINST_FILES_CHECKBOX), BM_SETCHECK, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
dwValue = 0x0;
|
||||
if (RegSetValueEx(hKey,
|
||||
L"DeleteInstaller",
|
||||
0,
|
||||
REG_DWORD,
|
||||
(LPBYTE)&dwValue,
|
||||
sizeof(DWORD)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
ChooseFolder(HWND hwnd)
|
||||
{
|
||||
BROWSEINFO fi;
|
||||
LPCITEMIDLIST lpItemList;
|
||||
TCHAR szPath[MAX_PATH],Buf[256];
|
||||
|
||||
ZeroMemory(&fi, sizeof(BROWSEINFO));
|
||||
fi.hwndOwner = hwnd;
|
||||
LoadString(GetModuleHandle(NULL), IDS_CHOOSE_FOLDER, Buf, sizeof(Buf) / sizeof(TCHAR));
|
||||
fi.lpszTitle = (LPCTSTR)Buf;
|
||||
fi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_BROWSEFORCOMPUTER | BIF_NEWDIALOGSTYLE;
|
||||
fi.lpfn = NULL;
|
||||
fi.lParam = -1;
|
||||
fi.iImage = 0;
|
||||
|
||||
if(!(lpItemList = SHBrowseForFolder(&fi))) return FALSE;
|
||||
SHGetPathFromIDList(lpItemList, szPath);
|
||||
|
||||
if (_tcslen(szPath) == 0) return FALSE;
|
||||
SendMessage(GetDlgItem(hwnd, IDC_DOWNLOAD_FOLDER_EDIT), WM_SETTEXT, -1, (LPARAM)szPath);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK
|
||||
ProfDlgProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
static HICON hIcon;
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
hIcon = LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,16,16,0);
|
||||
SendMessage(hDlg,WM_SETICON,ICON_SMALL,(LPARAM)hIcon);
|
||||
InitProfDlg(hDlg);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case IDC_CHOOSE_BUTTON:
|
||||
ChooseFolder(hDlg);
|
||||
break;
|
||||
case IDOK:
|
||||
{
|
||||
SaveSettings(hDlg);
|
||||
DestroyIcon(hIcon);
|
||||
EndDialog(hDlg,LOWORD(wParam));
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
{
|
||||
DestroyIcon(hIcon);
|
||||
EndDialog(hDlg,LOWORD(wParam));
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static RECT DescriptionRect;
|
||||
|
||||
|
@ -321,6 +637,13 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
if(HIWORD(wParam) == BN_CLICKED)
|
||||
{
|
||||
if (lParam == (LPARAM)hProfButton)
|
||||
{
|
||||
DialogBox(GetModuleHandle(NULL),
|
||||
MAKEINTRESOURCE(IDD_PROF),
|
||||
hwnd,
|
||||
ProfDlgProc);
|
||||
}
|
||||
if (lParam == (LPARAM)hDownloadButton)
|
||||
{
|
||||
if(SelectedApplication)
|
||||
|
@ -425,7 +748,8 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
|||
DescriptionRect = Rect;
|
||||
|
||||
MoveWindow(hHelpButton, LOWORD(lParam)-50, 10, 40, 40, TRUE);
|
||||
MoveWindow(hUpdateButton, LOWORD(lParam)-100, 10, 40, 40, TRUE);
|
||||
MoveWindow(hUpdateButton, LOWORD(lParam)-150, 10, 40, 40, TRUE);
|
||||
MoveWindow(hProfButton, LOWORD(lParam)-100, 10, 40, 40, TRUE);
|
||||
if(IsWindowVisible(hUninstallButton))
|
||||
MoveWindow(hDownloadButton, (Split_Vertical+LOWORD(lParam))/2, HIWORD(lParam)-45, 140, 35, TRUE);
|
||||
else
|
||||
|
@ -448,8 +772,11 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
|||
return DefWindowProc (hwnd, Message, wParam, lParam);
|
||||
}
|
||||
|
||||
INT WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
|
||||
LPTSTR lpCmdLine, INT nCmdShow)
|
||||
INT WINAPI
|
||||
wWinMain (HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInst,
|
||||
LPTSTR lpCmdLine,
|
||||
INT nCmdShow)
|
||||
{
|
||||
int i;
|
||||
WNDCLASSEXW WndClass = {0};
|
||||
|
@ -477,7 +804,7 @@ INT WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
|
|||
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
600, 550,
|
||||
650, 550,
|
||||
NULL, NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue