Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VS Printer control

Posted on 1999-10-11
10
Medium Priority
?
2,421 Views
Last Modified: 2013-12-26
When using the VSPrinter control I can't manage to:

  - Centre header text yet have it aligned to the left.
  - Place a picture in the header part of the page.
  - Position a table horizontally.  I can vertically, but it is too far over to the right.
0
Comment
Question by:andcu
[X]
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
  • 3
  • 2
  • +1
10 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 2117328
How do you simultaneously have text centered and aligned to the left? These are mutually exclusive options.

M
0
 
LVL 18

Expert Comment

by:mdougan
ID: 2117513
Can you post a sample routine?
0
 

Author Comment

by:andcu
ID: 2118896
What I mean is have it in the middle of the page but left-justified.  Does that make more sense.  Like this:

                  Andrew
                  Experts-Exchange
                  USA

It currently looks more like this.


                       Andrew
                  Experts-Exchange
                        USA

Do you see what I mean now?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:mark2150
ID: 2119506
That's just INDENTING, not centering. Move the left margin or simply move over a fixed amount of space on each line.

M
0
 

Author Comment

by:andcu
ID: 2119636
mark2150.  Thanks.  I have managed to get in contact with other sources now in reference to my problem.  I have managed to come up with ways to acheive what I needed to.
0
 
LVL 18

Accepted Solution

by:
mdougan earned 800 total points
ID: 2119662
Here are a couple of samples that I got out of the VSView sample application to demonstrate the things that you are asking for:

This example prints a table in the middle of the page (indented).  The text in the first two columns is Left aligned, the text in the second two columns is centered (because of the ^ symbol in the format string).

    Dim f$, s$, tw, savx
    Dim sp%


  ' start the print preview job
  vsPrinter.Action = 3 ' StartDoc
  If vsPrinter.Error Then Beep: Exit Sub
  MousePointer = 11

  ' set default style
  vsPrinter.FontName = "Arial"
  vsPrinter.FontSize = 40
  vsPrinter.FontBold = False
  vsPrinter.FontItalic = False
  vsPrinter.TextAlign = 0  'Left
  vsPrinter.TableBorder = 7
  vsPrinter.PageBorder = 3
  vsPrinter.PenStyle = 0
  vsPrinter.BrushStyle = 0
  vsPrinter.PenWidth = 2
  vsPrinter.PenColor = 0
  vsPrinter.BrushColor = 0
  vsPrinter.TextColor = 0
  vsPrinter.Columns = 1

' Here you set the size of the columns and their alignment
    ' initialize
    f = "2000|1800|^1440|^2200;"
    tw = 2000 + 1800 + 1440 + 2200
    s = "Country|Capital|GNP|Comments"
   
    ' print page title
    vsPrinter.TextAlign = 1    'Center
    vsPrinter.FontSize = 40
    vsPrinter = ""
    vsPrinter = "Shading Tables"
    vsPrinter.FontSize = 18
    vsPrinter = ""
    vsPrinter = ""

    ' save row start position
    Select Case vsPrinter.TextAlign
      Case 0: vsPrinter.X1 = vsPrinter.CurrentX
      Case 1: vsPrinter.X1 = (vsPrinter.PageWidth - tw) / 2
      Case 2: vsPrinter.X1 = vsPrinter.PageWidth - tw - vsPrinter.MarginRight
    End Select
    savx = vsPrinter.X1
    vsPrinter.Y1 = vsPrinter.CurrentY
   
    ' print header just to measure row
    vsPrinter.FontBold = True
    vsPrinter.Table = f + s
   
    ' save row end position
    vsPrinter.X2 = vsPrinter.X1 + tw
    vsPrinter.Y2 = vsPrinter.CurrentY
   
    ' use saved positions to draw light shading
    vsPrinter.BrushStyle = 0
    vsPrinter.BrushColor = RGB(255, 255, 0)
    vsPrinter.PenColor = vsPrinter.BrushColor
    vsPrinter.Draw = 2 ' rectangle
    vsPrinter.PenColor = 0
     
     
    ' the shading erased the row, so let's go again
    vsPrinter.CurrentX = savx
    vsPrinter.CurrentY = vsPrinter.Y1
    vsPrinter.Table = f + s
     
    ' disable header coloring
    vsPrinter.TextColor = 0
   
    ' do the table body
    vsPrinter.FontBold = False
    s = f + "Argentina|Buenos Aires|50|Tango land;"
    s = s + "Brazil|Brasilia|150|Lambada, anyone?;"
    s = s + "Chile|Santiago|25|This has nothing to do with beans!;"
    vsPrinter.Table = s
   
