472,371 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

Printing the Active MDI Child

In my MDI parent, I can do the following:

Form childForm = (Form)this.ActiveMdiChild;

I'd like to send the childForm in it's current state to the printer. Current
state being whatever text is currently in the textboxes on the form also
prints.

Thanks,

Randy
Nov 16 '05 #1
5 5297
Check this link

http://msdn.microsoft.com/library/de...us/cscon/html/
vclrfcodeprintpreviewingformvisualc.asp

--
Shak
(Houston)
"Randy" <rb***@sumaria.net> wrote in message
news:Bc******************@nwrdny02.gnilink.net...
In my MDI parent, I can do the following:

Form childForm = (Form)this.ActiveMdiChild;

I'd like to send the childForm in it's current state to the printer. Current state being whatever text is currently in the textboxes on the form also
prints.

Thanks,

Randy

Nov 16 '05 #2
Printing form

http://msdn.microsoft.com/library/de...us/cscon/html/
vclrfcodeprintpreviewingformvisualc.asp

--
Shak
(Houston)
"Randy" <rb***@sumaria.net> wrote in message
news:Bc******************@nwrdny02.gnilink.net...
In my MDI parent, I can do the following:

Form childForm = (Form)this.ActiveMdiChild;

I'd like to send the childForm in it's current state to the printer. Current state being whatever text is currently in the textboxes on the form also
prints.

Thanks,

Randy

Nov 16 '05 #3
Thanks for the response. I tried plugging that in as is, and the print
preview dialog comes up with "The document does not contain any pages." I
thought, "of course," and modified CaptureScreen() to use the
ActiveMdiChild, rather than "this". Still get "The document does not contain
any pages." Any thoughts? Again, I'm working in an Mdi parent, trying to
print the current mdi child form.

Randy

private void CaptureScreen()

{

Form form = (Form)this.ActiveMdiChild;

Console.WriteLine("Form name: {0}", form.Name);

Graphics mygraphics = form.CreateGraphics();

Size s = form.Size;

memoryImage = new Bitmap(s.Width, s.Height, mygraphics);

Graphics memoryGraphics = Graphics.FromImage(memoryImage);

IntPtr dc1 = mygraphics.GetHdc();

IntPtr dc2 = memoryGraphics.GetHdc();

BitBlt(dc2, 0, 0, form.ClientRectangle.Width, form.ClientRectangle.Height,
dc1, 0, 0, 13369376);

mygraphics.ReleaseHdc(dc1);

memoryGraphics.ReleaseHdc(dc2);

}


"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
Printing form

http://msdn.microsoft.com/library/de...us/cscon/html/ vclrfcodeprintpreviewingformvisualc.asp

--
Shak
(Houston)
"Randy" <rb***@sumaria.net> wrote in message
news:Bc******************@nwrdny02.gnilink.net...
In my MDI parent, I can do the following:

Form childForm = (Form)this.ActiveMdiChild;

I'd like to send the childForm in it's current state to the printer.

Current
state being whatever text is currently in the textboxes on the form also
prints.

Thanks,

Randy


Nov 16 '05 #4

Randy,

Try this,

Form pChildform = (Form)this.ActiveMdiChild;

if(pChildForm != null)
{
//access a method which will do the printing
pChildForm.DoPrintForm();
}

Keep a method called DoPrintForm inside the ChildForm and place ALL the
printing related code there as described by MSDN.

It shld print properly.

Shak.

--
Shak
(Houston)


"Randy" <rb***@sumaria.net> wrote in message
news:no******************@nwrdny01.gnilink.net...
Thanks for the response. I tried plugging that in as is, and the print
preview dialog comes up with "The document does not contain any pages." I
thought, "of course," and modified CaptureScreen() to use the
ActiveMdiChild, rather than "this". Still get "The document does not contain any pages." Any thoughts? Again, I'm working in an Mdi parent, trying to
print the current mdi child form.

Randy

private void CaptureScreen()

{

Form form = (Form)this.ActiveMdiChild;

Console.WriteLine("Form name: {0}", form.Name);

Graphics mygraphics = form.CreateGraphics();

Size s = form.Size;

memoryImage = new Bitmap(s.Width, s.Height, mygraphics);

Graphics memoryGraphics = Graphics.FromImage(memoryImage);

IntPtr dc1 = mygraphics.GetHdc();

IntPtr dc2 = memoryGraphics.GetHdc();

BitBlt(dc2, 0, 0, form.ClientRectangle.Width, form.ClientRectangle.Height,
dc1, 0, 0, 13369376);

mygraphics.ReleaseHdc(dc1);

memoryGraphics.ReleaseHdc(dc2);

}


"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
Printing form

http://msdn.microsoft.com/library/de...us/cscon/html/
vclrfcodeprintpreviewingformvisualc.asp

--
Shak
(Houston)
"Randy" <rb***@sumaria.net> wrote in message
news:Bc******************@nwrdny02.gnilink.net...
In my MDI parent, I can do the following:

Form childForm = (Form)this.ActiveMdiChild;

I'd like to send the childForm in it's current state to the printer.

Current
state being whatever text is currently in the textboxes on the form also prints.

Thanks,

Randy



Nov 16 '05 #5
Thanks.

Randy

"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...

Randy,

Try this,

Form pChildform = (Form)this.ActiveMdiChild;

if(pChildForm != null)
{
//access a method which will do the printing
pChildForm.DoPrintForm();
}

Keep a method called DoPrintForm inside the ChildForm and place ALL the
printing related code there as described by MSDN.

It shld print properly.

Shak.

--
Shak
(Houston)


"Randy" <rb***@sumaria.net> wrote in message
news:no******************@nwrdny01.gnilink.net...
Thanks for the response. I tried plugging that in as is, and the print
preview dialog comes up with "The document does not contain any pages." I
thought, "of course," and modified CaptureScreen() to use the
ActiveMdiChild, rather than "this". Still get "The document does not

contain
any pages." Any thoughts? Again, I'm working in an Mdi parent, trying to
print the current mdi child form.

Randy

private void CaptureScreen()

{

Form form = (Form)this.ActiveMdiChild;

Console.WriteLine("Form name: {0}", form.Name);

Graphics mygraphics = form.CreateGraphics();

Size s = form.Size;

memoryImage = new Bitmap(s.Width, s.Height, mygraphics);

Graphics memoryGraphics = Graphics.FromImage(memoryImage);

IntPtr dc1 = mygraphics.GetHdc();

IntPtr dc2 = memoryGraphics.GetHdc();

BitBlt(dc2, 0, 0, form.ClientRectangle.Width, form.ClientRectangle.Height, dc1, 0, 0, 13369376);

mygraphics.ReleaseHdc(dc1);

memoryGraphics.ReleaseHdc(dc2);

}


"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
Printing form

http://msdn.microsoft.com/library/de...us/cscon/html/
vclrfcodeprintpreviewingformvisualc.asp

--
Shak
(Houston)
"Randy" <rb***@sumaria.net> wrote in message
news:Bc******************@nwrdny02.gnilink.net...
> In my MDI parent, I can do the following:
>
> Form childForm = (Form)this.ActiveMdiChild;
>
> I'd like to send the childForm in it's current state to the printer.
Current
> state being whatever text is currently in the textboxes on the form also > prints.
>
> Thanks,
>
> Randy
>
>



Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Svennglenn | last post by:
How do i make a child window "active" like the root window? from Tkinter import * def open_child(): c = Toplevel(root) c.title("Child window") c.geometry('200x160+230+130') Label(c,...
1
by: alb120 | last post by:
I implementing Internet Printing; but it fails: http://w23ksv/printers/ gives error on EI Version 6.0.2800.1106 (XP) "Server object error 'ASP 0193 : 80020009' OnStartPage Failed...
6
by: Biguana | last post by:
Hi, Just wondering if anyone can help here. We have a site where most of the site opens in a window with no toolbars or menubar: window.open('mypage.aspx','self','toolbar=0, menubar=0, etc,...
3
by: Chrisitiaan | last post by:
Hi, I want to develop a 'truly' object oriented application, that is, my business logic objects handle the business logic (of course) and the persistence to a MS SQL server database. The user...
0
by: Morten Wennevik | last post by:
Given using a Parent and Child setup in MDI and overriding OnMdiChildActivate in the Parent, how come it seems to active the child I want active only every 2nd time? class Parent { private...
0
by: Frank_00001 | last post by:
I'm trying to use Active Directory to get a list of users that are in the same directory as the logon user. I'm trying to do this as a Web App written in C# using Windows Security and...
0
by: jpr | last post by:
Hello, I have a problem with my database and need some help. My database has a main menu named MENU which allows to access all the different forms of the program I am trying to develop. One of...
0
by: VMahaadevan | last post by:
Hi, I have MDI form in that I have 4 panels left panel has treeview control top panel has heading, version, label, Bottom panel has status bar for MDI and right side panel is work area where I...
1
by: ferguslogic | last post by:
Hello everyone, I have a C# winforms application which is designed as a mdi application. I am having a focus problem with it that I cannot seem to solve. If I open a mdi child and it is the...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.