Objective Grid: Using CGXPrintDevice with scroll views

Article ID: 406
Last updated: 27 Apr, 2018
Article ID: 406
Last updated: 27 Apr, 2018
Revision: 3
Views: 1828
Posted: 09 Jan, 2001
by Meltreger B.
Updated: 27 Apr, 2018
by Meltreger B.

Problem

 


How can I use CGXPrintDevice with scroll views or other views not derived from CGXView?

 

 


Cause

 


 

 


Action

 


You have to copy the following declarations and their implementations from GXView.cpp/.h to your CScrollView-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;

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 406
Last updated: 27 Apr, 2018
Revision: 3
Views: 1828
Posted: 09 Jan, 2001 by Meltreger B.
Updated: 27 Apr, 2018 by Meltreger B.

Others in this category