Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Saving text printed (.print) on a form?

I made a program whose output is in another form, maximized and no bordered so it's full screen. The output is made using the form.print function using different forecolors for the form.
What I need to do is to be able to either:
 1. Print the text into a picture box which will hold it the way the form displayed the text, it will not crop it and will be able to be saved.
 2. find some other way to turn the colored text into an image which could be bigger than the screen resolution(not using autodraw)

If you need any additional details ask freely
thanks alot in advance
  • 4
  • 4
  • 2
  • +2
1 Solution
why don't you just use a textbox or a label?
If I'm understanding your problem...
What I do in that case is as follows...

Dim outputObj as Object
dim previewMode as boolean

' set previewMode as appropriate

'you may also like to set different scaleModes for each possible output context so that the display doesn't fall off the screen/page

if previewMode then
  set outputObj = myForm (thescreen object you are using)
  set outputObj = Printer  (or other target context)

' do my printing stuff

' finally
if outputObj = printer then outputobj.enddoc

lan_nurAuthor Commented:
What I meant was:
I have a form\picture box which I print into using the .Print method which prints simple text. All I want to do is to be able to handle this picture as if it was a regular picture, ie: To be able to print into it even if it's outside of the screen boundries.

Mccoop, your post would help if I were using a regular picture box without using .Point(x,y) to get pixel colors (which forces the picture to be in screen boundries) and without using the .Print method.
Is it possible to directly write to a graphic file?

Hope this helps.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

You can make a picturebox larger than the screen area - and I have certainly drawn into one like that (although not with the point() function).  I also used the print() function to draw to the picturebos...

Although I did have issues and had to manipulate the picturebox's .AutoRedraw property.

Does the point() function not work outside the screen dimensions... ?  (Never tried that)

You could do it with very short line() calls... (well it's not nice - but I haven't had problems with the line() function being persistent outside screen area)

But I still had to work with the .autoredraw setting.

My application has a scrolling picturebox - which can be many times the screen area, and I draw text, lines, and even place activeX controls into it.

These are all persistent when managed properly - although I agree that it is one of the areas most dependent on video cards and drivers.

Some machines don't handle it at all well (lines and text get forgotten when scrolling etc) , others require a reboot after the app is installed, while the majority work straight off.

Sorry - back to my earlier post...

It requires a substantial rewrite, but if you plan your scaling correctly, changing the target context does work - and allows you to 'see' what you're going to get (+/- 1 twip)

Then you can also manipulate the numbers if you want to print the form into into a single page, or tile across multiple sheets of paper to keep the sixe of objects etc
lan_nurAuthor Commented:
All the years I've been working with VB, I didn't quite get the scaling thing and Twips and making an application work on all resolutions. Can you maybe explain how to scale the picture? Perhaps that's the answer.
And how did you make the picture scroll? That may be the answer too.
 You may use a large hidden picture box with autoredraw property, so that you print the text in both of them. And when you want to save or print the text, you can use the hidden picturebox.
  In case this solution didn't satisfy you, could you tell us why you don't want to use autodraw? It will save a lot of time and effort.

To make a scrolling picturebox, you need to place one picturebox (your drawing target) inside another (the container.

If you use scrollbars, then these would also be placed in the container (a tthe bottoma nd right edges.

You need to place the target and scroll bars programmatically (.move) if the container is going to be resizable.

Once the positioning is done (assuming the target is larger than the container) - you need to develop a relationship between the scrollbars and the target-to-container width & height,

By moving the top and left values of the target, you effectively move the vviewport into the target window.

If the target-tocontainer relationship is not constant (i.e window sizes may be different) The scaling of the scrollbars is also a variable, thus you need to manage  the min & max values in realtime.

Ths sounds complicated - but is not really, and once you've done it - it all makes sense and is easy to manipulate.

Here is a KB article:;en-us;Q186429
i dont quete understand what you are trying to do
but try this:
start a new exe project
form1 is created
make form1 a mdi-child
make autoredraw true
give form1 a single line border
give form1 no control box and no caption
the code in form1:

Private Sub Form_Load()
    Me.Move 90, 90, Screen.Width * 5, Screen.Height * 5
End Sub

add an mdi form to the project

now run the project and you will have a scrollable form that's as wide as 5 times the screen and as height as 5 times the screen

with this form you can do anything you can do with a 'normal' form
even reading the pixel color of a pixel that is not visible

and if you dont want the autoredraw=true,just place all the graphics methods in the paint event(but then you wont be able to read a hidden pixel)

lan_nurAuthor Commented:
I never said I didn't want to use Autodraw, it helps me alot.
I'll try the MDI Child later, but what I need to do is save the picture that was printed over. Even with autodraw it doesn't save it with the text.
Anyone advice?
Do u use:
SavePicture Picture1.Image, "c:\tmp.bmp"
SavePicture Picture1.Picture, "c:\tmp.bmp"

the first one should save the picture with the text drawn over it.

i dont want to sound patronising, but why do you want to save an image of a form/picturebox,if at anytime you can recreate what you have done
if by chance it is to send that image to the printer, you are better of using the system mcoop gave you
that way it does not matter if you are printing to a form or picturebox or the printer, the output will be exactly the same
if you send the saved image of the form/picturebox to the printer the quality will be no good, it will be screen quality
if you use mcoop's method the printer output will be the best the printer can do
lan_nurAuthor Commented:
In the end egsemsem's post about the image/picture solved the saving problem and pierrecampe's solution with the mdi child solved the size matter.
so thanks.
I'll give the points to egsemsem and pierre, if u want ill post another question so u get points too.

mcoop, thanks ALOT for your help too!

Thank you all
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now