473,806 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Graphics.DrawSt ring method pops an exception 2nd time I PrintPrevi

Hi, I'm trully excited to use VB.NET's PrintDocument to make my printouts. On
them I draw strings, images and lines.

All perfect, if I invoke the Print or the PrintPreview one time per run.

At second time I onvoke print or preview, the DrawLine or DrawImage go well,
but the first DrawString the program tries to execute pops an exception:

************** Exception Text **************
System.Argument Exception: Invalid parameter used.
at System.Windows. Forms.PrintPrev iewControl.Calc ulatePageInfo()
at System.Windows. Forms.Control.I nvokeMarshaledC allbacks()
************** Loaded Assemblies **************
mscorlib
(and so on...)

I already checked the content of my DrawString instruction and all the
parameters at the second time have the same values, except the handle number
where objects were new.

Please note that the problem emerges at the second time I try to print or
printpreview, not at the second page of a multiple page printout.

Help please.
--
Joao Braganca

Nov 23 '05 #1
1 1991
Update:

I only have this problem if I use the DrawLine method. When I use the
DrawString and the DrawImage, there's no error at the second time I Print or
PrintPreview.

There's something wrong when I mix DrawString and DrawLine that causes
DrawString to fail the second time.
--
Joao Braganca

"Joao" wrote:
Hi, I'm trully excited to use VB.NET's PrintDocument to make my printouts. On
them I draw strings, images and lines.

All perfect, if I invoke the Print or the PrintPreview one time per run.

At second time I onvoke print or preview, the DrawLine or DrawImage go well,
but the first DrawString the program tries to execute pops an exception:

************** Exception Text **************
System.Argument Exception: Invalid parameter used.
at System.Windows. Forms.PrintPrev iewControl.Calc ulatePageInfo()
at System.Windows. Forms.Control.I nvokeMarshaledC allbacks()
************** Loaded Assemblies **************
mscorlib
(and so on...)

I already checked the content of my DrawString instruction and all the
parameters at the second time have the same values, except the handle number
where objects were new.

Please note that the problem emerges at the second time I try to print or
printpreview, not at the second page of a multiple page printout.

Help please.
--
Joao Braganca

Nov 23 '05 #2

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

Similar topics

1
1308
by: DrDevious | last post by:
Maybe I am doing something wrong but has anyone else here noticed a difference in the positioning of text between the Graphics.DrawString method and the Win32 GDI DrawText function? My text is getting shifted to the right by 3 pixels for some reason. Everything else matches. I am creating my fonts under C# .NET in a way that should produce the same results as I am getting under C++ with the Win32 GDI API:
0
1402
by: twostepted | last post by:
Hello, This is a bit of a long post (sorry) but here is the jist of it: I've developed a Windows forms User Control marquee (auto-scrolling text like a readerboard). I'm trying to optimize it so that it'll display very large strings with out comsuming so many resources. That is, as the size of the display string increases, the marquee uses additional CPU cycles. I've considered two possible solutions.
5
27169
by: Charles A. Lackman | last post by:
Hello, I have created a complete PrintDocument and need to create an image from it. How is this done? e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos))
2
8185
by: Kalvin | last post by:
I keep getting my string inside a black box with this code. I would like to make the background transparent. Any help on this will be appreciated very much. '**** BEGIN CODE **** Try Dim NewFont As New Font(fg.Font.FontFamily, 10, FontStyle.Regular) Dim g As Graphics
7
3041
by: Michael Galvin | last post by:
I am trying to use Python to send to the printer a calender filled with a mix of text and simple graphics. I want to draw on the printed page something like a table with 6 rows and 7 columns to represent a calendar. I want to place text precisely within those boxes on the printed page. I am using Python 2.4 on Windows XP I was in the past able to do this within Visual Basic using its printer object. Visual Basic's printer object uses...
7
2584
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be stupid or missing the point. I used DrawString( ) as a simple test but I cannot get it to work at all unless I handle my custom controls Paint event.
6
3247
by: Chris Dunaway | last post by:
The method for printing documents in .Net can be confusing, especially for newer users. I would like to create a way to simplify this process. My idea would be implemented using a PrintDocument (much like the current model), but my PrintDocument would have a Pages collection such that each time you need to have an additional page, you would just add another page to the collection and then use the page object for the actual drawing etc. ...
2
3341
by: drsmooth | last post by:
Hi, i have made several different things using a double buffer and a jframe before but never had this problem: if you look thrugh the code, you can see that i draw a whole bunch of stuff to the screen and sometimes, i get a frame or two of just blank jframe color public void draw() { BufferStrategy bf = this.getBufferStrategy(); Graphics2D g = null; if(scrollPos>lastCoveredPos) lastCoveredPos =...
10
3657
by: anuking | last post by:
Hi, I made a tool that compares the texts from 2 richtextboxes and then marks the characters that are different in red. An option needs me to overlap these 2 text data to show the exact difference. I used a picturebox which is contained in a panel and draw the characters in respective colors using Graphics class. Everything is working fine, but for some reason I need to click the button twice to be able to see something on picturebox....
0
9598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.