Click here to Skip to main content
15,897,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Got it Pin
sashoalm13-Jan-09 3:25
sashoalm13-Jan-09 3:25 
GeneralRe: Got it Pin
TClarke13-Jan-09 3:39
TClarke13-Jan-09 3:39 
QuestionPlz Help to get solution Pin
vijith.squadz12-Jan-09 23:55
professionalvijith.squadz12-Jan-09 23:55 
AnswerRe: Plz Help to get solution Pin
CPallini13-Jan-09 0:16
mveCPallini13-Jan-09 0:16 
AnswerRe: Plz Help to get solution Pin
Rahul Vaishnav13-Jan-09 0:31
Rahul Vaishnav13-Jan-09 0:31 
GeneralRe: Plz Help to get solution Pin
vijith.squadz13-Jan-09 18:06
professionalvijith.squadz13-Jan-09 18:06 
QuestionPreview window closes when print button is clicked in print preview Pin
Member 447412812-Jan-09 23:30
Member 447412812-Jan-09 23:30 
AnswerRe: Preview window closes when print button is clicked in print preview Pin
Rajkumar R13-Jan-09 7:11
Rajkumar R13-Jan-09 7:11 
You may need to create custom preview class.

Have a look at [TN030: Customizing Printing and Print Preview^]

I tried some thing now, sorry i don't have easy solution,

create a new class CMyPreviewView derived from CPreviewView use #include <afxpriv.h> in stdafx.h
overide the Print command handler in the preview view,
BEGIN_MESSAGE_MAP(CMyPreviewView, CPreviewView)
	ON_COMMAND(AFX_ID_PREVIEW_PRINT, &CMyPreviewView::OnPreviewPrint) // this called when print button is pressed
END_MESSAGE_MAP()

so that you have the control of print button in CMyPreviewView::OnPreviewPrint and here you won't close the preview window
<small>void CMyPreviewView::OnPreviewPrint()
{
// assuming you want to print the view
	m_pOrigView->SendMessage(WM_COMMAND, ID_FILE_PRINT);
}</small>

make your custom preview class as Document preview class by calling DoPrintPreview,
<small>void CMyViewToBePrinted::OnFilePrintPreview()
{
	// In derived classes, implement special window handling here
	// Be sure to Unhook Frame Window close if hooked.

	// must not create this on the frame.  Must outlive this function
	CPrintPreviewState* pState = new CPrintPreviewState;

	TRY
	{
		// DoPrintPreview's return value does not necessarily indicate that
		// Print preview succeeded or failed, but rather what actions are necessary
		// at this point.  If DoPrintPreview returns TRUE, it means that
		// OnEndPrintPreview will be (or has already been) called and the
		// pState structure will be/has been deleted.
		// If DoPrintPreview returns FALSE, it means that OnEndPrintPreview
		// WILL NOT be called and that cleanup, including deleting pState
		// must be done here.

		if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
								RUNTIME_CLASS(CMyPreviewView), pState))
		{
			// In derived classes, reverse special window handling here for
			// Preview failure case

			TRACE(traceAppMsg, 0, "Error: DoPrintPreview failed.\n");
			AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
			delete pState;      // preview failed to initialize, delete State now
		}
	}
	CATCH_ALL(e)
	{
		delete pState;
		THROW_LAST();
	}
	END_CATCH_ALL
}</small>

modify the View message maps as,
<small>BEGIN_MESSAGE_MAP(CMyViewToBePrinted, CView)
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMyViewToBePrinted::OnFilePrintPreview)
END_MESSAGE_MAP()</small>

GeneralRe: Preview window closes when print button is clicked in print preview Pin
Member 447412828-Jan-09 3:31
Member 447412828-Jan-09 3:31 
GeneralRe: Preview window closes when print button is clicked in print preview Pin
Rajkumar R28-Jan-09 19:38
Rajkumar R28-Jan-09 19:38 
QuestionFont dialog Box problem Pin
trioum12-Jan-09 22:55
trioum12-Jan-09 22:55 
AnswerRe: Font dialog Box problem Pin
CPallini12-Jan-09 23:19
mveCPallini12-Jan-09 23:19 
QuestionUSB drive letter from WMI Pin
Subrat Patnaik12-Jan-09 22:21
Subrat Patnaik12-Jan-09 22:21 
AnswerRe: USB drive letter from WMI Pin
Leo Tiger2-Sep-09 9:12
Leo Tiger2-Sep-09 9:12 
Questionsaving 12 bits images Pin
alfalf312-Jan-09 22:04
alfalf312-Jan-09 22:04 
AnswerRe: saving 12 bits images Pin
CPallini12-Jan-09 23:14
mveCPallini12-Jan-09 23:14 
AnswerRe: saving 12 bits images Pin
«_Superman_»12-Jan-09 23:35
professional«_Superman_»12-Jan-09 23:35 
AnswerRe: saving 12 bits images Pin
alfalf313-Jan-09 4:15
alfalf313-Jan-09 4:15 
QuestionMulti language support in MBCS application Pin
Varghese Paul M12-Jan-09 21:06
Varghese Paul M12-Jan-09 21:06 
AnswerRe: Multi language support in MBCS application Pin
Jijo.Raj12-Jan-09 21:55
Jijo.Raj12-Jan-09 21:55 
AnswerRe: Multi language support in MBCS application Pin
«_Superman_»12-Jan-09 23:21
professional«_Superman_»12-Jan-09 23:21 
AnswerRe: Multi language support in MBCS application Pin
Randor 13-Jan-09 0:08
professional Randor 13-Jan-09 0:08 
QuestionBackGround color of Status Bar Pin
karhong12-Jan-09 19:27
karhong12-Jan-09 19:27 
AnswerRe: BackGround color of Status Bar [modified] Pin
karhong12-Jan-09 20:53
karhong12-Jan-09 20:53 
QuestionRe: BackGround color of Status Bar Pin
«_Superman_»12-Jan-09 23:11
professional«_Superman_»12-Jan-09 23:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.