Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello,

I'm programming a program that opens a second window and directly prints it. I thought I could use the event Form_Load. But if i print the form at that stage it will become totaly black (I think because the form has not finished loading yet). So I need a trigger to print the page directly after it is loaded, and this trigger can not be user input.

Who can help me on calling my print function when the page is loaded?
Thanks,
pieterjann
Posted
Comments
[no name] 6-Aug-12 10:22am    
How about the form loaded event?
pieterjann 6-Aug-12 10:27am    
is there a form Load AND a form Loaded event? if so could you give me an example of the form Loaded? My printing function makes an image of the form and prints that. As the form is not completely loaded at the form Load event it returns a black page....
[no name] 6-Aug-12 10:44am    
Give you an example? Go through the events list in the designer and select it from the list.
__John_ 6-Aug-12 10:28am    
Could you call your Print function from the form that owns the one you want to print?

Otherwise I think you might need to overide OnPaint.
Sergey Alexandrovich Kryukov 6-Aug-12 12:13pm    
Makes no much sense to speculate before OP creates some code sample and show how to reproduce the problem. And I voted 1 for "Solution 1", which is pure evil.
--SA

1 solution

Final answer:
Add a timer and disable it after the tic.


Thread closed
 
Share this answer
 
Comments
__John_ 6-Aug-12 10:29am    
It might work but it stinks.
DaveyM69 6-Aug-12 10:42am    
This will work only if the form loads before the timer ticks which is not guaranteed - a poor solution in my opinion.
There are several events raised by the form itself that may suffice (such as Shown) that would be more appropriate.
Sergey Alexandrovich Kryukov 6-Aug-12 12:08pm    
Very, very bad idea. It does not solve anything; and it totally pointless. Using timers is generally bad, but here it does not have any reason at all. And if it apparently "solves" the problem, it could be even worse: the original problem is hidden, the reasons are not understood, and you would just close the way to understand it -- very nice. You got very deserved 1, but this is not a main thing here. I would like to help you with the advice: your approaches to solving the problems will get you into trouble. Don't do such things.
--SA
pieterjann 7-Aug-12 8:16am    
Ok so you say do not do this. I tried with the event Shown, but it is not activated :( I will search a bit more before I ask you guys to solve my problem :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900