comdlg32: Use a helper to update the devmode handle.
This commit is contained in:
parent
ce9f046388
commit
ecd6f40acb
|
@ -254,6 +254,68 @@ static PRINTER_INFO_2A * get_printer_infoA(HANDLE hprn)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* update_devmode_handle [internal]
|
||||||
|
*
|
||||||
|
* update a devmode handle for the given DEVMODE, alloc the buffer, when needed
|
||||||
|
*/
|
||||||
|
static HGLOBAL update_devmode_handleW(HGLOBAL hdm, DEVMODEW *dm)
|
||||||
|
{
|
||||||
|
SIZE_T size = GlobalSize(hdm);
|
||||||
|
LPVOID ptr;
|
||||||
|
|
||||||
|
/* Increase / alloc the global memory block, when needed */
|
||||||
|
if ((dm->dmSize + dm->dmDriverExtra) > size) {
|
||||||
|
if (hdm)
|
||||||
|
hdm = GlobalReAlloc(hdm, dm->dmSize + dm->dmDriverExtra, 0);
|
||||||
|
else
|
||||||
|
hdm = GlobalAlloc(GMEM_MOVEABLE, dm->dmSize + dm->dmDriverExtra);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hdm) {
|
||||||
|
ptr = GlobalLock(hdm);
|
||||||
|
if (ptr) {
|
||||||
|
memcpy(ptr, dm, dm->dmSize + dm->dmDriverExtra);
|
||||||
|
GlobalUnlock(hdm);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalFree(hdm);
|
||||||
|
hdm = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hdm;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HGLOBAL update_devmode_handleA(HGLOBAL hdm, DEVMODEA *dm)
|
||||||
|
{
|
||||||
|
SIZE_T size = GlobalSize(hdm);
|
||||||
|
LPVOID ptr;
|
||||||
|
|
||||||
|
/* Increase / alloc the global memory block, when needed */
|
||||||
|
if ((dm->dmSize + dm->dmDriverExtra) > size) {
|
||||||
|
if (hdm)
|
||||||
|
hdm = GlobalReAlloc(hdm, dm->dmSize + dm->dmDriverExtra, 0);
|
||||||
|
else
|
||||||
|
hdm = GlobalAlloc(GMEM_MOVEABLE, dm->dmSize + dm->dmDriverExtra);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hdm) {
|
||||||
|
ptr = GlobalLock(hdm);
|
||||||
|
if (ptr) {
|
||||||
|
memcpy(ptr, dm, dm->dmSize + dm->dmDriverExtra);
|
||||||
|
GlobalUnlock(hdm);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalFree(hdm);
|
||||||
|
hdm = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hdm;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* convert_to_devmodeA
|
* convert_to_devmodeA
|
||||||
*
|
*
|
||||||
|
@ -3868,10 +3930,12 @@ BOOL WINAPI PageSetupDlgW(LPPAGESETUPDLGW setupdlg)
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
|
HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
|
||||||
{
|
{
|
||||||
DWORD ret = E_FAIL;
|
PRINTER_INFO_2A *pbuf;
|
||||||
LPVOID ptr;
|
DRIVER_INFO_3A *dbuf;
|
||||||
|
DEVMODEA *dm;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
HANDLE hprn;
|
||||||
|
|
||||||
FIXME("(%p) not fully implemented\n", lppd);
|
|
||||||
if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXA)))
|
if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXA)))
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
@ -3894,10 +3958,6 @@ HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
|
||||||
|
|
||||||
if (lppd->Flags & PD_RETURNDEFAULT)
|
if (lppd->Flags & PD_RETURNDEFAULT)
|
||||||
{
|
{
|
||||||
PRINTER_INFO_2A *pbuf;
|
|
||||||
DRIVER_INFO_3A *dbuf;
|
|
||||||
HANDLE hprn;
|
|
||||||
|
|
||||||
if (lppd->hDevMode || lppd->hDevNames)
|
if (lppd->hDevMode || lppd->hDevNames)
|
||||||
{
|
{
|
||||||
WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
|
WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
|
||||||
|
@ -3926,32 +3986,29 @@ HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
|
||||||
ClosePrinter(hprn);
|
ClosePrinter(hprn);
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
dm = pbuf->pDevMode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FIXME("(%p) dialog not implemented\n", lppd);
|
||||||
|
return E_NOTIMPL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ClosePrinter(hprn);
|
ClosePrinter(hprn);
|
||||||
|
|
||||||
PRINTDLG_CreateDevNames(&(lppd->hDevNames),
|
PRINTDLG_CreateDevNames(&(lppd->hDevNames), dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName);
|
||||||
dbuf->pDriverPath,
|
if (!lppd->hDevNames)
|
||||||
pbuf->pPrinterName,
|
hr = E_FAIL;
|
||||||
pbuf->pPortName);
|
|
||||||
lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
|
lppd->hDevMode = update_devmode_handleA(lppd->hDevMode, dm);
|
||||||
pbuf->pDevMode->dmDriverExtra);
|
if (!lppd->hDevMode)
|
||||||
if (lppd->hDevMode)
|
hr = E_FAIL;
|
||||||
{
|
|
||||||
ptr = GlobalLock(lppd->hDevMode);
|
|
||||||
if (ptr)
|
|
||||||
{
|
|
||||||
memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
|
|
||||||
pbuf->pDevMode->dmDriverExtra);
|
|
||||||
GlobalUnlock(lppd->hDevMode);
|
|
||||||
ret = S_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HeapFree(GetProcessHeap(), 0, pbuf);
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
||||||
HeapFree(GetProcessHeap(), 0, dbuf);
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
||||||
|
|
||||||
return ret;
|
return hr;
|
||||||
}
|
|
||||||
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -3982,10 +4039,11 @@ HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
|
HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
|
||||||
{
|
{
|
||||||
DWORD ret = E_FAIL;
|
PRINTER_INFO_2W *pbuf;
|
||||||
LPVOID ptr;
|
DRIVER_INFO_3W *dbuf;
|
||||||
|
DEVMODEW *dm;
|
||||||
FIXME("(%p) not fully implemented\n", lppd);
|
HRESULT hr = S_OK;
|
||||||
|
HANDLE hprn;
|
||||||
|
|
||||||
if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXW))) {
|
if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXW))) {
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
@ -4010,9 +4068,6 @@ HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lppd->Flags & PD_RETURNDEFAULT) {
|
if (lppd->Flags & PD_RETURNDEFAULT) {
|
||||||
PRINTER_INFO_2W *pbuf;
|
|
||||||
DRIVER_INFO_3W *dbuf;
|
|
||||||
HANDLE hprn;
|
|
||||||
|
|
||||||
if (lppd->hDevMode || lppd->hDevNames) {
|
if (lppd->hDevMode || lppd->hDevNames) {
|
||||||
WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
|
WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
|
||||||
|
@ -4040,28 +4095,27 @@ HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
|
||||||
ClosePrinter(hprn);
|
ClosePrinter(hprn);
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
dm = pbuf->pDevMode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FIXME("(%p) dialog not implemented\n", lppd);
|
||||||
|
return E_NOTIMPL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ClosePrinter(hprn);
|
ClosePrinter(hprn);
|
||||||
|
|
||||||
PRINTDLG_CreateDevNamesW(&(lppd->hDevNames),
|
PRINTDLG_CreateDevNamesW(&(lppd->hDevNames), dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName);
|
||||||
dbuf->pDriverPath,
|
if (!lppd->hDevNames)
|
||||||
pbuf->pPrinterName,
|
hr = E_FAIL;
|
||||||
pbuf->pPortName);
|
|
||||||
lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
|
lppd->hDevMode = update_devmode_handleW(lppd->hDevMode, dm);
|
||||||
pbuf->pDevMode->dmDriverExtra);
|
if (!lppd->hDevMode)
|
||||||
if (lppd->hDevMode) {
|
hr = E_FAIL;
|
||||||
ptr = GlobalLock(lppd->hDevMode);
|
|
||||||
if (ptr) {
|
|
||||||
memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
|
|
||||||
pbuf->pDevMode->dmDriverExtra);
|
|
||||||
GlobalUnlock(lppd->hDevMode);
|
|
||||||
ret = S_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HeapFree(GetProcessHeap(), 0, pbuf);
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
||||||
HeapFree(GetProcessHeap(), 0, dbuf);
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
||||||
|
|
||||||
return ret;
|
return hr;
|
||||||
}
|
|
||||||
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue