Printing a dialog box

My code opens some dialog boxes, with buttons and all the rest, and I draw 
some data of my own on the dialog.  I want to print the dialog exactly as it 
appears on the screen.  But because the dialog is not derived from CView or 
other class that knows how to print, there seems to be no provision for this 
function.

I have succeeded only by recreating the entire thing with a separate routine 
that is not itself a dialog.  There must be an easier way.  Does anyone know 
how?

I can make a bitmap copy of the screen and paste it into a graphics program, 
but that is a kludge.
0
Dilworth (1)
8/15/2007 3:08:02 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
757 Views

Similar Articles

[PageSpeed] 4

Check out the WM_PRINT message.

Here's an example (this code from a CDialog-derived class)...

//--------------------------------------------------------------------------------------------------
CWindowDC WindowDC(this);

CDC MemoryDC;
MemoryDC.CreateCompatibleDC(&WindowDC);

CRect WindowRect;
GetWindowRect(&WindowRect);

CBitmap WindowBitmap;
WindowBitmap.CreateCompatibleBitmap(&WindowDC, WindowRect.Width(), 
WindowRect.Height());

CBitmap *pOldBitmap = MemoryDC.SelectObject(&WindowBitmap);

SendMessage(WM_PRINT, (WPARAM)(HDC)MemoryDC, PRF_ERASEBKGND | PRF_CHILDREN | 
PRF_CLIENT | PRF_NONCLIENT);

//**test
BitBlt(WindowDC,100,100,WindowRect.Width(), WindowRect.Height(), MemoryDC, 
0, 0, SRCCOPY);
//**end test

MemoryDC.SelectObject(pOldBitmap);
//--------------------------------------------------------------------------------------------------

Of course, for printing you'd probably want to print the dialog to a printer 
DC

Mark

-- 
Mark Salsbery
Microsoft MVP - Visual C++


"Don Dilworth" <Don Dilworth@discussions.microsoft.com> wrote in message 
news:FF68FFD5-7817-42C5-9E3D-AEA10B844671@microsoft.com...
> My code opens some dialog boxes, with buttons and all the rest, and I draw
> some data of my own on the dialog.  I want to print the dialog exactly as 
> it
> appears on the screen.  But because the dialog is not derived from CView 
> or
> other class that knows how to print, there seems to be no provision for 
> this
> function.
>
> I have succeeded only by recreating the entire thing with a separate 
> routine
> that is not itself a dialog.  There must be an easier way.  Does anyone 
> know
> how?
>
> I can make a bitmap copy of the screen and paste it into a graphics 
> program,
> but that is a kludge. 


0
Mark
8/15/2007 4:22:48 PM
Alt-PrntScrn will copy the active window (PrntScrn by itself copies the 
entire desktop) so it can be pasted into a graphics or other program (Word, 
for instance) and included in documents or printed from there.  Would that do 
what you want?  

I use this all the time when preparing documentation.  Never needed to print 
a dialog from the app itself, though.  

Okie 

"Don Dilworth" wrote:

> My code opens some dialog boxes, with buttons and all the rest, and I draw 
> some data of my own on the dialog.  I want to print the dialog exactly as it 
> appears on the screen.  But because the dialog is not derived from CView or 
> other class that knows how to print, there seems to be no provision for this 
> function.
> 
> I have succeeded only by recreating the entire thing with a separate routine 
> that is not itself a dialog.  There must be an easier way.  Does anyone know 
> how?
> 
> I can make a bitmap copy of the screen and paste it into a graphics program, 
> but that is a kludge.
0
Okie (47)
8/15/2007 4:34:02 PM
Reply:

Similar Artilces:

New help with setting up printing
I am helping a friend with a 50th class reunion. I am uning a booklet style and have the middle two pages as a picutre, and a front and back cover. The pages in the middle will be class mates in alphibetical order. Not sure how to set up the pages between the cover and the center. Total of 12 pages with 1 being front 12 being back and 6 & 7 being the picture in the middle. I need to know where to start the bios on all the classmates to make them come out in order in the booklet. Thanks in advamce. What version Publisher? The catalog merge maybe your solution. Otherwise, you have 8 ...

