This MR fixes a few issues in the printdlg and adds the printer name to stc1.
This fixes some of the issues in the Quicken Print Dialog from the tax summary.
-- v4: comdlg32: Change WMCommandW to match WMCommandA comdlg32: Use ANSI functions in ANSI WMCommandA comdlg32: Populate printer name on the print dialogs comdlg32: Add resolutions to PRINTDLG_ChangePrinterW comdlg32: Use values from DeviceCapabilities in combobox.
From: Brendan McGrath bmcgrath@codeweavers.com
dpiX,dpiY are the default printer values from the GetDeviceCaps calls. This causes the item data to be the same for every option in the combobox.
The item data should reflect the selected values. --- dlls/comdlg32/printdlg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c index 700119bc9ff..2a2b7e9d1b2 100644 --- a/dlls/comdlg32/printdlg.c +++ b/dlls/comdlg32/printdlg.c @@ -1229,7 +1229,7 @@ static BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, PRINT_PTRA *PrintStru if(IsDefault) SendMessageA(hQuality, CB_SETCURSEL, Index, 0);
- SendMessageA(hQuality, CB_SETITEMDATA, Index, MAKELONG(dpiX,dpiY)); + SendMessageA(hQuality, CB_SETITEMDATA, Index, MAKELONG(Resolutions[i], Resolutions[i+1])); } free(Resolutions); }
From: Brendan McGrath bmcgrath@codeweavers.com
This was done in PRINTDLG_ChangePrinterA, but missing from PRINTDLG_ChangePrinterW --- dlls/comdlg32/printdlg.c | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c index 2a2b7e9d1b2..b777a83825f 100644 --- a/dlls/comdlg32/printdlg.c +++ b/dlls/comdlg32/printdlg.c @@ -1386,6 +1386,61 @@ static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name, if (lppd->Flags & PD_HIDEPRINTTOFILE) ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
+ /* Fill print quality combo, PrintDlg16 */ + if (GetDlgItem(hDlg, cmb1)) + { + DWORD num_resolutions = DeviceCapabilitiesW(PrintStructures->lpPrinterInfo->pPrinterName, + PrintStructures->lpPrinterInfo->pPortName, + DC_ENUMRESOLUTIONS, NULL, lpdm); + + if (num_resolutions != -1) + { + HWND quality = GetDlgItem(hDlg, cmb1); + LONG* resolutions; + WCHAR buf[255]; + DWORD i; + int dpiX, dpiY; + HDC printer = CreateDCW(PrintStructures->lpPrinterInfo->pDriverName, + PrintStructures->lpPrinterInfo->pPrinterName, + 0, lpdm); + + resolutions = malloc(num_resolutions * sizeof(LONG) * 2); + DeviceCapabilitiesW(PrintStructures->lpPrinterInfo->pPrinterName, + PrintStructures->lpPrinterInfo->pPortName, + DC_ENUMRESOLUTIONS, (LPWSTR)resolutions, lpdm); + + dpiX = GetDeviceCaps(printer, LOGPIXELSX); + dpiY = GetDeviceCaps(printer, LOGPIXELSY); + DeleteDC(printer); + + SendMessageW(quality, CB_RESETCONTENT, 0, 0); + for (i = 0; i < (num_resolutions * 2); i += 2) + { + BOOL is_default = FALSE; + LRESULT index; + + if (resolutions[i] == resolutions[i+1]) + { + if (dpiX == resolutions[i]) + is_default = TRUE; + swprintf(buf, sizeof(buf), L"%ld dpi", resolutions[i]); + } else + { + if (dpiX == resolutions[i] && dpiY == resolutions[i+1]) + is_default = TRUE; + swprintf(buf, sizeof(buf), L"%ld dpi x %ld dpi", resolutions[i], resolutions[i+1]); + } + + index = SendMessageW(quality, CB_ADDSTRING, 0, (LPARAM)buf); + + if (is_default) + SendMessageW(quality, CB_SETCURSEL, index, 0); + + SendMessageW(quality, CB_SETITEMDATA, index, MAKELONG(resolutions[i], resolutions[i+1])); + } + free(resolutions); + } + } } else { /* PD_PRINTSETUP */ BOOL bPortrait = (lpdm->dmOrientation == DMORIENT_PORTRAIT);
From: Brendan McGrath bmcgrath@codeweavers.com
This will display the name of the selected printer on the Print dialog and the default printer on the Print Setup dialog --- dlls/comdlg32/printdlg.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c index b777a83825f..e90a9e00efb 100644 --- a/dlls/comdlg32/printdlg.c +++ b/dlls/comdlg32/printdlg.c @@ -978,10 +978,11 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, /*********************************************************************** * PRINTDLG_UpdatePrinterInfoTexts [internal] */ -static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, const PRINTER_INFO_2A *pi) +static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, DWORD flags, const PRINTER_INFO_2A *pi) { char StatusMsg[256]; char ResourceString[256]; + char printer_name[256]; int i;
/* Status Message */ @@ -1004,6 +1005,17 @@ static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, const PRINTER_INFO_2A *p SetDlgItemTextA(hDlg, stc12, StatusMsg);
/* set all other printer info texts */ + if (flags & PD_PRINTSETUP) + { + DWORD dwBufLen = ARRAY_SIZE(printer_name); + GetDefaultPrinterA(printer_name, &dwBufLen); + } + else + { + /* FIXME: Windows decorates the printer name with text like 'System Printer' or 'on <port>'. */ + lstrcpynA(printer_name, pi->pPrinterName, ARRAY_SIZE(printer_name)); + } + SetDlgItemTextA(hDlg, stc1, printer_name); SetDlgItemTextA(hDlg, stc11, pi->pDriverName);
if (pi->pLocation != NULL && pi->pLocation[0] != '\0') @@ -1014,11 +1026,12 @@ static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, const PRINTER_INFO_2A *p return; }
-static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg, const PRINTER_INFO_2W *pi) +static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg, DWORD flags, const PRINTER_INFO_2W *pi) { WCHAR StatusMsg[256]; WCHAR ResourceString[256]; - int i; + WCHAR printer_name[256]; + int i;
/* Status Message */ StatusMsg[0]='\0'; @@ -1040,6 +1053,17 @@ static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg, const PRINTER_INFO_2W *p SetDlgItemTextW(hDlg, stc12, StatusMsg);
/* set all other printer info texts */ + if (flags & PD_PRINTSETUP) + { + DWORD dwBufLen = ARRAY_SIZE(printer_name); + GetDefaultPrinterW(printer_name, &dwBufLen); + } + else + { + /* FIXME: Windows decorates the printer name with text like 'System Printer' or 'on <port>'. */ + lstrcpynW(printer_name, pi->pPrinterName, ARRAY_SIZE(printer_name)); + } + SetDlgItemTextW(hDlg, stc1, printer_name); SetDlgItemTextW(hDlg, stc11, pi->pDriverName); if (pi->pLocation != NULL && pi->pLocation[0] != '\0') SetDlgItemTextW(hDlg, stc14, pi->pLocation); @@ -1081,7 +1105,7 @@ static BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, PRINT_PTRA *PrintStru } ClosePrinter(hprn);
- PRINTDLG_UpdatePrinterInfoTextsA(hDlg, PrintStructures->lpPrinterInfo); + PRINTDLG_UpdatePrinterInfoTextsA(hDlg, lppd->Flags, PrintStructures->lpPrinterInfo);
free(PrintStructures->lpDevMode); PrintStructures->lpDevMode = NULL; @@ -1288,7 +1312,7 @@ static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name, } ClosePrinter(hprn);
- PRINTDLG_UpdatePrinterInfoTextsW(hDlg, PrintStructures->lpPrinterInfo); + PRINTDLG_UpdatePrinterInfoTextsW(hDlg, lppd->Flags, PrintStructures->lpPrinterInfo);
free(PrintStructures->lpDevMode); PrintStructures->lpDevMode = NULL;
From: Brendan McGrath bmcgrath@codeweavers.com
--- dlls/comdlg32/printdlg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c index e90a9e00efb..d300b46a5b6 100644 --- a/dlls/comdlg32/printdlg.c +++ b/dlls/comdlg32/printdlg.c @@ -1840,8 +1840,8 @@ static LRESULT PRINTDLG_WMCommandA(HWND hDlg, WPARAM wParam, case cmb4: /* Printer combobox */ if (HIWORD(wParam)==CBN_SELCHANGE) { char *PrinterName; - INT index = SendDlgItemMessageW(hDlg, LOWORD(wParam), CB_GETCURSEL, 0, 0); - INT length = SendDlgItemMessageW(hDlg, LOWORD(wParam), CB_GETLBTEXTLEN, index, 0); + INT index = SendDlgItemMessageA(hDlg, LOWORD(wParam), CB_GETCURSEL, 0, 0); + INT length = SendDlgItemMessageA(hDlg, LOWORD(wParam), CB_GETLBTEXTLEN, index, 0); PrinterName = malloc(length + 1); SendDlgItemMessageA(hDlg, LOWORD(wParam), CB_GETLBTEXT, index, (LPARAM)PrinterName); PRINTDLG_ChangePrinterA(hDlg, PrinterName, PrintStructures);
From: Brendan McGrath bmcgrath@codeweavers.com
We shouldn't treat cmb1 as a Printer combobox unless it is the PrinterComboID --- dlls/comdlg32/printdlg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c index d300b46a5b6..d33e57addfc 100644 --- a/dlls/comdlg32/printdlg.c +++ b/dlls/comdlg32/printdlg.c @@ -1988,8 +1988,10 @@ static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam, } break;
- case cmb1: /* Printer Combobox in PRINT SETUP */ - /* FALLTHROUGH */ + case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT16 */ + if (PrinterComboID != LOWORD(wParam)) { + break; + } case cmb4: /* Printer combobox */ if (HIWORD(wParam)==CBN_SELCHANGE) { WCHAR *PrinterName;
Huw Davies (@huw) commented about dlls/comdlg32/printdlg.c:
} break;
- case cmb1: /* Printer Combobox in PRINT SETUP */
/* FALLTHROUGH */
- case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT16 */
if (PrinterComboID != LOWORD(wParam)) {
break;
}
```suggestion:-0+0 } /* FALLTHROUGH */ ```
The commit message could be better, e.g. ``` comdlg32: Don't treat cmb1 as the printer list unless in PRINT_SETUP.
This changes WMCommandW to match WMCommandA. ```
Essentially swapping the subject with the sentence in the body.