mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[ui] disable controls prior to format checks
* Also send Unicode strings to the debug output facility, since Windows 10 *FINALLY* added Unicode processing support there...
This commit is contained in:
		
							parent
							
								
									39e418fbe9
								
							
						
					
					
						commit
						d5babb5e72
					
				
					 3 changed files with 39 additions and 51 deletions
				
			
		
							
								
								
									
										55
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										55
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -2515,6 +2515,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 			if (format_thid != NULL) { | ||||
| 				return (INT_PTR)TRUE; | ||||
| 			} | ||||
| 			// Disable all controls except Cancel
 | ||||
| 			EnableControls(FALSE); | ||||
| 			FormatStatus = 0; | ||||
| 			StrArrayClear(&BlockingProcess); | ||||
| 			format_op_in_progress = TRUE; | ||||
|  | @ -2528,11 +2530,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 			nDeviceIndex = ComboBox_GetCurSel(hDeviceList); | ||||
| 			if (nDeviceIndex != CB_ERR) { | ||||
| 				if (!zero_drive) { | ||||
| 					if ((IsChecked(IDC_BOOT)) && (!BootCheck())) { | ||||
| 						format_op_in_progress = FALSE; | ||||
| 						PROCESS_QUEUED_EVENTS; | ||||
| 						break; | ||||
| 					} | ||||
| 					if ((IsChecked(IDC_BOOT)) && (!BootCheck())) | ||||
| 						goto aborted_start; | ||||
| 
 | ||||
| 					// Display a warning about UDF formatting times
 | ||||
| 					fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); | ||||
|  | @ -2558,9 +2557,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 						i = SelectionDialog(lmprintf(MSG_274), lmprintf(MSG_275, iso_image, dd_image, iso_image, dd_image), | ||||
| 							choices, 2); | ||||
| 						if (i < 0) {	// Cancel
 | ||||
| 							format_op_in_progress = FALSE; | ||||
| 							PROCESS_QUEUED_EVENTS; | ||||
| 							break; | ||||
| 							goto aborted_start; | ||||
| 						} else if (i == 2) { | ||||
| 							selection_default = BT_IMG; | ||||
| 							SetComboEntry(hBootType, selection_default); | ||||
|  | @ -2568,38 +2565,21 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 					} | ||||
| 				} | ||||
| 
 | ||||
| 				if (!CheckDriveAccess()) { | ||||
| 					format_op_in_progress = FALSE; | ||||
| 					zero_drive = FALSE; | ||||
| 					PROCESS_QUEUED_EVENTS; | ||||
| 					break; | ||||
| 				} | ||||
| 				if (!CheckDriveAccess()) | ||||
| 					goto aborted_start; | ||||
| 
 | ||||
| 				GetWindowTextU(hDeviceList, tmp, ARRAYSIZE(tmp)); | ||||
| 				if (MessageBoxExU(hMainDialog, lmprintf(MSG_003, tmp), | ||||
| 					APPLICATION_NAME, MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL) { | ||||
| 					format_op_in_progress = FALSE; | ||||
| 					zero_drive = FALSE; | ||||
| 					PROCESS_QUEUED_EVENTS; | ||||
| 					break; | ||||
| 				} | ||||
| 					APPLICATION_NAME, MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)  | ||||
| 					goto aborted_start; | ||||
| 				if ((SelectedDrive.nPartitions > 1) && (MessageBoxExU(hMainDialog, lmprintf(MSG_093), | ||||
| 					lmprintf(MSG_094), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) { | ||||
| 					format_op_in_progress = FALSE; | ||||
| 					zero_drive = FALSE; | ||||
| 					PROCESS_QUEUED_EVENTS; | ||||
| 					break; | ||||
| 				} | ||||
| 					lmprintf(MSG_094), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) | ||||
| 					goto aborted_start; | ||||
| 				if ((!zero_drive) && (IsChecked(IDC_BOOT)) && (SelectedDrive.SectorSize != 512) && | ||||
| 					(MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.SectorSize), | ||||
| 						lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) { | ||||
| 					format_op_in_progress = FALSE; | ||||
| 					PROCESS_QUEUED_EVENTS; | ||||
| 					break; | ||||
| 				} | ||||
| 						lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) | ||||
| 					goto aborted_start; | ||||
| 
 | ||||
