MFC Printing Question
-
I am just testing something out, this doesn't throw an error however it also doesn't print anything, am I missing something?
void CPrintDlg::OnPrintMe()
{
// TODO: Add your control notification handler code here
CDC dc;
CPrintDialog dlg (false);
if(dlg.DoModal() == IDOK)
{dc.Attach(dlg.GetPrinterDC()); DOCINFO di; ::ZeroMemory(&di, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); di.lpszDocName = \_T("Budget Figures for the Current Fiscal Year"); dc.StartDoc(&di); dc.StartPage(); CString a; a = "Printing Test"; dc.TextOut(0, 0, a); dc.EndPage(); dc.DeleteDC(); }
}
Nick Parker
May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
-
I am just testing something out, this doesn't throw an error however it also doesn't print anything, am I missing something?
void CPrintDlg::OnPrintMe()
{
// TODO: Add your control notification handler code here
CDC dc;
CPrintDialog dlg (false);
if(dlg.DoModal() == IDOK)
{dc.Attach(dlg.GetPrinterDC()); DOCINFO di; ::ZeroMemory(&di, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); di.lpszDocName = \_T("Budget Figures for the Current Fiscal Year"); dc.StartDoc(&di); dc.StartPage(); CString a; a = "Printing Test"; dc.TextOut(0, 0, a); dc.EndPage(); dc.DeleteDC(); }
}
Nick Parker
May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
-
You forgot:
dc.EndDoc();
after
dc.EndPage();
that may help. - Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
Nitron wrote: that may help. Yep, thanks. BTW, any ideas as to why when I type
::ZeroMemory(....)
I don't get intellisense? Nick Parker
May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
-
Nitron wrote: that may help. Yep, thanks. BTW, any ideas as to why when I type
::ZeroMemory(....)
I don't get intellisense? Nick Parker
May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
Nick Parker wrote: when I type ::ZeroMemory(....) I don't get intellisense? I don't think it's in the global namespace. When I type "::" ZeroMemory isn't in the list. :confused: I usually dont use that function anyway, I just make sure to initialize all my variables. - Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
-
Nick Parker wrote: when I type ::ZeroMemory(....) I don't get intellisense? I don't think it's in the global namespace. When I type "::" ZeroMemory isn't in the list. :confused: I usually dont use that function anyway, I just make sure to initialize all my variables. - Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com
-
Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com
If I'm using an array, I'll init:
int d[4] = {0,1,2,3};
if it gets too big for static init, i'll use a vector. However, you may find an un-initialized array somewhere... :~ - Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
-
Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com
Ravi Bhavnani wrote: How do you initialize an array? Err, don't you mean a structure ? You could initialize like this : DOCINFO di = {0} ; :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
-
Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com
You can always use memset(...)
-
You can always use memset(...)
My point was you often need to programatically initialize data using
ZeroMemory()
(ormemset()
). /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com -
Ravi Bhavnani wrote: How do you initialize an array? Err, don't you mean a structure ? You could initialize like this : DOCINFO di = {0} ; :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
No, I meant an array. My point was
ZeroMemory()
comes in handy for initializing an array without having to loop through it. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com -
You can always use memset(...)
ZeroMemory is a macro to memset (&xpto,0,sizeof(xpto)) :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
-
No, I meant an array. My point was
ZeroMemory()
comes in handy for initializing an array without having to loop through it. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.comRavi Bhavnani wrote: My point was ZeroMemory() comes in handy for initializing an array without having to loop through it. Ah, ok , sorry for the post . :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech