Avoid W->A transitions.

This commit is contained in:
Dimitrie O. Paun 2004-09-22 19:11:05 +00:00 committed by Alexandre Julliard
parent 268f62f47d
commit afab8342bb

View File

@ -156,17 +156,15 @@ static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name)
if(!name ||
(i = SendDlgItemMessageW(hDlg, id, CB_FINDSTRINGEXACT, -1,
(LPARAM)name)) == CB_ERR) {
/* ansi is ok */
char buf[260];
DWORD dwBufLen = sizeof(buf);
FIXME("Can't find '%s' in printer list so trying to find default\n",
WCHAR buf[260];
DWORD dwBufLen = sizeof(buf)/sizeof(buf[0]);
TRACE("Can't find '%s' in printer list so trying to find default\n",
debugstr_w(name));
if(!GetDefaultPrinterA(buf, &dwBufLen))
if(!GetDefaultPrinterW(buf, &dwBufLen))
return num;
i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
i = SendDlgItemMessageW(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
if(i == CB_ERR)
FIXME("Can't find default printer in printer list\n");
TRACE("Can't find default printer in printer list\n");
}
SendDlgItemMessageW(hDlg, id, CB_SETCURSEL, i, 0);
return num;
@ -378,14 +376,14 @@ static BOOL PRINTDLG_UpdatePrintDlgW(HWND hDlg,
nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
char resourcestr[256];
char resultstr[256];
LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE,
WCHAR resourcestr[256];
WCHAR resultstr[256];
LoadStringW(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE,
resourcestr, 255);
sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE,
wsprintfW(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
LoadStringW(COMDLG32_hInstance, PD32_PRINT_TITLE,
resourcestr, 255);
MessageBoxA(hDlg, resultstr, resourcestr,
MessageBoxW(hDlg, resultstr, resourcestr,
MB_OK | MB_ICONWARNING);
return FALSE;
}
@ -681,13 +679,13 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg,
TRACE(" Printer: %s, Port: %s, ComboID: %d\n",debugstr_w(PrinterName),debugstr_w(PortName),nIDComboBox);
/* query the dialog box for the current selected value */
Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
Sel = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
if(Sel != CB_ERR) {
/* we enter here only if a different printer is selected after
* the Print Setup dialog is opened. The current settings are
* stored into the newly selected printer.
*/
oldWord = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA,
oldWord = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA,
Sel, 0);
if (dm) {
if (nIDComboBox == cmb2)
@ -745,7 +743,7 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg,
fwCapability_Words, (LPWSTR)Words, dm);
/* reset any current content in the combobox */
SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageW(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
/* store new content */
for (i = 0; i < NrOfEntries; i++) {
@ -759,13 +757,13 @@ static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg,
item order will change as more items are added */
Sel = 0;
for (i = 0; i < NrOfEntries; i++) {
if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
if(SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
oldWord) {
Sel = i;
break;
}
}
SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
HeapFree(GetProcessHeap(),0,Words);
HeapFree(GetProcessHeap(),0,Names);
@ -1094,13 +1092,12 @@ static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name,
}
/* "All xxx pages"... */
{
/* ansi is ok */
char resourcestr[64];
char result[64];
LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES,
WCHAR resourcestr[64];
WCHAR result[64];
LoadStringW(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES,
resourcestr, 49);
sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
wsprintfW(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
SendDlgItemMessageW(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
}
/* Collate pages
@ -1108,11 +1105,11 @@ static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name,
* FIXME: The ico3 is not displayed for some reason. I don't know why.
*/
if (lppd->Flags & PD_COLLATE) {
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)PrintStructures->hCollateIcon);
CheckDlgButton(hDlg, chx2, 1);
} else {
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)PrintStructures->hNoCollateIcon);
CheckDlgButton(hDlg, chx2, 0);
}
@ -1164,7 +1161,7 @@ static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name,
PrintStructures->lpPrinterInfo->pPortName,
lpdm);
CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
PrintStructures->hLandscapeIcon));
@ -1292,6 +1289,10 @@ static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam,
static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, WPARAM wParam,
PRINT_PTRW* PrintStructures)
{
const static WCHAR PD32_COLLATE[] = { 'P', 'D', '3', '2', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 };
const static WCHAR PD32_NOCOLLATE[] = { 'P', 'D', '3', '2', '_', 'N', 'O', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 };
const static WCHAR PD32_PORTRAIT[] = { 'P', 'D', '3', '2', '_', 'P', 'O', 'R', 'T', 'R', 'A', 'I', 'T', 0 };
const static WCHAR PD32_LANDSCAPE[] = { 'P', 'D', '3', '2', '_', 'L', 'A', 'N', 'D', 'S', 'C', 'A', 'P', 'E', 0 };
LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
DEVNAMES *pdn;
DEVMODEW *pdm;
@ -1302,18 +1303,18 @@ static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, WPARAM wParam,
/* We load these with LoadImage because they are not a standard
size and we don't want them rescaled */
PrintStructures->hCollateIcon =
LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
LoadImageW(COMDLG32_hInstance, PD32_COLLATE, IMAGE_ICON, 0, 0, 0);
PrintStructures->hNoCollateIcon =
LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
LoadImageW(COMDLG32_hInstance, PD32_NOCOLLATE, IMAGE_ICON, 0, 0, 0);
/* These can be done with LoadIcon */
PrintStructures->hPortraitIcon =
LoadIconA(COMDLG32_hInstance, "PD32_PORTRAIT");
LoadIconW(COMDLG32_hInstance, PD32_PORTRAIT);
PrintStructures->hLandscapeIcon =
LoadIconA(COMDLG32_hInstance, "PD32_LANDSCAPE");
LoadIconW(COMDLG32_hInstance, PD32_LANDSCAPE);
/* display the collate/no_collate icon */
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)PrintStructures->hNoCollateIcon);
if(PrintStructures->hCollateIcon == 0 ||
@ -1331,7 +1332,7 @@ static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, WPARAM wParam,
*/
if (lppd->Flags & PD_SHOWHELP) {
if((PrintStructures->HelpMessageID =
RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
RegisterWindowMessageW(HELPMSGSTRINGW)) == 0) {
COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
return FALSE;
}
@ -1608,10 +1609,10 @@ static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam,
case chx2: /* collate pages checkbox */
if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)PrintStructures->hCollateIcon);
else
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)PrintStructures->hNoCollateIcon);
break;
case edt1: /* from page nr editbox */
@ -1663,7 +1664,7 @@ static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam,
if (lppd->Flags & PD_PRINTSETUP)
{
lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)(PrintStructures->hPortraitIcon));
}
break;
@ -1672,7 +1673,7 @@ static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam,
if (lppd->Flags & PD_PRINTSETUP)
{
lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM)(PrintStructures->hLandscapeIcon));
}
break;
@ -1693,9 +1694,9 @@ static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam,
case cmb2: /* Papersize */
{
DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
DWORD Sel = SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
if(Sel != CB_ERR)
lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
lpdm->u1.s1.dmPaperSize = SendDlgItemMessageW(hDlg, cmb2,
CB_GETITEMDATA,
Sel, 0);
}
@ -1703,7 +1704,7 @@ static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam,
case cmb3: /* Bin */
{
DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
DWORD Sel = SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0);
if(Sel != CB_ERR)
lpdm->dmDefaultSource = SendDlgItemMessageW(hDlg, cmb3,
CB_GETITEMDATA, Sel,
@ -1718,20 +1719,20 @@ static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam,
if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
SendDlgItemMessageW(hDlg, stc10, STM_SETIMAGE,
(WPARAM)IMAGE_ICON,
(LPARAM)PrintStructures->hPortraitIcon);
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE,
(WPARAM)IMAGE_ICON,
(LPARAM)PrintStructures->hPortraitIcon);
}
} else {
if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
SendDlgItemMessageW(hDlg, stc10, STM_SETIMAGE,
(WPARAM)IMAGE_ICON,
(LPARAM)PrintStructures->hLandscapeIcon);
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE,
(WPARAM)IMAGE_ICON,
(LPARAM)PrintStructures->hLandscapeIcon);
}
@ -2382,23 +2383,26 @@ _c_size2strA(PageSetupDataA *pda,DWORD size,LPSTR strout) {
return;
}
static void
_c_size2strW(PageSetupDataW *pda,DWORD size,LPSTR strout) {
strcpy(strout,"<undef>");
_c_size2strW(PageSetupDataW *pda,DWORD size,LPWSTR strout) {
const static WCHAR UNDEF[] = { '<', 'u', 'n', 'd', 'e', 'f', '>', 0 };
const static WCHAR mm_fmt[] = { '%', '.', '2', 'f', 'm', 'm', 0 };
const static WCHAR in_fmt[] = { '%', '.', '2', 'f', 'i', 'n', 0 };
lstrcpyW(strout, UNDEF);
if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {
sprintf(strout,"%.2fmm",(size*1.0)/100.0);
wsprintfW(strout,mm_fmt,(size*1.0)/100.0);
return;
}
if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {
sprintf(strout,"%.2fin",(size*1.0)/1000.0);
wsprintfW(strout,in_fmt,(size*1.0)/1000.0);
return;
}
pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
sprintf(strout,"%.2fmm",(size*1.0)/100.0);
wsprintfW(strout,mm_fmt,(size*1.0)/100.0);
return;
}
static DWORD
_c_str2size(PAGESETUPDLGA *dlga,LPCSTR strin) {
_c_str2sizeA(PAGESETUPDLGA *dlga,LPCSTR strin) {
float val;
char rest[200];
@ -2437,6 +2441,17 @@ _c_str2size(PAGESETUPDLGA *dlga,LPCSTR strin) {
}
static DWORD
_c_str2sizeW(PAGESETUPDLGW *dlga, LPCWSTR strin) {
char buf[200];
/* this W -> A transition is OK */
/* we need a unicode version of sscanf to avoid it */
WideCharToMultiByte(CP_ACP, 0, strin, -1, buf, sizeof(buf), NULL, NULL);
return _c_str2sizeA((PAGESETUPDLGA *)dlga, buf);
}
/*
* This is called on finish and will update the output fields of the
* struct.
@ -2462,7 +2477,7 @@ PRINTDLG_PS_UpdateDlgStructA(HWND hDlg, PageSetupDataA *pda) {
pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y);
} else
FIXME("could not get dialog text for papersize cmbbox?\n");
#define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size(pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
#define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2sizeA(pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
GETVAL(edt4,pda->dlga->rtMargin.left);
GETVAL(edt5,pda->dlga->rtMargin.top);
GETVAL(edt6,pda->dlga->rtMargin.right);
@ -2487,8 +2502,7 @@ PRINTDLG_PS_UpdateDlgStructW(HWND hDlg, PageSetupDataW *pda) {
DEVMODEW *dm;
LPWSTR devname,portname;
WCHAR papername[64];
char buf[200];
WCHAR buf[200];
dn = GlobalLock(pda->pdlg.hDevNames);
dm = GlobalLock(pda->pdlg.hDevMode);
@ -2503,7 +2517,7 @@ PRINTDLG_PS_UpdateDlgStructW(HWND hDlg, PageSetupDataW *pda) {
pda->dlga->ptPaperSize.y = _c_10mm2size((LPPAGESETUPDLGA)pda->dlga,pda->dlga->ptPaperSize.y);
} else
FIXME("could not get dialog text for papersize cmbbox?\n");
#define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size((LPPAGESETUPDLGA)pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
#define GETVAL(id,val) if (GetDlgItemTextW(hDlg,id,buf,sizeof(buf)/sizeof(buf[0]))>0) { val = _c_str2sizeW(pda->dlga,buf); } else { FIXME("could not get dlgitemtextw for %x\n",id); }
GETVAL(edt4,pda->dlga->rtMargin.left);
GETVAL(edt5,pda->dlga->rtMargin.top);
GETVAL(edt6,pda->dlga->rtMargin.right);
@ -2703,13 +2717,16 @@ PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
static INT_PTR CALLBACK
PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
const static WCHAR __WINE_PAGESETUPDLGDATA[] =
{ '_', '_', 'W', 'I', 'N', 'E', '_', 'P', 'A', 'G', 'E',
'S', 'E', 'T', 'U', 'P', 'D', 'L', 'G', 'D', 'A', 'T', 'A', 0 };
PageSetupDataW *pda;
BOOL res = FALSE;
if (uMsg==WM_INITDIALOG) {
res = TRUE;
pda = (PageSetupDataW*)lParam;
SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",pda);
SetPropW(hDlg, __WINE_PAGESETUPDLGDATA, pda);
if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,(LPARAM)pda->dlga);
if (!res) {
@ -2739,24 +2756,24 @@ PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
/* We fill them out enabled or not */
if (pda->dlga->Flags & PSD_MARGINS) {
char str[100];
WCHAR str[100];
_c_size2strW(pda,pda->dlga->rtMargin.left,str);
SetDlgItemTextA(hDlg,edt4,str);
SetDlgItemTextW(hDlg,edt4,str);
_c_size2strW(pda,pda->dlga->rtMargin.top,str);
SetDlgItemTextA(hDlg,edt5,str);
SetDlgItemTextW(hDlg,edt5,str);
_c_size2strW(pda,pda->dlga->rtMargin.right,str);
SetDlgItemTextA(hDlg,edt6,str);
SetDlgItemTextW(hDlg,edt6,str);
_c_size2strW(pda,pda->dlga->rtMargin.bottom,str);
SetDlgItemTextA(hDlg,edt7,str);
SetDlgItemTextW(hDlg,edt7,str);
} else {
/* default is 1 inch */
DWORD size = _c_inch2size((LPPAGESETUPDLGA)pda->dlga,1000);
char str[20];
WCHAR str[20];
_c_size2strW(pda,size,str);
SetDlgItemTextA(hDlg,edt4,str);
SetDlgItemTextA(hDlg,edt5,str);
SetDlgItemTextA(hDlg,edt6,str);
SetDlgItemTextA(hDlg,edt7,str);
SetDlgItemTextW(hDlg,edt4,str);
SetDlgItemTextW(hDlg,edt5,str);
SetDlgItemTextW(hDlg,edt6,str);
SetDlgItemTextW(hDlg,edt7,str);
}
PRINTDLG_PS_ChangePrinterW(hDlg,pda);
if (pda->dlga->Flags & PSD_DISABLEPAPER) {
@ -2765,7 +2782,7 @@ PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return TRUE;
} else {
pda = (PageSetupDataW*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA");
pda = (PageSetupDataW*)GetPropW(hDlg, __WINE_PAGESETUPDLGDATA);
if (!pda) {
WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
return FALSE;