| 				// Disable all controls except Cancel
 | ||||
| 				EnableControls(FALSE); | ||||
| 				DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex); | ||||
| 				InitProgress(zero_drive); | ||||
| 				format_thid = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL); | ||||
|  | @ -2607,7 +2587,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 					uprintf("Unable to start formatting thread"); | ||||
| 					FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_START_THREAD); | ||||
| 					PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); | ||||
| 				} | ||||
| 				} else { | ||||
| 					uprintf("\r\nFormat operation started"); | ||||
| 					PrintInfo(0, -1); | ||||
| 					timer = 0; | ||||
|  | @ -2615,11 +2595,14 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 					SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); | ||||
| 					SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); | ||||
| 				} | ||||
| 			if (format_thid == NULL) { | ||||
| 			} | ||||
| 			if (format_thid != NULL) | ||||
| 				break; | ||||
| 		aborted_start: | ||||
| 			format_op_in_progress = FALSE; | ||||
| 			EnableControls(TRUE); | ||||
| 			zero_drive = FALSE; | ||||
| 			PROCESS_QUEUED_EVENTS; | ||||
| 			} | ||||
| 			break; | ||||
| 		case IDC_HASH: | ||||
| 			if ((format_thid == NULL) && (image_path != NULL)) { | ||||
|  |  | |||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | |||
| IDD_DIALOG DIALOGEX 12, 12, 242, 376 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_ACCEPTFILES | ||||
| CAPTION "Rufus 2.16.1148" | ||||
| CAPTION "Rufus 2.16.1149" | ||||
| FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | ||||
| BEGIN | ||||
|     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 | ||||
|  | @ -366,8 +366,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 2,16,1148,0 | ||||
|  PRODUCTVERSION 2,16,1148,0 | ||||
|  FILEVERSION 2,16,1149,0 | ||||
|  PRODUCTVERSION 2,16,1149,0 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -384,13 +384,13 @@ BEGIN | |||
|         BEGIN | ||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "2.16.1148" | ||||
|             VALUE "FileVersion", "2.16.1149" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "2.16.1148" | ||||
|             VALUE "ProductVersion", "2.16.1149" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
|  | @ -42,10 +42,12 @@ size_t ubuffer_pos = 0; | |||
| char ubuffer[UBUFFER_SIZE];	// Buffer for ubpushf() messages we don't log right away
 | ||||
| 
 | ||||
| #ifdef RUFUS_LOGGING | ||||
| #define Edit_ReplaceSelW(hCtrl, wstr) ((void)SendMessageW(hCtrl, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)wstr)) | ||||
| void _uprintf(const char *format, ...) | ||||
| { | ||||
| 	static char buf[4096]; | ||||
| 	char* p = buf; | ||||
| 	wchar_t* wbuf; | ||||
| 	va_list args; | ||||
| 	int n; | ||||
| 
 | ||||
|  | @ -62,16 +64,19 @@ void _uprintf(const char *format, ...) | |||
| 	*p++ = '\n'; | ||||
| 	*p   = '\0'; | ||||
| 
 | ||||
| 	// Yay, Windows 10 *FINALLY* added actual Unicode support for OutputDebugStringW()!
 | ||||
| 	wbuf = utf8_to_wchar(buf); | ||||
| 	// Send output to Windows debug facility
 | ||||
| 	OutputDebugStringA(buf); | ||||
| 	OutputDebugStringW(wbuf); | ||||
| 	if ((hLog != NULL) && (hLog != INVALID_HANDLE_VALUE)) { | ||||
| 		// Send output to our log Window
 | ||||
| 		Edit_SetSel(hLog, MAX_LOG_SIZE, MAX_LOG_SIZE); | ||||
| 		Edit_ReplaceSelU(hLog, buf); | ||||
| 		Edit_ReplaceSelW(hLog, wbuf); | ||||
| 		// Make sure the message scrolls into view
 | ||||
| 		// (Or see code commented in LogProc:WM_SHOWWINDOW for a less forceful scroll)
 | ||||
| 		SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0)); | ||||
| 	} | ||||
| 	free(wbuf); | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue