1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[ui] use richedit for about dialog and other improvements

* Add template for updates policy and settings
This commit is contained in:
Pete Batard 2012-11-29 02:59:52 +00:00
parent 249d3e16fb
commit 454010c27c
10 changed files with 302 additions and 111 deletions

View file

@ -30,9 +30,7 @@ s/^[ \t]*FILEVERSION[ \t]*\(.*\),\(.*\),\(.*\),.*/ FILEVERSION \1,\2,\3,@@TAGVER
s/^[ \t]*PRODUCTVERSION[ \t]*\(.*\),\(.*\),\(.*\),.*/ PRODUCTVERSION \1,\2,\3,@@TAGVER@@/
s/^\([ \t]*\)VALUE[ \t]*"FileVersion",[ \t]*"\(.*\)\..*"/\1VALUE "FileVersion", "\2.@@TAGVER@@"/
s/^\([ \t]*\)VALUE[ \t]*"ProductVersion",[ \t]*"\(.*\)\..*"/\1VALUE "ProductVersion", "\2.@@TAGVER@@"/
# TODO: revert ' ' to '"' below when out of beta
s/^\(.*\)"Rufus v\(.*\)\.\(.*\)"\(.*\)/\1"Rufus v\2.@@TAGVER@@"\4/
s/^\(.*\)"Version \(.*\) (Build \(.*\))"\(.*\)/\1"Version \2 (Build @@TAGVER@@)"\4/
_EOF
# First run sed to substitute our variable in the sed command file

View file