' all done
  vsPrinter.Action = 6 'End Document
  MousePointer = 0

Here is a procedure that puts a graphic in the Header area:

    Dim s$, fmt$
 
  ' start the print preview job
  vsPrinter.Action = 3 ' StartDoc  

  If vsPrinter.Error Then Beep: Exit Sub
  MousePointer = 11

  ' set default style
  vsPrinter.FontName = "Arial"
  vsPrinter.FontSize = 40
  vsPrinter.FontBold = False
  vsPrinter.FontItalic = False
  vsPrinter.TextAlign = 0  'Left
  vsPrinter.TableBorder = 7
  vsPrinter.PageBorder = 3
  vsPrinter.PenStyle = 0
  vsPrinter.BrushStyle = 0
  vsPrinter.PenWidth = 2
  vsPrinter.PenColor = 0
  vsPrinter.BrushColor = 0
  vsPrinter.TextColor = 0
  vsPrinter.Columns = 1

    ' print page title
    vsPrinter = ""
    vsPrinter.CurrentX = 2500
    vsPrinter.TextColor = QBColor(1)
    vsPrinter = "Metafiles and Bitmaps"
    vsPrinter.TextColor = QBColor(0)
    vsPrinter.FontSize = 28
    vsPrinter = ""
    s = "You can now print and preview reports that "
    s = s + "include bitmaps and metafiles.  "
    s = s + "Automate desktop publishing with vsView!!!!"
    vsPrinter = s
    vsPrinter = ""

' Here is the key to positioning the graphics, give it the
' X and Y (and diminsions)
    ' print pictures, stretch and align anywhere on the page
    vsPrinter.X1 = 1000
    vsPrinter.Y1 = 1000
    vsPrinter.X2 = 2400
    vsPrinter.Y2 = 2400
    vsPrinter.Picture = Image3.Picture

    vsPrinter.X1 = vsPrinter.CurrentX
    vsPrinter.Y1 = vsPrinter.CurrentY
    vsPrinter.X2 = vsPrinter.PageWidth - vsPrinter.MarginRight
    vsPrinter.Y2 = vsPrinter.PageHeight - vsPrinter.MarginBottom
    vsPrinter.Picture = Image3.Picture

  ' all done
  vsPrinter.Action = 6 'End Document
  MousePointer = 0
     
0
 

Author Comment

by:andcu
ID: 2119706
Your answer is good.

Your answer does not (I don't think) allow the Picture to appear on subsequent pages i.e. only the first.  It wasn't quite the sort of standard that I needed.  It would have helped loads though
0
 
LVL 18

Expert Comment

by:mdougan
ID: 2119980
Thanks, glad you found your solution (even though from other sources).  I see now your difficulty in getting the picture to print in the header was not so much getting it to print there, but getting it to print there for every page.  

I don't know how you're formatting your report, if you're doing it one page at a time, or letting the VSPrinter break the pages.  However, if you are formatting each page of the report, then you can break the page by issuing the vsPrinter.NewPage command, and then you'd repeat the code for printing the graphic in the top of the page.

Otherwise, the printer control has a NewPage event, and you could put the code for printing the graphic in:

Private Sub vsPrinter_NewPage()

End Sub

Maybe Videosoft can recommend alternative ways.  They may have a FAQ or Message Board at www.VideoSoft.com
0
 

Author Comment

by:andcu
ID: 2120039
That is exactly what I did!!  Excellent.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6822144
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.

This is the Community Support link, if help is needed, along with the link to All Topics since many new ones were recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thanks,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

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.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 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