Pass value to combo box
I have an unbound text box (txtSaveVal), an unbound combo box (cboName), and a string variable strSaveVal. me.txtSaveVal=strSaveVal .............. Works fine me.cboName=strSaveVal ............... Does Not Work I simply want to put the value of strSaveVal into the combo box, as though I had typed it in, BEFORE pressing the enter key. Why isn't this working? esee, Why are you doing this? A combo box is not intended to accept a value from another control, but provide a means to select a value from a list of values either from a table, a query, or a manually ...

Resizing controls in a dialog
Hi there, I build an application with different dialogs which can be resized by the user. When this happens, I use OnSize to give new dimensions and positions to the controls in the dialog. I measure the window and put the controls to a special ratio of the whole screen; snippet: GetClientRect(&crClientRect); // complete window ...... cx = (iBorderHor * 4); cy = iBorderHor; sx = crClientRect.Height() - (crObject2Rect.Height() * 6); sy = (crClientRect.Width() / 4) - (iBorderHor); m_BrowseTree.SetWindowPos(&wndTop, cy, cx, sy, sx, 0); .... This ...

printing error #2
unable to print an excel document received in an e-mail, then saved to disk. Other documents saved or received from e-mails print just fine. ...

Draw a themed combo box.
hi I am trying to make a combo box like control completely on my own by directly derving from CWnd. I have a control derived from CWnd. The OnPaint handler's code is given at the end of the post. What i am doing is that in the OnPaint I am drawing a edit control and then drawing a scroll button on the right hand side. In enabled state the control looks just fine but in disabled state, it does not look like the MFC themed combo box. Can someone help me get the disabled look? code snippet: CPaintDC dc(this); CRect totalRect; GetClientRect(totalRect); // dropdown button ...

Help with printing gridlines
I have a wksht where I can see the gridlines, and have selected a checkmark to print out with the gridlines. However, if I do a print preview or print, the gridlines are missing in the output. I must have turned something off accidentally. Bob "The Dog Breeders List" <rltutt@earthlink.net> wrote in news:BF14336F-FD99-4635-80EA-030D2DF242D7@microsoft.com: > I have a wksht where I can see the gridlines, and have selected a > checkmark to print out with the gridlines. However, if I do a print > preview or print, the gridlines are missing in the output. I must have >...

need help printing on a form
How do i print a list addresses that i have saved in excel on a form from like an address book. i dont know how to arrange the address name etc... manually before printing. --- Message posted from http://www.ExcelForum.com/ It may be easiest to print the list by using Microsoft Word's Mail Merge feature to pull the data from Excel. There's information on the Word MVPs' web site: http://www.mvps.org/word/FAQs/MailMerge/ help_needed wrote: > How do i print a list addresses that i have saved in excel on a form > from like an address book. i dont know how to arrange t...

check box notification
I used a combo box with the following code to catch the Selection change notification: ON_CONTROL_REFLECT_EX(CBN_SELCHANGE, OnSelChange) Now I am using a check box and using this same code to catch button click notification but it doesnt work: ON_CONTROL_REFLECT_EX(BN_CLICKED, OnClick) How can I capture the button click notification inside my derived checkbox class? Thanks. Jess How about this ON_BN_CLICKED(IDC_CHECKBOX1,OnClick) void CMyDlg::OnClick() { CheckBox Clicked } AliR. "Jessica Weiner" <jessica@gmail.com> wrote in message news:LjYTf.56658$H71.43735@n...

Printing Journal Receipts in HQ
Hi, I am trying to print journaled transaction receipts from HQ but each time the information on the left hand side is missing. E.G. Transaction would appear as 'nsaction'. The whole left hand side is missing. I have tried both A4 printers and an Epson TM88 windows printer but same result. If anyone has any ideas or solutions I would be grateful. Thanks. ...

can you edit a print shop file in publisher?
Is the print shop software compatible with MS Publisher. No, it is not compatible. You could export your printshop item as an image and insert that image into Publisher, but you will only be able to edit the image as an image, you won't be able to edit text, etc. -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com This posting is provided "AS IS" with no warranties, and confers no rights. "Tthomas" <Tthomas@discussions.microsoft.com> wrote in message news:96D872CD-E940-4891-86F9-23F0E21CC8F2@microsoft.com... > Is the print shop softwa...

Booklet printing in Word 2007
Tearing my hair out and wasting LOTS of paper and toner in trying to print a booklet. I do NOT have a duplex printer, but I cannot seem to get the settings right for this - the pages either don't print next to each other properly, or are upside down, or in the wrong order. Can anyone point me to a GOOD tutorial where I can see what I am not doing? Word is crap at booklet printing. Instead, save your document to PDF using Word 2007's built-in converter. Then open the document in Adobe Reader v9 and use its booklet feature. It is impressively good! It is the one saving ...

shelf label printing with rms avery 5160
This is a multi-part message in MIME format. ------=_NextPart_000_0046_01C8926E.1DECDFA0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit We are trying to print shelf labels with rms. When you choose avery 5160 it doesn't ask you for the row or column number. Since the sheet has 3 columns and 10 rows how do I tell it to print the label, lets say at row 3 column 2. I tried to create my own label by editing one of the every labels but it does the same thing. Any help would be appreciated. ------=_NextPart_000_0046_01C8926E.1DECDFA0 Content-Type...

Populate text boxes from a list box
Hi, I have a form with text and combo boxes where user enters data. After saving, a list box in another form is being populated, and all that works just fine. What i wanted to do next is to enable users to open one set of data from the list box (one row of data) in that form with text and combo boxes. I tried and tried but either i manage to open that form in add mode where all fields are blank, or i manage to open the form with data from the list box, but always positioned on the first data in the list box. I have been trying for a while so it could be possible that i am missing...

Option to shadow shapes & text boxes in Publisher 2003
MS Office help offers the following instructions referencing a SHADOW STYLE OPTION; THIS OPTION DOES NOT APPEAR ON MY DROP DOWN LIST OF OPTIONS!!! Select the picture, AutoShape, WordArt or text box that you want to change. On the Formatting toolbar, click Shadow Style , and do one of the following: Add or remove a shadow To add a shadow, click the shadow style you want. To remove a shadow, click No Shadow. Change the direction of the shadow To change the direction of a shadow, click a shadow that goes the direction you want. Change the distance of the shadow from...

Print only coloured rows of table
I am working on a table shown in the attachment as "Original table�. In this table if �Total Reqd� >0 then the Row of that particular item gets coloured by the CONDITIONAL FORMATTING formula. Is there any Formula / Macro in Excel by which when I print the original table I get only the coloured rows � As shown in �Required table after printing� Attachment filename: sample.xls Download attachment: http://www.excelforum.com/attachment.php?postid=557493 --- Message posted from http://www.ExcelForum.com/ Hi I would do this by using the same criteria as ...

Problem with box size and cutting words
I'm obviously having some settings related problem with Crystal Reports. After I deploy my application to client everything works like a charm except for one problem - on all reports text is cut and carried to next line at border line; like this: // Some text is comming near to text obj ect border and then is cut is this ma nner // Of course it should be done like this: // Some text is comming near to text object border and then is cut is this manner // Anyone having idea what is problem? on the field on the report right click and go to properties. On the common tab i...

How do I print email without the email subject header info?
I cannot find the right way to do this in the help files. I would like to print emails without having the default header that contains the username, from, sent, to, and subject fields. What version of Outlook are you using? Short answer is that you can't. Long answer is that you can but you have to copy/paste that text to Word (or similar app) and print from there. -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.htm "Loren" <Loren@discussions.microsoft.com> wrote in message news:A7D4EDFA-355...

Comment box
When I insert a comment, already inserted is "User:", is there a way t get rid of this so that the box is completely empty -- Message posted from http://www.ExcelForum.com Hi tghcogo! Tools > Options > General Delete the existing User Name, and type a new entry OK Be aware that this is an Office setting and will impact upon other Office programs. You might want to change it back before exiting Excel. -- Regards Norman Harker MVP (Excel) Sydney, Australia njharker@optusnet.com.au "tghcogo >" <<tghcogo.18puzz@excelforum-nospam.com> wrote in message ...