@ -17,58 +17,76 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const char* about_blurb_format =
"{\\rtf1\\ansi\n"
"{\\b\\fs20Rufus - The Reliable USB Formatting Utility}\\line\n"
"\\fs18Version %d.%d.%d (Build %d)\\line\n"
"\\line\n"
"Copyright © 2011-2012 Pete Batard / Akeo\\line\n"
RUFUS_URL "\\line\n"
"\\line\n"
"Report bugs or request enhancements at:\\line\n"
"https://github.com/pbatard/rufus/issues\\line\n"
"\\line\n"
"{\\b\\fs18Additional Copyrights:}}";
const char* additional_copyrights =
"Icon by PC Unleashed:\r\n"
"http://pcunleashed.com\r\n"
"Freeware\r\n"
"\r\n"
"Boot record handling from ms-sys by Henrik Carlqvist:\r\n"
"http://ms-sys.sourceforge.net\r\n"
"GNU General Public License (GPL) v2 or later\r\n"
"\r\n"
"FreeDOS support from the FreeDOS project:\r\n"
"http://www.freedos.org\r\n"
"GNU General Public License (GPL) v2 or later, with binary redistribution allowed\r\n"
"\r\n"
"ISO extraction support from libcdio by Rocky Bernstein et al:\r\n"
"http://www.gnu.org/software/libcdio\r\n"
"GNU General Public License (GPL) v3 or later\r\n"
"\r\n"
"Syslinux support from Syslinux by H. Peter Anvin et al:\r\n"
"http://www.syslinux.org\r\n"
"GNU General Public License (GPL) v2 or later\r\n"
"\r\n"
"Bad blocks testing from e2fsprogs by Theodore T'so et al:\r\n"
"http://e2fsprogs.sourceforge.net\r\n"
"GNU General Public License (GPL) v3 compatible\r\n"
"\r\n"
"Large FAT32 volume formatting from fat32format by Tom Thornhill:\r\n"
"http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm\r\n"
"GNU General Public License (GPL) v2 or later\r\n"
"\r\n"
"fmifs.dll usage based on Formatx by Mark Russinovich:\r\n"
"http://doc.sch130.nsc.ru/www.sysinternals.com/ntw2k/source/fmifs.shtml\r\n"
"http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/fmifs\r\n"
"Public Domain\r\n"
"\r\n"
"Device enumeration based on TestUSBDriveEject.cpp by ahmd:\r\n"
"http://www.codeguru.com/forum/showthread.php?p=1951973\r\n"
"Public Domain\r\n"
"\r\n"
"Some FAT and time-conversion handling by ReactOS:\r\n"
"http://svn.reactos.org/svn/reactos/trunk/reactos\r\n"
"GNU General Public License (GPL) v3 compatible\r\n"
"\r\n"
"FS Type description from by GNU fdisk:\r\n"
"http://www.gnu.org/software/fdisk\r\n"
"GNU General Public License (GPL) v3 or later\r\n"
"\r\n"
"About and License dialogs inspired by WinSCP\r\n"
"Copyright (c) 2000-2011 Martin Prikryl\r\n"
"GNU General Public License (GPL) v3 or later\r\n"
"\r\n"
"\r\n"
"All other references can be found in the source.\r\n";
"{\\rtf1\\ansi\n"
"Icon by PC Unleashed:\\line\n"
"http://pcunleashed.com\\line\n"
"Freeware\\line\n"
"\\line\n"
"Boot record handling from ms-sys by Henrik Carlqvist:\\line\n"
"http://ms-sys.sourceforge.net\\line\n"
"GNU General Public License (GPL) v2 or later\\line\n"
"\\line\n"
"FreeDOS support from the FreeDOS project:\\line\n"
"http://www.freedos.org\\line\n"
"GNU General Public License (GPL) v2 or later, with binary redistribution allowed\\line\n"
"\\line\n"
"ISO extraction support from libcdio by Rocky Bernstein et al:\\line\n"
"http://www.gnu.org/software/libcdio\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"
"\\line\n"
"Syslinux support from Syslinux by H. Peter Anvin et al:\\line\n"
"http://www.syslinux.org\\line\n"
"GNU General Public License (GPL) v2 or later\\line\n"
"\\line\n"
"Bad blocks testing from e2fsprogs by Theodore T'so et al:\\line\n"
"http://e2fsprogs.sourceforge.net\\line\n"
"GNU General Public License (GPL) v3 compatible\\line\n"
"\\line\n"
"Large FAT32 volume formatting from fat32format by Tom Thornhill:\\line\n"
"http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm\\line\n"
"GNU General Public License (GPL) v2 or later\\line\n"
"\\line\n"
"fmifs.dll usage based on Formatx by Mark Russinovich:\\line\n"
"http://doc.sch130.nsc.ru/www.sysinternals.com/ntw2k/source/fmifs.shtml\\line\n"
"http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/fmifs\\line\n"
"Public Domain\\line\n"
"\\line\n"
"Device enumeration based on TestUSBDriveEject.cpp by ahmd:\\line\n"
"http://www.codeguru.com/forum/showthread.php?p=1951973\\line\n"
"Public Domain\\line\n"
"\\line\n"
"Some FAT and time-conversion handling by ReactOS:\\line\n"
"http://svn.reactos.org/svn/reactos/trunk/reactos\\line\n"
"GNU General Public License (GPL) v3 compatible\\line\n"
"\\line\n"
"FS Type description from by GNU fdisk:\\line\n"
"http://www.gnu.org/software/fdisk\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"
"\\line\n"
"About and License dialogs inspired by WinSCP by Martin Prikryl\\line\n"
"http://winscp.net\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"
"\\line\n"
"\\line\n"
"All other references can be found in the source.\\line\n}";
const char* update_policy =
"{\\rtf1\\ansi\n"
"Hey sexy mama, Wanna kill all humans?}";
const char* gplv3 =
" GNU GENERAL PUBLIC LICENSE\r\n"

View file

@ -368,7 +368,6 @@ out:
DWORD WINAPI CheckForUpdatesThread(LPVOID param)
{
const char* server_url = RUFUS_URL "/";
BOOL r = FALSE;
int i, j, verbose = 2, verpos[4];
static char* archname[] = {"win_x86", "win_x64"};
DWORD dwFlags, dwSize, dwDownloaded, dwTotalSize, dwStatus;
@ -446,14 +445,14 @@ DWORD WINAPI CheckForUpdatesThread(LPVOID param)
safe_sprintf(urlpath, sizeof(urlpath), "%s_%s_%d.%d.ver", APPLICATION_NAME,
archname[is_x64?1:0], os_version.dwMajorVersion, os_version.dwMinorVersion);
uprintf("Base update check: %s\n", urlpath);
vuprintf("Base update check: %s\n", urlpath);
for (i=0, j=safe_strlen(urlpath)-5; (j>0)&&(i<ARRAYSIZE(verpos)); j--) {
if ((urlpath[j] == '.') || (urlpath[j] == '_')) {
verpos[i++] = j;
}
}
if (i != ARRAYSIZE(verpos)) {
uprintf("Fix your code in CheckForUpdatesThread()!\n");
uprintf("Fix CheckForUpdatesThread()!\n");
goto out;
}
@ -471,18 +470,17 @@ DWORD WINAPI CheckForUpdatesThread(LPVOID param)
dwSize = sizeof(dwStatus);
dwStatus = 404;
HttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwStatus, &dwSize, NULL);
if (dwStatus == 200) {
vvuprintf("Found.");
if (dwStatus == 200)
break;
}
InternetCloseHandle(hRequest);
hRequest = NULL;
safe_strcpy(&urlpath[verpos[i]], 5, ".ver");
}
if (dwStatus != 200) {
vuprintf("Unable to find a version file on server");
vuprintf("Could not find a version file on server %s", server_url);
goto out;
}
vuprintf("Found match for %s on server %s.", urlpath, server_url);
dwSize = sizeof(mime);
HttpQueryInfoA(hRequest, HTTP_QUERY_CONTENT_TYPE, (LPVOID)&mime, &dwSize, NULL);
@ -522,7 +520,6 @@ DWORD WINAPI CheckForUpdatesThread(LPVOID param)
vuprintf("Successfully downloaded version file (%d bytes)\n", dwTotalSize);
parse_update(buf, dwTotalSize+1);
r = TRUE;
out:
safe_free(buf);

View file

