Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Printer.komande u vb6

[es] :: Visual Basic 6 :: Printer.komande u vb6

[ Pregleda: 2632 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Aleksandar Vasic
Web Administrator, Uspon d.o.o
Čačak

Član broj: 91692
Poruke: 1226
*.dynamic.sbb.co.yu.

Sajt: www.vasictech.net


+1 Profil

icon Printer.komande u vb619.09.2007. u 13:04 - pre 202 meseci
Pozdrav, da li ima neki tutorijal o stampanju u vb-u??
 
Odgovor na temu

rgdrajko
Beograd

Član broj: 117734
Poruke: 710
80.93.249.*



+3 Profil

icon Re: Printer.komande u vb619.09.2007. u 16:29 - pre 202 meseci
U VB6 postoji objekat printer preko koga se vrse sva stampanja. Znaci otkucaj printer, klikni misem na rec printer i pritisni taster F1 i dobices help u kome mozes videti :
Code:

Printer Object, Printers Collection

The Printer object enables you to communicate with a system printer (initially the default system printer).

The Printerscollection enables you to gather information about all the available printers on the system.

Syntax

Printer

Printers(index)

The index placeholder represents an integer with a range from 0 to Printers.Count-1.

Remarks

Usegraphics methods to draw text and graphics on the Printer object. Once the Printer object contains the output you want to print, you can use the EndDoc method to send the output directly to the default printer for the application.

You should check and possibly revise the layout of your forms if you print them. If you use the PrintForm method to print a form, for example, graphical images may be clipped at the bottom of the page and text carried over to the next page.

The Printers collection enables you to query the available printers so you can specify a default printer for your application. For example, you may want to find out which of the available printers uses a specific printer driver. The following code searches all available printers to locate the first printer with its page orientation set to Portrait, then sets it as the default printer:

Dim X As Printer
For Each X In Printers
   If X.Orientation = vbPRORPortrait Then
      ' Set printer as system default.
      Set Printer = X
      ' Stop looking for a printer.
      Exit For
   End If
Next

You designate one of the printers in the Printers collection as the default printer by using the Set statement. The preceding example designates the printer identified by the object variable X, the default printer for the application.

Note   If you use the Printers collection to specify a particular printer, as in Printers(3), you can only access properties on a read-only basis. To both read and write the properties of an individual printer, you must first make that printer the default printer for the application.

Prouci Properties(Svojstva) i Methods(Metode).

Inace na http://www.devarticles.com/c/a.../Printing-With-Visual-Basic/1/ imas primer:
Code:

Printing With Visual Basic - Printing with VB 
(Page 2 of 5 )

Unsurprisingly, Visual Basic provides us with the Printer and Printers objects, which are available at runtime to all VB apps. The Printers object gives us information about all the available printers installed on the system. The Printer object controls all the output to the active printer and retrieves information such as the printer name.

First of all, lets look at the basic steps involved in printing with VB. First off, we send all the data we want to print using the Print method. For example, if we wanted to print "Hello", we would call

Printer.Print "Hello"

Each time you call the Print method, your output will move to the next line. So,

Printer.Print "Hello" 

Printer.Print "Goodbye!"

would appear as

Hello 

Goodbye!

on paper.

If you want to output a new page, you simply call the NewPage method:

Printer.NewPage

Once you have finished outputting the data to the printer, you need to call the EndDoc method:

Printer.EndDoc

Windows will then spool your document to the printer.

Setting formatting options 

Using the Printer object further, you can also apply formatting to the text you output by setting the Font and its associated FontSize, FontBold, FontItalic, FontStrikeThru and FontUnderline properties. To change the font, simply change the FontName property. For example,

Printer.FontName = "Tahoma"

changes the font to Tahoma. To change the size, just call Printer.FontSize. Most of the other formatting options are just boolean (ie True or False), which makes it even easier to apply formatting. The code below gives a simple demonstration:

With Printer 

Printer.Print "Normal Line" 

.FontBold = True 

Printer.Print "Bold Line" 

.FontItalic = True 

Printer.Print "Bold and Italic Line" 

.FontBold = False 

.FontItalic = False 

Printer.Print "Second Normal Line" 

.EndDoc 

End With

Although I am using a With statement, I still have to write Printer.Print for outputting the text. This is another 'quirk' of VB - the Print statement does not actually belong to the Printer object, or in fact any other object in VB. If you search for Print in the Object Browser (press F2), you won't find it anywhere. Print is in fact a statement that VB interprets on its own, and outputs it according to the object before the Print statement. If you call PictureBox1.Print, it will 'print' the text into the PictureBox control. As such, the Print function behaves just as if it were an object of PictureBox or Printer. However, the designers of VB obviously didn't extend this behavior to With statements.

For a full list of font options, go to the Object Browser (F2), and select Printer from the Classes list.

One other thing worth noting regarding formatting... If you are using the RichTextBox control, you don't need to worry about applying all the formatting - there is some code using API calls which does it all for you, including page margins! Click here to see that code.

Setting the alignment of text isn't quite so simple because VB doesn't provide an align property. Instead, we need to work out where the middle of the page is and then take into account the width of the text. Take a look at this code, which prints the page number in the middle of the page:

sMsg = "Page " & Printer.Page ' Print Page number 

HWidth = Printer.TextWidth(sMsg) / 2 ' Get one-half width. 

HHeight = Printer.TextHeight(sMsg) /2 ' Get one-half height. 

Printer.CurrentX = Printer.ScaleWidth / 2 - HWidth 

Printer.CurrentY = Printer.ScaleHeight / 2 - HHeight 

Printer.Print sMsg

This code uses the CurrentX and CurrentY variables to change the position of where the text is outputted, centers the position, and prints the page number using the Printer's Page property. If you want the text in the middle at the top of the page, simply comment out the Printer.CurrentY line.


Prouci malo ovo i bice ti sve jasno u vezi stampanja iz VB.
rgdrajko
 
Odgovor na temu

Aleksandar Vasic
Web Administrator, Uspon d.o.o
Čačak

Član broj: 91692
Poruke: 1226
*.dynamic.sbb.co.yu.

Sajt: www.vasictech.net


+1 Profil

icon Re: Printer.komande u vb619.09.2007. u 16:41 - pre 202 meseci
Hvala!
 
Odgovor na temu

[es] :: Visual Basic 6 :: Printer.komande u vb6

[ Pregleda: 2632 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.