bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data ) { wxWindowsPrintNativeData *native_data = (wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData(); data.GetPrintData().ConvertToNative(); PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageDlg; // Shouldn't have been defined anywhere if (pd) 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) { GlobalFree(pd->hDevMode); pd->hDevMode = NULL; } pd->hDevMode = (HGLOBAL) native_data->GetDevMode(); native_data->SetDevMode( (void*) 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((void*) NULL); // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE)); pd->Flags = PSD_MARGINS|PSD_MINMARGINS; if ( data.GetDefaultMinMargins() ) pd->Flags |= PSD_DEFAULTMINMARGINS; if ( !data.GetEnableMargins() ) pd->Flags |= PSD_DISABLEMARGINS; if ( !data.GetEnableOrientation() ) pd->Flags |= PSD_DISABLEORIENTATION; if ( !data.GetEnablePaper() ) pd->Flags |= PSD_DISABLEPAPER; if ( !data.GetEnablePrinter() ) pd->Flags |= PSD_DISABLEPRINTER; if ( data.GetDefaultInfo() ) pd->Flags |= PSD_RETURNDEFAULT; if ( data.GetEnableHelp() ) pd->Flags |= PSD_SHOWHELP; // We want the units to be in hundredths of a millimetre pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; pd->lStructSize = sizeof( PAGESETUPDLG ); pd->hwndOwner=(HWND)NULL; // pd->hDevNames=(HWND)NULL; pd->hInstance=(HINSTANCE)NULL; // PAGESETUPDLG is in hundreds of a mm pd->ptPaperSize.x = data.GetPaperSize().x * 100; pd->ptPaperSize.y = data.GetPaperSize().y * 100; pd->rtMinMargin.left = data.GetMinMarginTopLeft().x * 100; pd->rtMinMargin.top = data.GetMinMarginTopLeft().y * 100; pd->rtMinMargin.right = data.GetMinMarginBottomRight().x * 100; pd->rtMinMargin.bottom = data.GetMinMarginBottomRight().y * 100; pd->rtMargin.left = data.GetMarginTopLeft().x * 100; pd->rtMargin.top = data.GetMarginTopLeft().y * 100; pd->rtMargin.right = data.GetMarginBottomRight().x * 100; pd->rtMargin.bottom = data.GetMarginBottomRight().y * 100; pd->lCustData = 0; pd->lpfnPageSetupHook = NULL; pd->lpfnPagePaintHook = NULL; 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; }
bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data ) { wxWindowsPrintNativeData *native_data = (wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData(); data.GetPrintData().ConvertToNative(); PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageDlg; // Shouldn't have been defined anywhere if (pd) return false; pd = new PAGESETUPDLG; m_pageDlg = (void *)pd; // We must not set hDevMode and hDevNames when using PSD_RETURNDEFAULT, // otherwise the call to PageSetupDlg() would fail. if ( data.GetDefaultInfo() ) { pd->hDevMode = NULL; pd->hDevNames = 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 = (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; if ( data.GetDefaultMinMargins() ) pd->Flags |= PSD_DEFAULTMINMARGINS; if ( !data.GetEnableMargins() ) pd->Flags |= PSD_DISABLEMARGINS; if ( !data.GetEnableOrientation() ) pd->Flags |= PSD_DISABLEORIENTATION; if ( !data.GetEnablePaper() ) pd->Flags |= PSD_DISABLEPAPER; if ( !data.GetEnablePrinter() ) pd->Flags |= PSD_DISABLEPRINTER; if ( data.GetDefaultInfo() ) pd->Flags |= PSD_RETURNDEFAULT; if ( data.GetEnableHelp() ) pd->Flags |= PSD_SHOWHELP; // We want the units to be in hundredths of a millimetre pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; pd->lStructSize = sizeof( PAGESETUPDLG ); pd->hwndOwner = NULL; pd->hInstance = NULL; // PAGESETUPDLG is in hundreds of a mm pd->ptPaperSize.x = data.GetPaperSize().x * 100; pd->ptPaperSize.y = data.GetPaperSize().y * 100; pd->rtMinMargin.left = data.GetMinMarginTopLeft().x * 100; pd->rtMinMargin.top = data.GetMinMarginTopLeft().y * 100; pd->rtMinMargin.right = data.GetMinMarginBottomRight().x * 100; pd->rtMinMargin.bottom = data.GetMinMarginBottomRight().y * 100; pd->rtMargin.left = data.GetMarginTopLeft().x * 100; pd->rtMargin.top = data.GetMarginTopLeft().y * 100; pd->rtMargin.right = data.GetMarginBottomRight().x * 100; pd->rtMargin.bottom = data.GetMarginBottomRight().y * 100; pd->lCustData = 0; pd->lpfnPageSetupHook = NULL; pd->lpfnPagePaintHook = NULL; pd->hPageSetupTemplate = NULL; pd->lpPageSetupTemplateName = NULL; return true; }