@ -209,7 +209,7 @@ static __inline char* get_sanitized_token_data_buffer(const char* token, unsigne
// Parse an update data file and populates a rufus_update structure.
// NB: since this is remote data, and we're running elevated, it *IS* considered
// potentially malicioueven if it comes from a supposedly trusted server.
// potentially malicious, even if it comes from a supposedly trusted server.
// len should be the size of the buffer - 1, for the zero terminator
void parse_update(char* buf, size_t len)
{

View file

@ -41,12 +41,11 @@ extern "C" {
static __inline BOOL DeleteRegistryKey(const char* key_name)
{
HKEY hSoftware = NULL;
LSTATUS s;
LONG s;
if (RegOpenKeyExA(HKEY_CURRENT_USER, "SOFTWARE", 0, KEY_READ|KEY_CREATE_SUB_KEY, &hSoftware) != ERROR_SUCCESS) {
return FALSE;
}
ERROR_SUCCESS;
s = RegDeleteKeyA(hSoftware, key_name);
if ((s != ERROR_SUCCESS) && (s != ERROR_FILE_NOT_FOUND)) {

View file

@ -12,6 +12,8 @@
#define IDS_VERSION 108
#define IDI_UP 109
#define IDI_DOWN 110
#define IDD_QUESTION 111
#define IDD_UPDATE_POLICY 112
#define IDR_BR_MBR_BIN 200
#define IDR_FD_COMMAND_COM 300
#define IDR_FD_KERNEL_SYS 301
@ -82,15 +84,20 @@
#define IDC_LOG_EDIT 1050
#define IDC_LOG_SAVE 1051
#define IDC_LOG_CLEAR 1052
#define IDC_QUESTION_MORE_INFO 1060
#define IDC_UPDATES_POLICY 1061
#define IDC_UPDATE_FREQUENCY 1062
#define IDC_INCLUDE_BETAS 1063
#define IDC_ABOUT_BLURB 1064
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 110
#define _APS_NEXT_RESOURCE_VALUE 113
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1053
#define _APS_NEXT_CONTROL_VALUE 1065
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -1521,6 +1521,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
{
DRAWITEMSTRUCT* pDI;
POINT Point;
BOOL testme;
RECT DialogRect, DesktopRect;
int nDeviceIndex, fs, i, nWidth, nHeight;
static DWORD DeviceNum = 0;
@ -1626,7 +1627,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break;
#ifdef RUFUS_TEST
case IDC_TEST:
CheckForUpdates();
testme = Question("Rufus updates", "Do you want to allow " APPLICATION_NAME " to check for updates?\n");
uprintf("User said %s\n", testme?"YES":"NO");
// CheckForUpdates();
/*
InitProgress();
if (!IsWindow(hISOProgressDlg)) {
@ -1822,8 +1825,13 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
}
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
if ((fs == FS_NTFS) && (!iso_report.has_bootmgr) && (!IS_WINPE(iso_report.winpe))) {
MessageBoxA(hMainDialog, "Only 'bootmgr' or 'WinPE' based ISO "
"images can currently be used with NTFS.", "Unsupported ISO...", MB_OK|MB_ICONERROR);
if (iso_report.has_isolinux) {
MessageBoxA(hMainDialog, "Only FAT32 is supported for this type of ISO. "
"Please revert the filesystem back from NTFS to FAT32.", "Unsupported filesystem...", MB_OK|MB_ICONERROR);
} else {
MessageBoxA(hMainDialog, "Only 'bootmgr' or 'WinPE' based ISO "
"images can currently be used with NTFS.", "Unsupported ISO...", MB_OK|MB_ICONERROR);
}
break;
} else if (((fs == FS_FAT16)||(fs == FS_FAT32)) && (!iso_report.has_isolinux)) {
MessageBoxA(hMainDialog, "Only 'isolinux' based ISO "
@ -1941,6 +1949,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Set the Windows version
DetectWindowsVersion();
// Some dialogs have Rich Edit controls and won't display without this
if (LoadLibraryA("Riched20.dll") == NULL) {
uprintf("Could not load RichEdit library - some dialogs may not display: %s\n", WindowsErrorString());
}
// We use local group policies rather than direct registry manipulation
// 0x9e disables removable and fixed drive notifications
SetLGP(FALSE, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e);
@ -1992,7 +2005,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
PrintStatus(2000, FALSE, "Fake drive detection %s.", detect_fakes?"enabled":"disabled");
continue;
}
// Alt-R => Remove all the registry settings created by Rufus by deleting the registry key
// Alt-R => Remove all the registry keys created by Rufus
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'R')) {
PrintStatus(2000, FALSE, "Application registry key %s deleted.",
DeleteRegistryKey(COMPANY_NAME "\\" APPLICATION_NAME)?"successfully":"could not be");

View file

@ -43,7 +43,6 @@
#define WHITE RGB(255,255,255)
#define SEPARATOR_GREY RGB(223,223,223)
#define RUFUS_URL "http://rufus.akeo.ie"
#define BUG_URL "https://github.com/pbatard/rufus/issues"
#define VESAMENU_URL "http://cloud.github.com/downloads/pbatard/rufus/vesamenu.c32"
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
#ifndef ARRAYSIZE
@ -227,6 +226,7 @@ extern BOOL CreateTooltip(HWND hControl, const char* message, int duration);
extern void DestroyTooltip(HWND hWnd);
extern void DestroyAllTooltips(void);
extern BOOL Notification(int type, char* title, char* format, ...);
extern BOOL Question(char* title, char* format, ...);
extern BOOL ExtractDOS(const char* path);
extern BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan);
extern BOOL ExtractISOFile(const char* iso, const char* iso_file, const char* dest_file);

View file

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 316
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.2.1.197"
CAPTION "Rufus v1.2.1.198"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
@ -66,24 +66,16 @@ BEGIN
PUSHBUTTON "Log",IDC_LOG,62,278,18,14
END
IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195
IDD_ABOUTBOX DIALOGEX 0, 0, 287, 201
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Rufus"
FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
BEGIN
ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20
LTEXT "Rufus - The Reliable USB Formatting Utility",IDC_RUFUS_BOLD,46,8,240,10,SS_NOPREFIX | SS_NOTIFY
LTEXT "Copyright (c) 2011-2012 Pete Batard",IDC_STATIC,46,36,139,8
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.2.1 (Build 197)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
CONTROL "",IDC_ABOUT_COPYRIGHTS,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_VSCROLL,46,107,235,63,WS_EX_STATICEDGE
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
LTEXT "Portions copyright:",IDC_STATIC,46,95,59,8
CONTROL "<a>https://github.com/pbatard/rufus/issues</a>",IDC_ABOUT_BUG_URL,
"SysLink",WS_TABSTOP,46,76,203,14
DEFPUSHBUTTON "OK",IDOK,231,181,50,14,WS_GROUP
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,181,50,14,WS_GROUP
CONTROL "",IDC_ABOUT_COPYRIGHTS,"RichEdit20W",WS_VSCROLL | 0x804,46,101,235,74,WS_EX_STATICEDGE
CONTROL "",IDC_ABOUT_BLURB,"RichEdit20W",WS_TABSTOP | 0x884,46,7,235,93
END
IDD_NOTIFICATION DIALOGEX 0, 0, 263, 63
@ -128,6 +120,35 @@ BEGIN
PUSHBUTTON "Close Log",IDCANCEL,308,259,50,14
END
IDD_QUESTION DIALOGEX 0, 0, 263, 63
STYLE DS_SETFONT | DS_FIXEDSYS | DS_NOFAILCREATE | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME
CAPTION "Rufus"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "",IDC_NOTIFICATION_LINE,0,0,263,39
CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,263,38
ICON 32516,IDC_NOTIFICATION_ICON,6,6,20,20
LTEXT "",IDC_NOTIFICATION_TEXT,35,10,219,20
DEFPUSHBUTTON "No",IDNO,211,44,50,14
DEFPUSHBUTTON "More info...",IDC_QUESTION_MORE_INFO,8,44,50,14
DEFPUSHBUTTON "Yes",IDYES,159,44,50,14
END
IDD_UPDATE_POLICY DIALOGEX 0, 0, 287, 195
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Update policy and settings"
FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
BEGIN
ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20
DEFPUSHBUTTON "OK",IDOK,231,166,50,14,WS_GROUP
CONTROL "",IDC_UPDATES_POLICY,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_VSCROLL,46,8,235,130,WS_EX_STATICEDGE
COMBOBOX IDC_UPDATE_FREQUENCY,121,150,66,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Check for updates:",IDC_STATIC,52,152,61,11
LTEXT "Include beta versions:",IDC_STATIC,52,168,75,11
COMBOBOX IDC_INCLUDE_BETAS,151,166,36,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Settings",IDC_STATIC,46,140,149,43
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@ -204,7 +225,6 @@ GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG, DIALOG
BEGIN
BOTTOMMARGIN, 315
END
IDD_ABOUTBOX, DIALOG
@ -217,7 +237,6 @@ BEGIN
IDD_ISO_EXTRACT, DIALOG
BEGIN
BOTTOMMARGIN, 65
END
IDD_LICENSE, DIALOG
@ -227,6 +246,14 @@ BEGIN
IDD_LOG, DIALOG
BEGIN
END
IDD_QUESTION, DIALOG
BEGIN
END
IDD_UPDATE_POLICY, DIALOG
BEGIN
END
END
#endif // APSTUDIO_INVOKED
@ -237,8 +264,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,1,197
PRODUCTVERSION 1,2,1,197
FILEVERSION 1,2,1,198
PRODUCTVERSION 1,2,1,198
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -255,13 +282,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.2.1.197"
VALUE "FileVersion", "1.2.1.198"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.2.1.197"
VALUE "ProductVersion", "1.2.1.198"
END
END
BLOCK "VarFileInfo"

View file

@ -64,6 +64,7 @@ enum WindowsVersion nWindowsVersion = WINDOWS_UNSUPPORTED;
static HWND hBrowseEdit;
static WNDPROC pOrgBrowseWndproc;
HFONT hBoldFont = NULL;
static const SETTEXTEX friggin_microsoft_unicode_amateurs = {ST_DEFAULT, CP_UTF8};
/*
* Detect Windows version
@ -668,7 +669,11 @@ INT_PTR CALLBACK LicenseCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
*/
INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hCopyrights;
int i;
const int edit_id[2] = {IDC_ABOUT_BLURB, IDC_ABOUT_COPYRIGHTS};
char about_blurb[1024];
const char* edit_text[2] = {about_blurb, additional_copyrights};
HWND hEdit[2];
TEXTRANGEW tr;
ENLINK* enl;
wchar_t wUrl[256];
@ -676,12 +681,20 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
switch (message) {
case WM_INITDIALOG:
CenterDialog(hDlg);
hCopyrights = GetDlgItem(hDlg, IDC_ABOUT_COPYRIGHTS);
SendMessageA(hCopyrights, EM_AUTOURLDETECT, 1, 0);
SetDlgItemTextA(hDlg, IDC_ABOUT_COPYRIGHTS, additional_copyrights);
SendMessage(hCopyrights, EM_SETSEL, -1, -1);
SendMessage(hCopyrights, EM_SETEVENTMASK, 0, ENM_LINK);
SendMessageA(hCopyrights, EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE));
safe_sprintf(about_blurb, sizeof(about_blurb), about_blurb_format,
rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[3]);
for (i=0; i<ARRAYSIZE(hEdit); i++) {
hEdit[i] = GetDlgItem(hDlg, edit_id[i]);
SendMessage(hEdit[i], EM_AUTOURLDETECT, 1, 0);
/* Can't use SetDlgItemText, because it only works with RichEdit20A... and VS insists
* on reverting to RichEdit20W as soon as you edit the dialog. You can try all the W
* methods you want, it JUST WON'T WORK unless you use EM_SETTEXTEX. Also see:
* http://blog.kowalczyk.info/article/eny/Setting-unicode-rtf-text-in-rich-edit-control.html */
SendMessageA(hEdit[i], EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)edit_text[i]);
SendMessage(hEdit[i], EM_SETSEL, -1, -1);
SendMessage(hEdit[i], EM_SETEVENTMASK, 0, ENM_LINK);
SendMessage(hEdit[i], EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE));
}
break;
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == GetDlgItem(hDlg, IDC_RUFUS_BOLD)) {
@ -693,17 +706,6 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
break;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) {
case NM_CLICK:
case NM_RETURN:
switch (LOWORD(wParam)) {
case IDC_ABOUT_RUFUS_URL:
ShellExecuteA(hDlg, "open", RUFUS_URL, NULL, NULL, SW_SHOWNORMAL);
break;
case IDC_ABOUT_BUG_URL:
ShellExecuteA(hDlg, "open", BUG_URL, NULL, NULL, SW_SHOWNORMAL);
break;
}
break;
case EN_LINK:
enl = (ENLINK*) lParam;
if (enl->msg == WM_LBUTTONUP) {
@ -733,11 +735,56 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
INT_PTR CreateAboutBox(void)
{
// Required to display the license in a rich edit control
LoadLibraryA("Riched20.dll");
return DialogBoxA(hMainInstance, MAKEINTRESOURCEA(IDD_ABOUTBOX), hMainDialog, AboutCallback);
}
/*
* Update policy and settings dialog callback
*/
INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hPolicy, hCombo;
switch (message) {
case WM_INITDIALOG:
CenterDialog(hDlg);
hCombo = GetDlgItem(hDlg, IDC_UPDATE_FREQUENCY);
IGNORE_RETVAL(ComboBox_SetItemData(hCombo, ComboBox_AddStringU(hCombo, "Never (Disabled)"), -1));
IGNORE_RETVAL(ComboBox_SetItemData(hCombo, ComboBox_AddStringU(hCombo, "Daily (Default)"), 86400));
IGNORE_RETVAL(ComboBox_SetItemData(hCombo, ComboBox_AddStringU(hCombo, "Weekly"), 604800));
IGNORE_RETVAL(ComboBox_SetItemData(hCombo, ComboBox_AddStringU(hCombo, "Monthly"), 2629800));
IGNORE_RETVAL(ComboBox_SetCurSel(hCombo, 1));
hCombo = GetDlgItem(hDlg, IDC_INCLUDE_BETAS);
IGNORE_RETVAL(ComboBox_AddStringU(hCombo, "No"));
IGNORE_RETVAL(ComboBox_AddStringU(hCombo, "Yes"));
IGNORE_RETVAL(ComboBox_SetCurSel(hCombo, 0));
hPolicy = GetDlgItem(hDlg, IDC_UPDATES_POLICY);
SendMessage(hPolicy, EM_AUTOURLDETECT, 1, 0);
SendMessageA(hPolicy, EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)update_policy);
SendMessage(hPolicy, EM_SETSEL, -1, -1);
SendMessage(hPolicy, EM_SETEVENTMASK, 0, ENM_LINK);
SendMessageA(hPolicy, EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE));
break;
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == GetDlgItem(hDlg, IDC_RUFUS_BOLD)) {
CreateBoldFont((HDC)wParam);
SetBkMode((HDC)wParam, TRANSPARENT);
SelectObject((HDC)wParam, hBoldFont);
return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
}
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
/*
* We use our own MessageBox for notifications to have greater control (center, no close button, etc)
*/
@ -827,6 +874,91 @@ BOOL Notification(int type, char* title, char* format, ...)
return TRUE;
}
/*
* Same for custom questions
*/
INT_PTR CALLBACK QuestionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT loc;
int i;
// Prevent resizing
static LRESULT disabled[9] = { HTLEFT, HTRIGHT, HTTOP, HTBOTTOM, HTSIZE,
HTTOPLEFT, HTTOPRIGHT, HTBOTTOMLEFT, HTBOTTOMRIGHT };
static HBRUSH white_brush, separator_brush;
switch (message) {
case WM_INITDIALOG:
white_brush = CreateSolidBrush(WHITE);
separator_brush = CreateSolidBrush(SEPARATOR_GREY);
CenterDialog(hDlg);
// Change the default icon
if (Static_SetIcon(GetDlgItem(hDlg, IDC_NOTIFICATION_ICON), hMessageIcon) == 0) {
uprintf("Could not set dialog icon\n");
}
// Set the dialog title
if (szMessageTitle != NULL) {
SetWindowTextA(hDlg, szMessageTitle);
}
// Set the control text
if (szMessageText != NULL) {
SetWindowTextA(GetDlgItem(hDlg, IDC_NOTIFICATION_TEXT), szMessageText);
}
return (INT_PTR)TRUE;
case WM_CTLCOLORSTATIC:
// Change the background colour for static text and icon
SetBkMode((HDC)wParam, TRANSPARENT);
if ((HWND)lParam == GetDlgItem(hDlg, IDC_NOTIFICATION_LINE)) {
return (INT_PTR)separator_brush;
}
return (INT_PTR)white_brush;
case WM_NCHITTEST:
// Check coordinates to prevent resize actions
loc = DefWindowProc(hDlg, message, wParam, lParam);
for(i = 0; i < 9; i++) {
if (loc == disabled[i]) {
return (INT_PTR)TRUE;
}
}
return (INT_PTR)FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDYES:
case IDNO:
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
case IDC_QUESTION_MORE_INFO:
DialogBoxA(hMainInstance, MAKEINTRESOURCEA(IDD_UPDATE_POLICY), hDlg, UpdateCallback);
break;
}
break;
}
return (INT_PTR)FALSE;
}
/*
* Display a custom question
* returns TRUE if the user answered yes, FALSE if no
* TODO: point to a static dialog for more info
*/
BOOL Question(char* title, char* format, ...)
{
va_list args;
BOOL ret;
szMessageText = (char*)malloc(MAX_PATH);
if (szMessageText == NULL) return FALSE;
szMessageTitle = title;
va_start(args, format);
safe_vsnprintf(szMessageText, MAX_PATH-1, format, args);
va_end(args);
szMessageText[MAX_PATH-1] = 0;
hMessageIcon = LoadIcon(NULL, IDI_QUESTION);
ret = (DialogBox(hMainInstance, MAKEINTRESOURCE(IDD_QUESTION), hMainDialog, QuestionCallback) == IDYES);
safe_free(szMessageText);
return ret;
}
static struct {
HWND hTip; // Tooltip handle
HWND hCtrl; // Handle of the control the tooltip belongs to