Saving text printed (.print) on a form?

Posted on 2002-06-28
Medium Priority
Last Modified: 2010-05-02
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
Question by:lan_nur
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +2
LVL 18

Expert Comment

ID: 7117698
why don't you just use a textbox or a label?

Expert Comment

ID: 7117726
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


Author Comment

ID: 7118314
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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 7118450
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.


Expert Comment

ID: 7118457
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

Author Comment

ID: 7118859
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.

Expert Comment

ID: 7119169
 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.


Expert Comment

ID: 7119365
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:


Expert Comment

ID: 7120152
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)


Author Comment

ID: 7120543
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?

Accepted Solution

egsemsem earned 1050 total points
ID: 7120573
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.


Expert Comment

ID: 7120659
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

Author Comment

ID: 7122950
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question