Printing document on a specific printer using shellExecute()
I want to print a document on a specific printr by giving its name and port using shellExecute() where to pass the argument?. pl help me Now i am using char *path = "c:\\Errlog.txt"; ShellExecute(NULL, "open", path, NULL, NULL, SW_NORMAL); ShellExecute(NULL, "print", path, NULL, NULL, SW_NORMAL); Thanks T.Appasamy I doubt you can unless the application with which the file extension is associated can take an arguement which can be used to specify the printer name. -- Vipin Aravind http://blogs.explorewindows.com "Appu" <a.t.appasamy@gm...

Error in query referring to Combo Box
I am very new to using VBA to build forms and am having a problem. I trying to embed a query within a public sub routine. The goal of this query is to use an alphanumeric code entered into a combo box on the form to retrieve an associated ID within a table. The bound column of the combo box is text. I have used the following code: Public Sub GetSturID(intSturID As Integer) Dim rsSturID As ADODB.Recordset Set rsSturID = New ADODB.Recordset rsSturID.Open "SELECT tblSturg.SturgID FROM tblSturg WHERE (tblSturg.PIT = '" & cmbPIT.Value & "')" _ &...

VBA causing Excel to max out 100% CPU when opening the Font Property dialog box
Hi, I'm trying to solve an issue that a client at work got with VBA in Excel 2003. The Client has a SS that got a few 'Combo Boxes' on it, if he select just 1 of the Boxes, anyone and tries to change the 'FONT PROPERTY' as soon as the ellipse ' 3 ... ' is clicked on XL then max's out the CPU sometimes talking 10 - 20 minutes before opening the 'FONT PROPERTY ' dialog box, or you can end the VBA task, this give error that it can't close XL, you OK this and then the 'FONT PROPERTY ' dialog box opens, once it finally open you can go on and ed...

Error (607) occured during action print
Dear Microsoft, I have a recent copy of Visio 2003 that was installed and working fine until last week. Then my HP DesignJet 1055CM printer that I access through a print server had the paper loaded incorrectly. Something else may have been wrong with it too - since it's paper selections changed and when I tried to print to it my ordinary xerox printer would end up being chosen no matter what I did. Suffice it to say the printer was messed up - but it also seems to have messed up something on my PC as well. Now - whenever I print with Visio to this printer I get the message Error (607)...

Links to external images and printing the images
I am in the very beginning stages of developing a database for someone in sort of an HR function in our organization. She needs to be able to keep track of various employment qualifications - certification dates, drivers license status, etc. The tricky request she has given me is that she wants to click on a button/record/somesuch for an employee, and have it bring up the appropriate scanned image, such as a scan of the drivers' license, and then print it. I was thinking of using the attachments feature in Access 2007 (which i will be developing in), but saw that the attachment total for t...

How do I get email listed in my in-box to display in red when flag
When I flag a message in Outlook 2007 at work, that email text color changes from black to red in my in-box list the the next day. I can do the same thing in my work email in-box in Outlook 2007 at home but not in my personal in-boxes. How do I set my home Outlook2007 to change the email color when flagged - like my work email does? I can't find that setting anywhere. It makes it a lot easier to see flagged messages. Thanks ... That means they are overdue. Which flag are you using at home? Set the quick click to use Today. -- Diane Poremsky [MVP - Outlook] Out...

I'm still having problems with my macros that need to toggle off a check box.
Someone gave me this macro: Private Sub CheckBox1_Click() Range("A1").Select 'Active Cell Select If CheckBox1.Value = True Then Selection.EntireRow.Hidden = True Else: CheckBox1.Value = False Selection.EntireRow.Hidden = False End If End Sub When I run it as is I get an error in the third line "If CheckBox1.Value = True Then" "Run time '424': Object required". I change the name of the check box back to from CheckBox1 but even when I changed it back I still get the same error message. What is the purpose of the "Range("A1").S...