Click here to Skip to main content
15,908,842 members
Home / Discussions / C#
   

C#

 
QuestionBasic question. Pin
Taurian11013-Jan-06 8:34
Taurian11013-Jan-06 8:34 
AnswerRe: Basic question. Pin
User 665813-Jan-06 8:39
User 665813-Jan-06 8:39 
AnswerRe: Basic question. Pin
Dave Kreskowiak13-Jan-06 8:54
mveDave Kreskowiak13-Jan-06 8:54 
GeneralRe: Basic question. Pin
User 665813-Jan-06 8:58
User 665813-Jan-06 8:58 
GeneralRe: Basic question. Pin
Dave Kreskowiak13-Jan-06 9:52
mveDave Kreskowiak13-Jan-06 9:52 
AnswerRe: Basic question. Pin
Colin Angus Mackay13-Jan-06 9:19
Colin Angus Mackay13-Jan-06 9:19 
AnswerRe: Basic question. Pin
Robert Rohde14-Jan-06 21:53
Robert Rohde14-Jan-06 21:53 
Questionprinting problem Pin
melanieab13-Jan-06 8:03
melanieab13-Jan-06 8:03 
Hi,
When the print button is clicked, I save a snapshot of the screen to a bitmap file.
Graphics currentTab = this.CreateGraphics(); <br />
			Size s = this.Size;<br />
			Bitmap memoryImage = new Bitmap(s.Width - 10, s.Height - 36, currentTab);<br />
			Graphics memoryGraphics = Graphics.FromImage(memoryImage);<br />
			IntPtr dc1 = currentTab.GetHdc();<br />
			IntPtr dc2 = memoryGraphics.GetHdc();<br />
			BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 2, 2, 13369376);<br />
			CurrentPage = memoryImage;<br />
			currentTab.ReleaseHdc(dc1);<br />
			memoryGraphics.ReleaseHdc(dc2);<br />
			CurrentPage.Save("sCurrentPage.bmp",System.Drawing.Imaging.ImageFormat.Bmp);

Then I start to do the printing.
PrintDocument ppd = new PrintDocument(); <br />
    PageSetupDialog pg = new PageSetupDialog();<br />
    printDialog1.Document = ppd;<br />
    pg.Document = ppd;<br />
    pg.PageSettings.Landscape = true;<br />
    DialogResult result = printDialog1.ShowDialog();<br />
    if (result==DialogResult.OK)<br />
    {<br />
        ppd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintCurrentPage);<br />
        ppd.Print();        <br />
    }<br />
    ppd.Dispose();

The first time I print, everything works ok. But if I hit the button again, I get an error, and the current screen doesn't save. (An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll Additional information: A generic error occurred in GDI+.)
If I comment out the printing part, the current page saves just fine. I also commented out just the line ppd.Print();. The image saved fine and I didn't get any error messages. Any thoughts?
Cheers,
Mel
AnswerRe: printing problem Pin
DigitalKing14-Jan-06 17:51
DigitalKing14-Jan-06 17:51 
QuestionDelegate or pointer? Pin
BlackDice13-Jan-06 7:30
BlackDice13-Jan-06 7:30 
AnswerRe: Delegate or pointer? Pin
BlackDice13-Jan-06 11:38
BlackDice13-Jan-06 11:38 
QuestionVWD 2005 Pin
fmardani13-Jan-06 7:07
fmardani13-Jan-06 7:07 
AnswerRe: VWD 2005 Pin
minhpc_bk13-Jan-06 15:51
minhpc_bk13-Jan-06 15:51 
Questionworking with MSR device Pin
Manu_8113-Jan-06 6:43
Manu_8113-Jan-06 6:43 
Questionsqldatasource options greyed out Pin
fmardani13-Jan-06 6:29
fmardani13-Jan-06 6:29 
AnswerRe: sqldatasource options greyed out Pin
Dave Kreskowiak13-Jan-06 14:32
mveDave Kreskowiak13-Jan-06 14:32 
AnswerRe: sqldatasource options greyed out Pin
minhpc_bk13-Jan-06 15:48
minhpc_bk13-Jan-06 15:48 
Questiondeleting class objects Pin
Manu_8113-Jan-06 6:23
Manu_8113-Jan-06 6:23 
AnswerRe: deleting class objects Pin
Tom Larsen13-Jan-06 6:34
Tom Larsen13-Jan-06 6:34 
AnswerRe: deleting class objects Pin
Guffa13-Jan-06 6:39
Guffa13-Jan-06 6:39 
QuestionInclude C++ resources in C# code Pin
Erock12313-Jan-06 4:46
Erock12313-Jan-06 4:46 
Questioninserting image in form Pin
usmanali12313-Jan-06 3:53
usmanali12313-Jan-06 3:53 
AnswerRe: inserting image in form Pin
RizwanSharp13-Jan-06 9:45
RizwanSharp13-Jan-06 9:45 
AnswerRe: inserting image in form Pin
Koushik Biswas13-Jan-06 12:35
Koushik Biswas13-Jan-06 12:35 
QuestionEM_SETCHARFORMAT Question Pin
c#guy381113-Jan-06 3:47
c#guy381113-Jan-06 3:47 

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.