Commit 562dd4ab authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

comdlg32: Add helpers for getting and setting the devmode papersize.

parent c1209a68
...@@ -2575,13 +2575,28 @@ static WORD pagesetup_get_orientation(PageSetupDataA *pda) ...@@ -2575,13 +2575,28 @@ static WORD pagesetup_get_orientation(PageSetupDataA *pda)
return orient; return orient;
} }
static void pagesetup_set_papersize(PageSetupDataA *pda, WORD paper)
{
DEVMODEA *dm = GlobalLock(pda->dlga->hDevMode);
dm->u1.s1.dmPaperSize = paper;
GlobalUnlock(pda->dlga->hDevMode);
}
static WORD pagesetup_get_papersize(PageSetupDataA *pda)
{
DEVMODEA *dm = GlobalLock(pda->dlga->hDevMode);
WORD paper = dm->u1.s1.dmPaperSize;
GlobalUnlock(pda->dlga->hDevMode);
return paper;
}
static BOOL pagesetup_update_papersize(PageSetupDataA *pda) static BOOL pagesetup_update_papersize(PageSetupDataA *pda)
{ {
DEVNAMES *dn; DEVNAMES *dn;
DEVMODEA *dm; DEVMODEA *dm;
LPSTR devname, portname; LPSTR devname, portname;
int i, num; int i, num;
WORD *words = NULL; WORD *words = NULL, paperword;
POINT *points = NULL; POINT *points = NULL;
BOOL retval = FALSE; BOOL retval = FALSE;
...@@ -2612,13 +2627,15 @@ static BOOL pagesetup_update_papersize(PageSetupDataA *pda) ...@@ -2612,13 +2627,15 @@ static BOOL pagesetup_update_papersize(PageSetupDataA *pda)
goto end; goto end;
} }
paperword = pagesetup_get_papersize(pda);
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
if (words[i] == dm->u1.s1.dmPaperSize) if (words[i] == paperword)
break; break;
if (i == num) if (i == num)
{ {
FIXME("Papersize %d not found in list?\n", dm->u1.s1.dmPaperSize); FIXME("Papersize %d not found in list?\n", paperword);
goto end; goto end;
} }
...@@ -3046,9 +3063,7 @@ PRINTDLG_PS_WMCommandA( ...@@ -3046,9 +3063,7 @@ PRINTDLG_PS_WMCommandA(
SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0), 0); SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0), 0);
if (paperword != CB_ERR) if (paperword != CB_ERR)
{ {
DEVMODEA *dm = GlobalLock(pda->dlga->hDevMode); pagesetup_set_papersize(pda, paperword);
dm->u1.s1.dmPaperSize = paperword;
GlobalUnlock(pda->dlga->hDevMode);
pagesetup_update_papersize(pda); pagesetup_update_papersize(pda);
PRINTDLG_PS_ChangePaperPrev(pda); PRINTDLG_PS_ChangePaperPrev(pda);
} else } else
...@@ -3090,9 +3105,10 @@ PRINTDLG_PS_WMCommandA( ...@@ -3090,9 +3105,10 @@ PRINTDLG_PS_WMCommandA(
PRINTDLG_PS_ChangePaperPrev(pda); PRINTDLG_PS_ChangePaperPrev(pda);
/* Selecting paper in combo */ /* Selecting paper in combo */
count = SendDlgItemMessageA(hDlg, cmb2, CB_GETCOUNT, 0, 0); count = SendDlgItemMessageA(hDlg, cmb2, CB_GETCOUNT, 0, 0);
if(count != CB_ERR){ if(count != CB_ERR) {
WORD paperword = pagesetup_get_papersize(pda);
for(i=0; i<count; ++i){ for(i=0; i<count; ++i){
if(SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0) == dm->u1.s1.dmPaperSize) { if(SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0) == paperword) {
SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0); SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
break; break;
} }
......
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