Commit 016b7c53 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

comdlg32: When changing printers, only preserve the paper/bin settings if the…

comdlg32: When changing printers, only preserve the paper/bin settings if the new printer has the original setting available.
parent c9b70e66
...@@ -616,8 +616,8 @@ static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg, ...@@ -616,8 +616,8 @@ static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg,
int NrOfEntries; int NrOfEntries;
char* Names; char* Names;
WORD* Words; WORD* Words;
DWORD Sel; DWORD Sel, old_Sel;
WORD oldWord = 0; WORD oldWord = 0, newWord = 0; /* DMPAPER_ and DMBIN_ start at 1 */
int NamesSize; int NamesSize;
int fwCapability_Names; int fwCapability_Names;
int fwCapability_Words; int fwCapability_Words;
...@@ -633,26 +633,14 @@ static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg, ...@@ -633,26 +633,14 @@ static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg,
*/ */
oldWord = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, oldWord = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA,
Sel, 0); Sel, 0);
if (dm) { if(oldWord >= DMPAPER_USER) /* DMPAPER_USER == DMBIN_USER */
if (nIDComboBox == cmb2) oldWord = 0; /* There's no point in trying to keep custom
dm->u1.s1.dmPaperSize = oldWord; paper / bin sizes across printers */
else
dm->u1.s1.dmDefaultSource = oldWord;
}
}
else {
/* we enter here only when the Print setup dialog is initially
* opened. In this case the settings are restored from when
* the dialog was last closed.
*/
if (dm) {
if (nIDComboBox == cmb2)
oldWord = dm->u1.s1.dmPaperSize;
else
oldWord = dm->u1.s1.dmDefaultSource;
}
} }
if (dm)
newWord = (nIDComboBox == cmb2) ? dm->u1.s1.dmPaperSize : dm->u1.s1.dmDefaultSource;
if (nIDComboBox == cmb2) { if (nIDComboBox == cmb2) {
NamesSize = 64; NamesSize = 64;
fwCapability_Names = DC_PAPERNAMES; fwCapability_Names = DC_PAPERNAMES;
...@@ -695,16 +683,32 @@ static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg, ...@@ -695,16 +683,32 @@ static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg,
Words[i]); Words[i]);
} }
/* Look for old selection - can't do this is previous loop since /* Look for old selection or the new default.
item order will change as more items are added */ Can't do this is previous loop since item order will change as more items are added */
Sel = 0; Sel = 0;
old_Sel = NrOfEntries;
for (i = 0; i < NrOfEntries; i++) { for (i = 0; i < NrOfEntries; i++) {
if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
oldWord) { oldWord) {
Sel = i; old_Sel = i;
break; break;
} }
if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == newWord)
Sel = i;
}
if(old_Sel < NrOfEntries)
{
if (dm)
{
if(nIDComboBox == cmb2)
dm->u1.s1.dmPaperSize = oldWord;
else
dm->u1.s1.dmDefaultSource = oldWord;
}
Sel = old_Sel;
} }
SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0); SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
HeapFree(GetProcessHeap(),0,Words); HeapFree(GetProcessHeap(),0,Words);
...@@ -722,8 +726,8 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, ...@@ -722,8 +726,8 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg,
int NrOfEntries; int NrOfEntries;
WCHAR* Names; WCHAR* Names;
WORD* Words; WORD* Words;
DWORD Sel; DWORD Sel, old_Sel;
WORD oldWord = 0; WORD oldWord = 0, newWord = 0; /* DMPAPER_ and DMBIN_ start at 1 */
int NamesSize; int NamesSize;
int fwCapability_Names; int fwCapability_Names;
int fwCapability_Words; int fwCapability_Words;
...@@ -739,26 +743,15 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, ...@@ -739,26 +743,15 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg,
*/ */
oldWord = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA, oldWord = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA,
Sel, 0); Sel, 0);
if (dm) {
if (nIDComboBox == cmb2) if(oldWord >= DMPAPER_USER) /* DMPAPER_USER == DMBIN_USER */
dm->u1.s1.dmPaperSize = oldWord; oldWord = 0; /* There's no point in trying to keep custom
else paper / bin sizes across printers */
dm->u1.s1.dmDefaultSource = oldWord;
}
}
else {
/* we enter here only when the Print setup dialog is initially
* opened. In this case the settings are restored from when
* the dialog was last closed.
*/
if (dm) {
if (nIDComboBox == cmb2)
oldWord = dm->u1.s1.dmPaperSize;
else
oldWord = dm->u1.s1.dmDefaultSource;
}
} }
if (dm)
newWord = (nIDComboBox == cmb2) ? dm->u1.s1.dmPaperSize : dm->u1.s1.dmDefaultSource;
if (nIDComboBox == cmb2) { if (nIDComboBox == cmb2) {
NamesSize = 64; NamesSize = 64;
fwCapability_Names = DC_PAPERNAMES; fwCapability_Names = DC_PAPERNAMES;
...@@ -801,16 +794,32 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, ...@@ -801,16 +794,32 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg,
Words[i]); Words[i]);
} }
/* Look for old selection - can't do this is previous loop since /* Look for old selection or the new default.
item order will change as more items are added */ Can't do this is previous loop since item order will change as more items are added */
Sel = 0; Sel = 0;
old_Sel = NrOfEntries;
for (i = 0; i < NrOfEntries; i++) { for (i = 0; i < NrOfEntries; i++) {
if(SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == if(SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
oldWord) { oldWord) {
Sel = i; old_Sel = i;
break; break;
} }
if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == newWord)
Sel = i;
}
if(old_Sel < NrOfEntries)
{
if (dm)
{
if(nIDComboBox == cmb2)
dm->u1.s1.dmPaperSize = oldWord;
else
dm->u1.s1.dmDefaultSource = oldWord;
}
Sel = old_Sel;
} }
SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0); SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
HeapFree(GetProcessHeap(),0,Words); HeapFree(GetProcessHeap(),0,Words);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment