Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using a database link in a C# program Pin
Heath Stewart6-Jan-04 21:11
protectorHeath Stewart6-Jan-04 21:11 
Questiondeveloping applications - MDI and SDI ? Pin
jeffreylreed28-Dec-03 21:27
jeffreylreed28-Dec-03 21:27 
AnswerRe: developing applications - MDI and SDI ? Pin
Heath Stewart29-Dec-03 5:03
protectorHeath Stewart29-Dec-03 5:03 
GeneralRe: developing applications - MDI and SDI ? Pin
jeffreylreed29-Dec-03 8:45
jeffreylreed29-Dec-03 8:45 
GeneralRe: developing applications - MDI and SDI ? Pin
Heath Stewart29-Dec-03 9:32
protectorHeath Stewart29-Dec-03 9:32 
GeneralPrintDocument PrintPage event Pin
Yaron K.28-Dec-03 20:36
Yaron K.28-Dec-03 20:36 
GeneralRe: PrintDocument PrintPage event Pin
Heath Stewart29-Dec-03 4:58
protectorHeath Stewart29-Dec-03 4:58 
GeneralRe: PrintDocument PrintPage event - a real answer Pin
Bryan White29-Dec-03 14:58
Bryan White29-Dec-03 14:58 
Do not presume to know the mind of someone asking an apparently stupid question. There is a school of thought that says that there are no stupid questions, only stupid answers.

I beg to differ about:
- there being no good reason to act differently.
- there being no good way to tell the difference.

Now, why would I want Print Preview to be different? Because my graphics lines @ 1200 dpi are TOO THIN to show even at 500% Zoom ! So I want to use thicker lines in print preview (and it's also quicker generating a page of bitmapped graphics @ 200dpi rather than 1200dpi).

I don't like flags. The idea of OO stuff is encapsulation.

Good News:
The PrintDocument passed as object sender to XX_PrintPage contains a member 'PrintController' which has a member 'underlyingController' which has a type of {System.Drawing.Printing.PreviewPrintController} or {System.Drawing.Printing.StandardPrintController}.

Bad News:
This is supposed to be hidden from you (thank you Bill and your people who can't think outside the square and mutter "Why would you do anything different").

Good News:
Use Reflection!
//using System.Reflection;
PrintDocument PD = sender as PrintDocument;
PrintControllerWithStatusDialog PC = PD.PrintController as PrintControllerWithStatusDialog;
FieldInfo FI = PC.GetType().GetField("underlyingController", BindingFlags.NonPublic | BindingFlags.Instance);
PreviewPrintController PPC = FI.GetValue(PC) as PreviewPrintController;

Now, if PPC is not null, it's PrintPreview.
If PPC is null, it's not PrintPreview.

Bad News:
It's ugly, brittle, hardly polymorphic, uses undocumented features of dotNet Framework and might stop working in a future release.
Maybe it's not a good way, but it's better than no way.

Good News:
It works for me, and I hope it does for you, too.


Regards

Brewman
GeneralRe: PrintDocument PrintPage event - a real answer Pin
Yaron K.29-Dec-03 19:57
Yaron K.29-Dec-03 19:57 
GeneralRe: PrintDocument PrintPage event - a real answer Pin
Heath Stewart30-Dec-03 3:24
protectorHeath Stewart30-Dec-03 3:24 
GeneralRe: PrintDocument PrintPage event - a real answer Pin
Bryan White4-Jan-04 9:47
Bryan White4-Jan-04 9:47 
GeneralRe: PrintDocument PrintPage event - a real answer Pin
Heath Stewart4-Jan-04 9:54
protectorHeath Stewart4-Jan-04 9:54 
GeneralUsing IActiveDesktop in C# Pin
Okeno Palmer28-Dec-03 19:01
Okeno Palmer28-Dec-03 19:01 
GeneralRe: Using IActiveDesktop in C# Pin
Heath Stewart29-Dec-03 4:48
protectorHeath Stewart29-Dec-03 4:48 
GeneralRe: Using IActiveDesktop in C# Pin
Okeno Palmer29-Dec-03 5:02
Okeno Palmer29-Dec-03 5:02 
GeneralRe: Using IActiveDesktop in C# Pin
Heath Stewart29-Dec-03 5:51
protectorHeath Stewart29-Dec-03 5:51 
GeneralRe: Using IActiveDesktop in C# Pin
Okeno Palmer29-Dec-03 11:12
Okeno Palmer29-Dec-03 11:12 
GeneralBuilding Office add-ins in C# Pin
Member 78647328-Dec-03 10:36
Member 78647328-Dec-03 10:36 
GeneralRe: Building Office add-ins in C# Pin
Michael P Butler28-Dec-03 11:36
Michael P Butler28-Dec-03 11:36 
GeneralRe: Building Office add-ins in C# Pin
Member 78647328-Dec-03 11:50
Member 78647328-Dec-03 11:50 
QuestionHow to kill Excel process properly? Pin
teagermylk28-Dec-03 10:31
teagermylk28-Dec-03 10:31 
QuestionWIN32 DrawText() .NET equivalent?? Pin
ShaneStump28-Dec-03 8:11
ShaneStump28-Dec-03 8:11 
AnswerRe: WIN32 DrawText() .NET equivalent?? Pin
Heath Stewart28-Dec-03 9:11
protectorHeath Stewart28-Dec-03 9:11 
GeneralRe: WIN32 DrawText() .NET equivalent?? Pin
ShaneStump28-Dec-03 10:48
ShaneStump28-Dec-03 10:48 
GeneralRe: WIN32 DrawText() .NET equivalent?? Pin
Nick Parker28-Dec-03 11:02
protectorNick Parker28-Dec-03 11:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.