mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[ui] use our own custom bar with text
* Needed because native Windows produces obnoxious tearing on redrawing. * Also rename global partition scheme variable back to 'pt' * Also fix major and minor version numbers in the .rc
This commit is contained in:
		
							parent
							
								
									2fbe7be870
								
							
						
					
					
						commit
						7fef3c6434
					
				
					 5 changed files with 79 additions and 44 deletions
				
			
		|  | @ -1662,7 +1662,7 @@ DWORD WINAPI FormatThread(void* param) | |||
| 	if (large_drive) | ||||
| 		uprintf("Notice: Large drive detected (may produce short writes)"); | ||||
| 	// Find out if we need to add any extra partitions
 | ||||
| 	if ((windows_to_go) && (tt == TT_UEFI) && (ps == PARTITION_STYLE_GPT)) | ||||
| 	if ((windows_to_go) && (tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) | ||||
| 		// According to Microsoft, every GPT disk (we RUN Windows from) must have an MSR due to not having hidden sectors
 | ||||
| 		// http://msdn.microsoft.com/en-us/library/windows/hardware/dn640535.aspx#gpt_faq_what_disk_require_msr
 | ||||
| 		extra_partitions = XP_MSR | XP_EFI; | ||||
|  | @ -1848,7 +1848,7 @@ DWORD WINAPI FormatThread(void* param) | |||
| 	UpdateProgress(OP_ZERO_MBR, -1.0f); | ||||
| 	CHECK_FOR_USER_CANCEL; | ||||
| 
 | ||||
| 	if (!CreatePartition(hPhysicalDrive, ps, fs, (ps==PARTITION_STYLE_MBR) && (tt==TT_UEFI), extra_partitions)) { | ||||
| 	if (!CreatePartition(hPhysicalDrive, pt, fs, (pt==PARTITION_STYLE_MBR) && (tt==TT_UEFI), extra_partitions)) { | ||||
| 		FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE; | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -1882,7 +1882,7 @@ DWORD WINAPI FormatThread(void* param) | |||
| 	} | ||||
| 
 | ||||
| 	// Thanks to Microsoft, we must fix the MBR AFTER the drive has been formatted
 | ||||
| 	if (ps == PARTITION_STYLE_MBR) { | ||||
| 	if (pt == PARTITION_STYLE_MBR) { | ||||
| 		PrintInfoDebug(0, MSG_228);	// "Writing master boot record..."
 | ||||
| 		if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) { | ||||
| 			if (!IS_ERROR(FormatStatus)) | ||||
|  |  | |||
|  | @ -413,16 +413,7 @@ static uint64_t last_msg_time[2] = { 0, 0 }; | |||
| 
 | ||||
| static void PrintInfoMessage(char* msg) { | ||||
| 	SetWindowTextU(hProgress, msg); | ||||
| 	// Make sure our field gets redrawn
 | ||||
| 	// If the progress bar is not active, it looks like WM_PAINT is
 | ||||
| 	// ignored. But InvalidateRect is causing refresh tearing so we
 | ||||
| 	// don't want to use that while active.
 | ||||
| 	// Refresh still sucks though and marquee no longer works... :(
 | ||||
| 	// TODO: Create our own progress bar control with text overlay and inverted text
 | ||||
| 	if (!progress_in_use) | ||||
| 		InvalidateRect(hProgress, NULL, TRUE); | ||||
| 	else | ||||
| 		SendMessage(hProgress, WM_PAINT, 0, 0); | ||||
| 	InvalidateRect(hProgress, NULL, TRUE); | ||||
| } | ||||
| static void PrintStatusMessage(char* msg) { | ||||
| 	SendMessageLU(hStatus, SB_SETTEXTW, SBT_OWNERDRAW | SB_SECTION_LEFT, msg); | ||||
|  |  | |||
							
								
								
									
										94
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										94
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -102,7 +102,7 @@ BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }, bi_save = { 0 } | |||
| char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH]; | ||||
| char *image_path = NULL, *short_image_path; | ||||
| float fScale = 1.0f; | ||||
| int default_fs, fs, bt, ps, tt; | ||||
| int default_fs, fs, bt, pt, tt; // file system, boot type, partition type, target type
 | ||||
| int cbw, ddw, ddbh = 0, bh = 0; // (empty) check box width, (empty) drop down width, button height (for and without dropdown match)
 | ||||
| uint32_t dur_mins, dur_secs; | ||||
| loc_cmd* selected_locale = NULL; | ||||
|  | @ -334,19 +334,19 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target) | |||
| 				preferred_ps = PARTITION_STYLE_MBR; | ||||
| 		} | ||||
| 		SetComboEntry(hPartitionScheme, preferred_ps); | ||||
| 		ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); | ||||
| 		pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); | ||||
| 	} | ||||
| 
 | ||||
| 	has_uefi_csm = FALSE; | ||||
| 	if (allowed_target_system[0] && (ps != PARTITION_STYLE_GPT)) { | ||||
| 	if (allowed_target_system[0] && (pt != PARTITION_STYLE_GPT)) { | ||||
| 		IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, | ||||
| 			ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_031)), TT_BIOS)); | ||||
| 		has_uefi_csm = TRUE; | ||||
| 	} | ||||
| 	if (allowed_target_system[1] && !((ps == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) ) | ||||
| 	if (allowed_target_system[1] && !((pt == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) ) | ||||
| 		IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, | ||||
| 			ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_032)), TT_UEFI)); | ||||
| 	if (allowed_target_system[2] && ((ps != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE))) | ||||
| 	if (allowed_target_system[2] && ((pt != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE))) | ||||
| 		IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, | ||||
| 			ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_033)), TT_BIOS)); | ||||
| 	IGNORE_RETVAL(ComboBox_SetCurSel(hTargetSystem, 0)); | ||||
|  | @ -647,7 +647,7 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes) | |||
| 	BOOL actual_enable_fix = enable; | ||||
| 	static UINT uXPartChecked = BST_UNCHECKED; | ||||
| 
 | ||||
| 	if ((ps != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) { | ||||
| 	if ((pt != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) { | ||||
| 		// These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable
 | ||||
| 		actual_enable_mbr = FALSE; | ||||
| 		actual_enable_fix = FALSE; | ||||
|  | @ -1444,7 +1444,7 @@ static BOOL BootCheck(void) | |||
| 				return FALSE; | ||||
| 			} | ||||
| 			if (SelectedDrive.MediaType != FixedMedia) { | ||||
| 				if ((tt == TT_UEFI) && (ps == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) { | ||||
| 				if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) { | ||||
| 					// Up to Windows 10 Creators Update, we were screwed, since we need access to 2 partitions at the same time.
 | ||||
| 					// Thankfully, the newer Windows allow mounting multiple partitions on the same REMOVABLE drive.
 | ||||
| 					MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); | ||||
|  | @ -1750,25 +1750,69 @@ static __inline const char* IsAlphaOrBeta(void) | |||
| static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam, LPARAM lParam) | ||||
| { | ||||
| 	HDC hDC; | ||||
| 	RECT rect; | ||||
| 	PAINTSTRUCT paint_struct; | ||||
| 	wchar_t winfo[128] = L"Copying ISO files..."; | ||||
| 	RECT rc; | ||||
| 	PAINTSTRUCT ps; | ||||
| 	SIZE size; | ||||
| 	LONG full_right; | ||||
| 	wchar_t winfo[128]; | ||||
| 	static WORD pos = 0, min = 0, max = 0xFFFF; | ||||
| 	static COLORREF color = RGB(0x06, 0xB0, 0x25); | ||||
| 
 | ||||
| 	switch (message) { | ||||
| 
 | ||||
| 	case PBM_SETSTATE: | ||||
| 		switch (wParam) { | ||||
| 		case PBST_NORMAL: | ||||
| 			color = RGB(0x06, 0xB0, 0x25); | ||||
| 			break; | ||||
| 		case PBST_PAUSED: | ||||
| 			color = RGB(0xDA, 0xCB, 0x26); | ||||
| 			break; | ||||
| 		case PBST_ERROR: | ||||
| 			color = RGB(0xDA, 0x26, 0x26); | ||||
| 			break; | ||||
| 		} | ||||
| 		return (INT_PTR)TRUE; | ||||
| 
 | ||||
| 	case PBM_SETRANGE: | ||||
| 		min = lParam & 0xFFFF; | ||||
| 		max = lParam >> 16; | ||||
| 		return (INT_PTR)TRUE; | ||||
| 
 | ||||
| 	case PBM_SETPOS: | ||||
| 		pos = (WORD)wParam; | ||||
| 		InvalidateRect(hProgress, NULL, TRUE); | ||||
| 		return (INT_PTR)TRUE; | ||||
| 
 | ||||
| 	case WM_PAINT: | ||||
| 		hDC = BeginPaint(hCtrl, &paint_struct); | ||||
| 		CallWindowProc(progress_original_proc, hCtrl, message, (WPARAM)hDC, lParam); | ||||
| 		hDC = BeginPaint(hCtrl, &ps); | ||||
| 		GetClientRect(hCtrl, &rc); | ||||
| 		SelectObject(hDC, GetStockObject(DC_PEN)); | ||||
| 		SelectObject(hDC, GetStockObject(NULL_BRUSH)); | ||||
| 		SetDCPenColor(hDC, RGB(0xBC, 0xBC, 0xBC)); | ||||
| 		Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); | ||||
| 		InflateRect(&rc, -1, -1); | ||||
| 		// TODO: Handle SetText message so we can avoid this call
 | ||||
| 		GetWindowTextW(hProgress, winfo, ARRAYSIZE(winfo)); | ||||
| 		SetBkMode(hDC, TRANSPARENT); | ||||
| 		full_right = rc.right; | ||||
| 		rc.right = (pos > min) ? MulDiv(pos - min, rc.right, max - min) : rc.left; | ||||
| 		SelectObject(hDC, hInfoFont); | ||||
| 		GetTextExtentPoint32(hDC, winfo, wcslen(winfo), &size); | ||||
| 		// First half
 | ||||
| 		SetTextColor(hDC, RGB(0xFF, 0xFF, 0xFF)); | ||||
| 		SetTextAlign(hDC, TA_CENTER | TA_BASELINE); | ||||
| 		GetClientRect(hCtrl, &rect); | ||||
| 		ExtTextOutW(hDC, rect.right / 2, rect.bottom / 2 + (int)(4.0f * fScale), | ||||
| 			ETO_CLIPPED | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0), | ||||
| 			&rect, winfo, (int)wcslen(winfo), NULL); | ||||
| 		EndPaint(hCtrl, &paint_struct); | ||||
| 		SetBkColor(hDC, color); | ||||
| 		ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, | ||||
| 			ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0), | ||||
| 			&rc, winfo, wcslen(winfo), NULL); | ||||
| 		// Second half
 | ||||
| 		SetTextColor(hDC, RGB(0x00, 0x00, 0x00)); | ||||
| 		SetBkColor(hDC, RGB(0xE6, 0xE6, 0xE6)); | ||||
| 		rc.left = rc.right; | ||||
| 		rc.right = full_right; | ||||
| 		ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, | ||||
| 			ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0), | ||||
| 			&rc, winfo, wcslen(winfo), NULL); | ||||
| 		EndPaint(hCtrl, &ps); | ||||
| 		return (INT_PTR)TRUE; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -2804,7 +2848,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 	RECT rc, DialogRect, DesktopRect; | ||||
| 	LONG progress_style; | ||||
| 	HDC hDC; | ||||
| 	PAINTSTRUCT paint_struct; | ||||
| 	PAINTSTRUCT ps; | ||||
| 	int nDeviceIndex, i, nWidth, nHeight, nb_devices, selected_language, offset; | ||||
| 	char tmp[128]; | ||||
| 	wchar_t* wbuffer = NULL; | ||||
|  | @ -2976,7 +3020,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 		case IDC_PARTITION_TYPE: | ||||
| 			if (HIWORD(wParam) != CBN_SELCHANGE) | ||||
| 				break; | ||||
| 			ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); | ||||
| 			pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); | ||||
| 			SetPartitionSchemeAndTargetSystem(TRUE); | ||||
| 			SetFileSystemAndClusterSize(NULL); | ||||
| 			EnableMBRBootOptions(TRUE, FALSE); | ||||
|  | @ -3026,7 +3070,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 			SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); | ||||
| 			EnableControls(TRUE); | ||||
| 			tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); | ||||
| 			ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); | ||||
| 			pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); | ||||
| 			return (INT_PTR)TRUE; | ||||
| 		case IDC_SELECT: | ||||
| 			if (iso_provided) { | ||||
|  | @ -3075,7 +3119,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 			// Just in case
 | ||||
| 			bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); | ||||
| 			tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); | ||||
| 			ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); | ||||
| 			pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); | ||||
| 			fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); | ||||
| 			write_as_image = FALSE; | ||||
| 			// Disable all controls except Cancel
 | ||||
|  | @ -3334,9 +3378,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 		break; | ||||
| 
 | ||||
| 	case WM_PAINT: | ||||
| 		hDC = BeginPaint(hDlg, &paint_struct); | ||||
| 		hDC = BeginPaint(hDlg, &ps); | ||||
| 		OnPaint(hDC); | ||||
| 		EndPaint(hDlg, &paint_struct); | ||||
| 		EndPaint(hDlg, &ps); | ||||
| 		break; | ||||
| 
 | ||||
| 	case WM_CTLCOLORSTATIC: | ||||
|  |  | |||
|  | @ -398,7 +398,7 @@ extern int64_t iso_blocking_status; | |||
| extern uint16_t rufus_version[3], embedded_sl_version[2]; | ||||
| extern int nWindowsVersion; | ||||
| extern int nWindowsBuildNumber; | ||||
| extern int fs, bt, ps, tt; | ||||
| extern int fs, bt, pt, tt; | ||||
| extern char WindowsVersionStr[128]; | ||||
| extern size_t ubuffer_pos; | ||||
| extern char ubuffer[UBUFFER_SIZE]; | ||||
|  |  | |||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | |||
| IDD_DIALOG DIALOGEX 12, 12, 232, 326 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_ACCEPTFILES | ||||
| CAPTION "Rufus 3.0.1247" | ||||
| CAPTION "Rufus 3.0.1248" | ||||
| FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | ||||
| BEGIN | ||||
|     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP | ||||
|  | @ -371,8 +371,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 2,18,1247,0 | ||||
|  PRODUCTVERSION 2,18,1247,0 | ||||
|  FILEVERSION 3,0,1248,0 | ||||
|  PRODUCTVERSION 3,0,1248,0 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -389,13 +389,13 @@ BEGIN | |||
|         BEGIN | ||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "2.18.1247" | ||||
|             VALUE "FileVersion", "3.0.1248" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "2.18.1247" | ||||
|             VALUE "ProductVersion", "3.0.1248" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue