How can I use CGXPrintDevice with scroll views or other views not derived from CGXView?
You have to copy the following declarations and their implementations from GXView.cpp/.h to your CSrollView-derived class:
// Attributes
public:
BOOL m_bOwnPD;
CGXPrintDevice* m_pPD;
// Printer Settings
public:
CGXPrintDevice* GetPrintDevice();
void SetPrintDevice(CGXPrintDevice* pPD, BOOL bMustDelete = TRUE);
// Printing support
public:
virtual void OnModifiedPrintDevice();
int DoPrintDialog(CPrintDialog* pPD);
BOOL DoPreparePrinting(CPrintInfo* pInfo);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
void UpdatePrinterDevice(CGXPrintDevice* pd);
Next, you can initialize the settings in your OnInitialUpdate routine with
if (GetPrintDevice() == NULL:)
{
CGXPrintDevice* pDevice = new CGXPrintDevice( );
SetPrintDevice(pDevice);
// Ensure that device info is existent
pDevice->NeedDeviceHandles( );
// Now, you can get the device info
LPDEVNAMES pDevNames;
DWORD cbSizeDevNames;
LPDEVMODE pDevMode;
DWORD cbSizeDevMode;
pd->GetDeviceInfo(pDevNames, cbSizeDevNames, pDevMode, cbSizeDevMode);
// Now, you can change this structure
// as documented in the Win31 SDK
// and later call CreateDeviceHandles to apply the changes.
pd->CreateDeviceHandles(pDevNames, cbSizeDevNames, pDevMode,
cbSizeDevMode);
delete pDevMode;
delete pDevNames;
}