Don't set PAGESETUPDLG::hDevNames and hDevMode when using PSD_RETURNDEFAULT.
If the page setup dialog is used to retrieve the default information, hDevMode and hDevNames fields must not be set, otherwise PageSetupDlg() function simply fails because of incorrect parameters passed to it. Closes #13928. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70516 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
0e3b10c509
commit
fd76344ecc
@ -990,38 +990,34 @@ bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data )
|
||||
return false;
|
||||
|
||||
pd = new PAGESETUPDLG;
|
||||
pd->hDevMode = NULL;
|
||||
pd->hDevNames = NULL;
|
||||
m_pageDlg = (void *)pd;
|
||||
|
||||
// Pass the devmode data (created in m_printData.ConvertToNative)
|
||||
// to the PRINTDLG structure, since it'll
|
||||
// be needed when PrintDlg is called.
|
||||
|
||||
if (pd->hDevMode)
|
||||
// We must not set hDevMode and hDevNames when using PSD_RETURNDEFAULT,
|
||||
// otherwise the call to PageSetupDlg() would fail.
|
||||
if ( data.GetDefaultInfo() )
|
||||
{
|
||||
GlobalFree(pd->hDevMode);
|
||||
pd->hDevMode = NULL;
|
||||
}
|
||||
pd->hDevMode = (HGLOBAL) native_data->GetDevMode();
|
||||
native_data->SetDevMode(NULL);
|
||||
|
||||
// Shouldn't assert; we should be able to test Ok-ness at a higher level
|
||||
//wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
|
||||
|
||||
// Pass the devnames data (created in m_printData.ConvertToNative)
|
||||
// to the PRINTDLG structure, since it'll
|
||||
// be needed when PrintDlg is called.
|
||||
|
||||
if (pd->hDevNames)
|
||||
{
|
||||
GlobalFree(pd->hDevNames);
|
||||
pd->hDevNames = NULL;
|
||||
}
|
||||
pd->hDevNames = (HGLOBAL) native_data->GetDevNames();
|
||||
native_data->SetDevNames(NULL);
|
||||
else
|
||||
{
|
||||
// Pass the devmode data (created in m_printData.ConvertToNative)
|
||||
// to the PRINTDLG structure, since it'll
|
||||
// be needed when PrintDlg is called.
|
||||
|
||||
// pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
|
||||
pd->hDevMode = (HGLOBAL) native_data->GetDevMode();
|
||||
native_data->SetDevMode(NULL);
|
||||
|
||||
// Shouldn't assert; we should be able to test Ok-ness at a higher level
|
||||
//wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
|
||||
|
||||
// Pass the devnames data (created in m_printData.ConvertToNative)
|
||||
// to the PRINTDLG structure, since it'll
|
||||
// be needed when PrintDlg is called.
|
||||
|
||||
pd->hDevNames = (HGLOBAL) native_data->GetDevNames();
|
||||
native_data->SetDevNames(NULL);
|
||||
}
|
||||
|
||||
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
|
||||
|
||||
@ -1066,17 +1062,6 @@ bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data )
|
||||
pd->hPageSetupTemplate = NULL;
|
||||
pd->lpPageSetupTemplateName = NULL;
|
||||
|
||||
/*
|
||||
if ( pd->hDevMode )
|
||||
{
|
||||
DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
|
||||
memset(devMode, 0, sizeof(DEVMODE));
|
||||
devMode->dmSize = sizeof(DEVMODE);
|
||||
devMode->dmOrientation = m_orientation;
|
||||
devMode->dmFields = DM_ORIENTATION;
|
||||
GlobalUnlock(pd->hDevMode);
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user