Add your own alternative version
Stats
148.9K views 3.8K downloads 36 bookmarked
Posted
13 May 2003
|
Comments and Discussions
|
|
This capture and printing is working fine using the Foreground Window mode (which should include the Form's Title Bar and application menu bar).
However, on the 2nd or succeeding calls, the Form's Title Bar for the 1st call is always displayed for the 2nd and succeeding calls.
All of the content is correct, it is just the Title Bar that is incorrect.
Any ideas?
|
|
|
|
|
Sorry,
Because of the job market situation in the country i live i had to abandon programming since at least 10 years. I really apologize, but cannot help anymore.
Albert
|
|
|
|
|
|
We would like to use your code in a commercial product and would like your permission to do so. We request permission to make modifications to your code, make copies and create derivative works. We also request your permission to distribute to third parties, including US and Foreign governments.
Your reply is appreciated and thank you for creating useful software.
Kind regards.
|
|
|
|
|
Feel free to use the code the way you like, all permissions granted.
|
|
|
|
|
Feel free to use the code the way you like, all permissions granted.
(PS: The reply above is also from me, just logged with the wrong account.)
|
|
|
|
|
Great Job of course....May you help us again?...How to discard mouse movemment on CPrintDialog. This is cause Removemenu & another steps don´t work with your way...
|
|
|
|
|
I didn´t fully understand your request, sorry. Is it that you would like to have the mouse cursor at the position where it was before the printer dialog was called? Have i understood right?
Albert
|
|
|
|
|
Hi Albert,
...Sorry for...What I need from your CPrntScreen: 1st->Remove CPrintDialog "move" item menu, 2nd->Lock mouse for CPrintDialog screen movement when left click & move done.
Please, see:
http://www.codeguru.com/forum/archive/index.php/t-206643.html
Thanks in advance...
|
|
|
|
|
I was trying to test some part of the codes, but I faced this linking problem.
Problem:
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCD.lib(dbgdel.obj)
This problem surfaced when I add in CSize or CDC variables.
How am I supposed to solve this problem?
Thank for your attention.
|
|
|
|
|
Output:
Dumping objects ->
{161} client block at 0x00376EA0, subtype c0, 8 bytes long.
a CBitmap object at $00376EA0, 8 bytes long
Object dump complete.
The program '[4020] PrintDlg.exe: Native' has exited with code 0 (0x0).
I tried to fix that by using:
oldImage->DeleteObject();
but i guess that's not it
|
|
|
|
|
When I use this class in windows98,the printing is failure.
because the class use the function StretchDIBits to print screen,so I change the program
from
if ((iRasterCaps & RC_STRETCHBLT)==0)
to
if ((iRasterCaps & RC_STRETCHDIB)==0)
The class is very goood,thank you so much!!!
|
|
|
|
|
Hey, your work is surprisingly simple and correct...congratulations.
Although i haven't deep-scanned the code, i was wondering if thre's a simple way to print only the actual window so that fits the page...any hint?
Thanks,
Alberto.
|
|
|
|
|
Hi Alberto,
Thanks for the nice words.
To change the code to always to print "fit to page size" (proportional correct off course), you would need to change the stretching section of the code.
See arround line 375, there should be this code:
scrXY = (double)sizeScreen.cx/(double)sizeScreen.cy;
prnXY = (double)sizePrn.cx/(double)sizePrn.cy;
if (scrXY>prnXY)
{
zoomx = ((double)sizeClient.cx/(double)sizeScreen.cx);
zoomy = ((double)sizeClient.cy/(double)sizeScreen.cy)*(prnXY/scrXY);
}
else
{
zoomx = ((double)sizeClient.cx/(double)sizeScreen.cx)*(scrXY/prnXY);
zoomy = ((double)sizeClient.cy/(double)sizeScreen.cy);
}
Now change it to
scrXY = (double)sizeClient.cx/(double)sizeClient.cy;
prnXY = (double)sizePrn.cx/(double)sizePrn.cy;
if (scrXY>prnXY)
{
zoomx = (double)sizeClient.cx;
zoomy = ((double)sizeClient.cy) *(prnXY/scrXY);
}
else
{
zoomx = ((double)sizeClient.cx)*(scrXY/prnXY);
zoomy = (double)sizeClient.cy;
}
and you should get the 'fit to page' printing. For active window, use the 2nd example, like
#include "PrntScreen.h"
CPrntScreen * ScrCap;
ScrCap = new CPrntScreen();
ScrCap->DoPrntScreen(1,0,true);
delete ScrCap;
ScrCap = NULL;
And please do not forget to fix that error (memory leak) at line 294, as stated in the below posts!
To do so, change line 294 from
CBitmap *oldImage = new CBitmap,srcImage;
to
CBitmap *oldImage = new CBitmap;
CBitmap srcImage;
Havn't found time to update the article, will do so soon, thought.
Greetings,
Albert Hermann
-- modified at 13:19 Wednesday 11th January, 2006
|
|
|
|
|
Exactly what I was looking for! Excellent ---!
|
|
|
|
|
I downloaded, unzipped, included and tried, it run at once. Thanks a lot.
|
|
|
|
|
Hi, thank for a class.
Function void CPrntScreen::DoPrntScreen(int fArea, int fOrientation, bool bDialog)
Change
// CBitmap *oldImage = new CBitmap,srcImage;
To
CBitmap *oldImage;
CBitmap srcImage;
|
|
|
|
|
Ahh,
of course! What a st.... mistake.
Thanks very much, Saruth, will fix this soon.
Albert
|
|
|
|
|
Hello all
Say I have a program - for which I have no source code, and it prints a "report" in this case it is actually a Point-Of-Sale RECEIPT going to either a SERIAL or PARALLEL printer port
I want tyo TRAP, the print Job, before it gets to the port, re-package it (add some Logo, and header / footer lines) and then let go of it to the intended printer..
Can this be done? Any suggestions please (using MFC / C++)
Thanks
Alex
|
|
|
|
|
No, don't have no real idea, if this can be made in an easy way. Looks like you would have to programm a device driver to capture the parallel port or something like that.
Sorry that i can´t help.
Albert
|
|
|
|
|
Albert,
Thanks for you code. I have a dialog application that needs printing and your code is perfect for it. You have saved me a lot of time!!!
Cheers
Macca
|
|
|
|
|
I´m glad that the code helped.
Thanks,
Albert
|
|
|
|
|
I saw this article 15 minutes ago. Automatic screen dump to printer is now implemented in my project. Works like a charm. I haven't even read the code yet. Just plugged it in. Talk about useful article. Got an "Excellent" vote from me. The first to receive it in here
One suggestion though, for the sake of user feedback: Encapsulate the DoPrntScreen() call with BeginWaitCursor() and EndWaitCursor(), since the call takes a couple of seconds to return. Especially informative if you use just the default printer.
DP TO THE PEOPLE
|
|
|
|
|
Thanks for the nice comments. Nice to see, that the code helps others, like i was help by a lot of the code here at the Code Project.
Actually, my private version has BeginWaitCursor() and EndWaitCursor() implemented, but i didn´t think that others would like this. It´s really time to update the code and implement the suggestion made here
Albert
|
|
|
|
|
Hi Albert,
the class works fine!
I have a suggestion:
What about making the printer dialog modal?
I've done it this way:
;<br />
CPrintDialog pd(FALSE,PD_ALLPAGES,NULL);
All over the Code, this has to be changed:
;<br />
pd.GetPrinterDC();<br />
<br />
;<br />
pd.GetDevMode();
And this is the modal call:
if(pd.DoModal()==IDOK)
Best regards
Andreas
|
|
|
|
|
|
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
|