diff --git a/_pre-commit.sh b/_pre-commit.sh
index 1907108f..a1824f6e 100644
--- a/_pre-commit.sh
+++ b/_pre-commit.sh
@@ -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
diff --git a/src/license.h b/src/license.h
index 82ff17e5..7644426e 100644
--- a/src/license.h
+++ b/src/license.h
@@ -17,58 +17,76 @@
* along with this program. If not, see .
*/
+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"
diff --git a/src/net.c b/src/net.c
index 7cb3e58d..0db97278 100644
--- a/src/net.c
+++ b/src/net.c
@@ -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 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");
diff --git a/src/rufus.h b/src/rufus.h
index 80b2ccff..1143e0fd 100644
--- a/src/rufus.h
+++ b/src/rufus.h
@@ -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);
diff --git a/src/rufus.rc b/src/rufus.rc
index 2fbf41a5..3815da7f 100644
--- a/src/rufus.rc
+++ b/src/rufus.rc
@@ -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 "http://rufus.akeo.ie",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 "https://github.com/pbatard/rufus/issues",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"
diff --git a/src/stdlg.c b/src/stdlg.c
index efe835a0..fe0f4fb0 100644
--- a/src/stdlg.c
+++ b/src/stdlg.c
@@ -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; icode) {
- 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