Click here to Skip to main content
15,890,282 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Preprocessor Directive Pin
Andrew Brock31-Jan-11 23:46
Andrew Brock31-Jan-11 23:46 
GeneralRe: Preprocessor Directive Pin
Stefan_Lang31-Jan-11 23:55
Stefan_Lang31-Jan-11 23:55 
GeneralRe: Preprocessor Directive Pin
Andrew Brock31-Jan-11 23:57
Andrew Brock31-Jan-11 23:57 
GeneralRe: Preprocessor Directive Pin
Niklas L1-Feb-11 1:50
Niklas L1-Feb-11 1:50 
GeneralRe: Preprocessor Directive Pin
Niklas L1-Feb-11 1:41
Niklas L1-Feb-11 1:41 
GeneralRe: Preprocessor Directive Pin
Stefan_Lang1-Feb-11 0:11
Stefan_Lang1-Feb-11 0:11 
AnswerRe: Preprocessor Directive Pin
Malli_S31-Jan-11 21:10
Malli_S31-Jan-11 21:10 
QuestionMFC - Printing - Changing page orientation from a custom pagesetup dialog [SOLVED] Pin
Un Suthee31-Jan-11 15:11
Un Suthee31-Jan-11 15:11 
Hi there,

I am developing a custom print dialog and page setup for my Win32 program. Since the code is legacy, I can't take much advantage from MFC view/doc architecture. As a result, I wrote a printing code completely from scratch.

I setup CPrintInfo, instantiate my custom print dialog box and hook this dialog box to the CPrintInfo I just created. When my custom print dialog is up, I have a radio button to let a user toggles the page orientation. For some reasons, I couldn't modify the current DEVMODE at the run-time. As a result, every page I print will end up as a portrait.


<b>Here is the code I have:</b>
void PrintSomething(CWnd* currentWnd)
{
// Create CPrintInfo
CPrintInfo* pPrintInfo = new CPrintInfo;
SetupPrintInfo(pPrintInfo); // simply setup some member variables of CPrintInfo

// Create a custom print dialog and use this dialog box during instead of the default CPrintDialog
CustomPrintDlg* pCustomPrtDlg = new CustomPrintDlg(FALSE, PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS
| PD_HIDEPRINTTOFILE | PD_NOSELECTION, pPrintInfo, currentWnd);
SetupPrintDialog(pPrintInfo,pCustomPrtDlg);

if ( AfxGetApp()->DoPrintDialog(pCustomPrtDlg) == IDOK ) {
... // proceed a print loop
}
}

void SetupPrintDialog(CPrintInfo* pPrintInfo,CustomPrintDlg* pCustomPrtDlg)
{
delete pInfo->m_pPD;
pInfo->m_pPD = pCustomPrtDlg;

pInfo->m_pPD->m_pd.hInstance = AfxGetInstanceHandle();
pInfo->m_pPD->m_pd.lpPrintTemplateName = MAKEINTRESOURCE(IDD_CUSTOM_PRTDLG);

// Set the Flags of the PRINTDLG structure as shown, else the
// changes will have no effect.
pInfo>m_pPD->m_pd.Flags |= PD_ENABLEPRINTTEMPLATE;

// Set the page range.
pInfo>m_pPD->m_pd.nMinPage = 1; // one based page numbers.
pInfo>m_pPD->m_pd.nMaxPage = 0xffff; // how many pages is unknown.
}

When a user toggles the radio button to Landscape, this function will be invoked:
void CustomPrintDlg::OnLandscapeChecked()
{
// set the current Devmode to landscape
LPDEVMODE pDevMode = GetDevMode();
GlobalUnlock(pDevMode);
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
}

class CustomPrintDlg: public CPrintDialog {

... // just override some methods from CPrintDialog
};


Even if I manually set pDevMode->dmOrientation to DMORIENT_LANDSCAPE when the dialog is up, the printing result is still ended up in Portrait. I am really not sure why this is happening. Please help.

Thank you in advance for any help.
Un

Un


-- Modified Thursday, February 3, 2011 10:30 PM
AnswerRe: MFC - Printing - Changing page orientation from a custom pagesetup dialog Pin
Roger Allen2-Feb-11 5:46
Roger Allen2-Feb-11 5:46 
GeneralRe: MFC - Printing - Changing page orientation from a custom pagesetup dialog Pin
Un Suthee3-Feb-11 16:30
Un Suthee3-Feb-11 16:30 
Question2D dynamic wchar array Pin
csrss31-Jan-11 13:30
csrss31-Jan-11 13:30 
AnswerRe: 2D dynamic wchar array Pin
Andrew Brock31-Jan-11 16:41
Andrew Brock31-Jan-11 16:41 
GeneralRe: 2D dynamic wchar array Pin
csrss31-Jan-11 22:35
csrss31-Jan-11 22:35 
AnswerRe: 2D dynamic wchar array [DONE] Pin
csrss1-Feb-11 2:25
csrss1-Feb-11 2:25 
AnswerRe: 2D dynamic wchar array [modified] Pin
Emilio Garavaglia31-Jan-11 20:50
Emilio Garavaglia31-Jan-11 20:50 
GeneralRe: 2D dynamic wchar array Pin
csrss31-Jan-11 22:45
csrss31-Jan-11 22:45 
QuestionString array comparison Pin
jharn31-Jan-11 4:48
jharn31-Jan-11 4:48 
QuestionRe: String array comparison Pin
David Crow31-Jan-11 4:57
David Crow31-Jan-11 4:57 
AnswerRe: String array comparison Pin
jharn31-Jan-11 5:08
jharn31-Jan-11 5:08 
AnswerRe: String array comparison Pin
David Crow31-Jan-11 5:41
David Crow31-Jan-11 5:41 
GeneralRe: String array comparison Pin
jharn31-Jan-11 6:09
jharn31-Jan-11 6:09 
GeneralRe: String array comparison Pin
Matthew Barnett1-Feb-11 1:06
Matthew Barnett1-Feb-11 1:06 
AnswerRe: String array comparison Pin
jharn31-Jan-11 5:46
jharn31-Jan-11 5:46 
AnswerRe: String array comparison Pin
David Crow31-Jan-11 6:08
David Crow31-Jan-11 6:08 
GeneralRe: String array comparison Pin
jharn31-Jan-11 6:10
jharn31-Jan-11 6:10 

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.