How To Print Images That Fit To The Page Size Specified In Print Common Dialog?
i need some help in printing the whole image tat fit onto the paper size i specified in Print Common Dialog. I hav a PictureBox array & each PictureBox contains a smaller Picturebox inside. For example : Picture1(index) has a smaller Picture2(index) inside. There are vertical & horizontal scrollbars next to each Picture1(index).
i already hav the basic Print Common Dialog code below. Here's the problem -> I can print out the pictures displayed inside Picture2(index) but the printout will turn out truncated or just part of the whole picture when im printing to a 4R photo size for example and the image displayed in Picture2(index) is larger then the bounding Picture1(index) & i need to use the scrollbars to scroll and view the other portions of the image.
So how to modify the code below to print out the whole image tat fit nicely to the paper size i specified. Thanxs.
'--------------------------------------------------------------------- 'CODE '---------------------------------------------------------------------
CommonDialog1.CancelError = True On Error Resume Next
CommonDialog1.Action = 5 ' Start the Print Common Dialog
If (Err.Number = cdlCancel) Then Exit Sub 'when Cancel is pressed, exit subroutine
'Code to print the array here
For Pics = Picture2.LBound To Picture2.UBound If Picture2(Pics).Picture > 0 Then ' If the PictureBox is not empty Printer.PaintPicture Picture2(Pics).Picture, 0, 0 Printer.EndDoc End If Next
'---------------------------------------------------------------------
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Print Dialog & Page Size
Can the page size progerty be reteived from the
Print Dialog.
I can get Orientation, Copies, etc but there
doesn't seem to be a paper size property even
though you can set it by clicking Properties
when the Print Dialog is displayed.
Thanks in advance
SeanR
Common Dialog Print
Hey Guys,
I have searched, but couldn't find an answer.
I have made a program in VB that puts some info on a Excel sheet. If I press 'Print sheet' I can print this sheet on the default printer, but I want to be able to let the user pick a printer and print with that selected printer (only if the user wants to print on another printer than the default printer).
When I show the common dialog for the printer, I don't know how to link the 'Print' button on the common dialog to a certain command to print the active Excel sheet!
Can you help me with this?
Kind regards,
Arjan
Common Dialog Print
I'm using MS Common Dialog for the printer aspect. After I print once it remembers what printer I used and continues to print to it without showing me the dialog box. here's my code.
Code:
dlg.CancelError = True
On Error Resume Next
dlg.ShowPrinter
If Err = 32755 Then
Exit Sub
End If
Printer.Orientation = 1
newp.PrintForm
It continues to print to the same printer even if I close the program and restart it. Thanks!
Print Common Dialog
Hey guys, I'm just starting to learn how to use the common dialog print box. First, I open it with
Code:
Dialog1.ShowPrinter
but I don't understand how to tell if the user hits the print or cancel button on the dialog box. This is probably something simple, but I can't find it in the object browser or by searching. Thanks in advance!
Common Print Dialog
i have an option to print something
when you click on the print button the print dialog comes up, allowing you to choose the printer, what pages to print and how many copies etc.
if you click ok, it goes ahead and prints, the problem is, if you click cancel it prints anway
how do i take the response from the print dialog? so that i can print if the user clicks ok, and nothing happens if they click cancel
Common Print Dialog
Please help.
I am accessing the printer common dialog through api calls as i do not have the ocx installed and cannot install it (due to corporate red tape). however all is working fine, dialog box appears, selections are, made but when I return to the calling procedure and set the new printer name, that is accepted, when it then sets the number of copies the printer device name is reset to the windows default
Public Type DEVMODE_TYPE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public Function ShowPrinter(frmOwner As Form, Optional PrintFlags As Long) As DEVMODE_TYPE
newprintername = ShowPrinter(frm)
For Each objprinter In Printers
If UCase$(objprinter.DeviceName) = Left(newprintername.dmDeviceName, InStr(1, newprintername.dmDeviceName, Chr(0)) - 1) Then
Set Printer = objprinter 'at this point the printer is set
correctly
Printer.Copies = newprintername.dmCopies'when this line
executes the
printer is changed back to
the windows default
Printer.Duplex = newprintername.dmDuplex
Printer.Orientation = newprintername.dmOrientation
Printer.PaperSize = newprintername.dmPaperSize
Printer.PrintQuality = newprintername.dmPrintQuality
Printer.ColorMode = newprintername.dmColor
Printer.PaperBin = newprintername.dmDefaultSource
End If
Next
Print Common Dialog
Most of the code I have seen that shows the print common dialog via API then sets the Printer object to the DevMode type properties, seems to put a 32 character limit on the dmDeviceName. For example, on my machine I have a network printer installed named \SHENANDOAHEPSON Stylus COLOR 900 but the dmDeviceName returns it as \SHENANDOAHEPSON Stylus COLOR plus a vbNullChar. Is there anyway to get around this or should I just compare the first 32 characters of Printer.DeviceName with dmDeviceName and hope that none of my clients have two different printers that have the first 32 characters the same?
Thanks
BestCoder
Common Dialog: Print?
VB Code:
Private Sub cmdprint_Click()cdbprint.DialogTitle = "Select A Printer"cdbprint.ShowPrinterEnd Sub
i know i'm missing something but i don't know what. can someone finish that for me, i know its easy i just dunno what i'm doing.
Print Common Dialog?
Ok i asked every common dialog thingy, this is the last to go to implement in to a basic text program....
I know the first part:
VB Code:
Private Sub Print_Click()CommonDialog1.ShowPrinterEnd Sub
Now how do i get it to print the RichTextBox1.Text?
~$uper-$tar
Common Dialog For Print
I've managed to get the print dialog to display however i'm not sure what the code is to send the data to the actual printer. Can anyone help?
This is what I have so far:
Private Sub cmdPrint_Click()
Dim BeginPage, EndPage, NumCopies, Orientation, i
' Set Cancel to True.
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' Display the Print dialog box.
CommonDialog1.ShowPrinter
' Get user-selected values from the dialog box.
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
Orientation = CommonDialog1.Orientation
For i = 1 To NumCopies
' Put code here to send data to your printer.
Next
Exit Sub
ErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub
Common Dialog (Print)
<vbcode>
I am trying to fix a program that I did not write. I am not too familiar with Common Dialog but here is the code:
Private Sub cmdPrint_Click()
On Error Resume Next
Dim BeginPage, EndPage, NumCopies, Orientation, i
Dim ActiveForm, dlgCommonDialog
With dlgCommonDialog
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
If Err <> MSComDlg.cdlCancel Then
ActiveForm.rtfText.SelPrint .hDC
End If
End With
'Get user-selected values from the dialog box.
BeginPage = dlgCommonDialog.FromPage
EndPage = dlgCommonDialog.ToPage
NumCopies = dlgCommonDialog.Copies
Orientation = dlgCommonDialog.Orientation
' For i = 1 To NumCopies
'Put code here to send data to your printer.
Printer.Orientation = 1 'Portrait
dlgCommonDialog.Orientation = cdlPortrait
End Sub
The Common Dialog is included on another form, but print dialog does not "pop-up".
any advice?
</vbcode>
Print Dialog (common Dialog) Frustration
Hi,
I've read through quite a number of help topics on different forums trying to find an easy solution:
I'd like to achieve the following:
1) show a print setup dialog
2) When user wants to print, the printer object (default printer) would reflect all the changes that the user made in step 1 (that is, the choice of printer, page orientation, papersize etc.)
For step 1, I know that code
commondialog1.flags = cdlPDPrintSetup
commondialog1.showprinter
shows the print setup dialog, but how can you easily make use of the user selections? (through experiment I know that setting printer.trackdefault = true makes the printer object reflect at least on the choice of the printer, but not e.g. paper size, at least not consistently).
Thanks for any help,
Efunlake
MS Common Dialog Print Command
If I try to use the .showprint command more than once in a program, it wont work. I have to restart my program for me to be able to use it again. Any clues??
Code:
dlg.CancelError = True
On Error Resume Next
Printer.PrintQuality = 4
dlg.ShowPrinter
If Err = 32755 Then
Exit Sub
End If
Printer.Orientation = 1
newp.PrintForm
Common Dialog Print Problem
Hey folks,
I am having trouble showing out the print common dialog immediately after I show out a open dialog box.
The problem is whenever I use the common dialog object to show an Open Dialog box and after that I use the same common dialog object to show the Printer Dialog box, it refuses to pop up. Instead of doing that. It skips the Show Printer line and executes my printing codes. Weird ! Help ?
Thanks in advance...
Common Print Dialog Box Properties
I am using VB6 and Crystal Reports 8.5 with Windows 2000 operating system and decided to use the VB print dialog box.
When called, using “CommonDialog1.ShowPrinter”, the VB print box displays a three tabbed section print common dialog box: General, Layout, and Paper/Quality. Using the code between the “With CommonDialog1” and “end with” below, the following code enables the features that I want on the general section tab of the VB print dialog box:
With CommonDialog1
.Flags = cdlPDPageNums
.Min = 1
.Max = 999
.FromPage = 1
.ToPage = 999
End With
Question: What are the property variables for the other two tabbed sections of the print common dialog box and what system variables has to be updated (with the user settings) from the common dialog box?
For example, this statement gets a value from the common dialog print box:
orientation = commondialog.orientation
What does orientation (1 for portrait, 2 for landscape) update in VB6?
I appreciate anyone's help. Thanks.
Common Dialog Print Control, Etc.
I teach VB in High School and look like a fool today when I could not get form to print using Common Dialog Control. Have a rather large form which I need to print in landscape orientation. Current code:
Private Sub mnuPrintForm....
CommonDialog1.ShowPrinter
End Sub
The textbook offers no other info.
The only way I can print the form is to eliminate the commondialog control and just type in the PrintForm command, but still does not print landscape.
Thanks for any help.
Common Dialog Print Function
I've formated and writen a PCL print file from inside my program to the harddrive. Now i want to send it to a PCL printer on the network. (its done over windows network) \servernameprinter001 etc.
Can I in someway retrive the path to the printer using the Common dialog printer object? It would be so sweet if the user could select the Printer from the standard windows printer selector.
/Anders
How To Set Common (Print) Dialog Language?
How do you change the language displayed for the common dialog control (Print, Open, etc)? Is this even possible? I am amazed at how difficult its been to find any information on this!
My application is written in VB 6.0 and runs on Windows NT 4.0 SP5. The language the application runs in (via resource file) is based on the Locale chosen by the user. However, changing the Locale seems to have no impact on the text displayed on the Common Dialog control.
I am using the Microsoft Common Dialog Control 6.0 (SP3) - comdlg32.ocx
Any info would be greatly appreciated - Thanks!
Print Common Dialog Control Please Help
I need to figure out how to return the name of the printer
selected in the CommonDialog control for printers
cdSelectPrinter.ShowPrint
I don't even know if this is possible or not.
I know how to print and get a list of installed printers(thanks to Johnny101)
I just would like to know if the printer name selected in the CommonDialog Control can be returned.
If not can you force the CommonDialog Control to accept a printer name instead of listing all installed printers?
Any help is greatly appreciated!!!
Common Dialog Print Setup & Memory
HI, I have a program that is using the commondialog option of print setup but when my program is running and I select this option on a particular laptop an error message appears "Not enough memory for this operation". My program works on numerous computers and laptops and this particular laptop has 128ram and enough disc space. Has anyone any ideas?!
Thanks
Hazey Daze
Print Setup Common Dialog Question
Previously, we were keeping the PrinterDefault property of the CommonDialog control as True, which would set the windows default printer to the printer selected when using the Print Setup dialog.
However, in most applications, the default printer does not get changed when you use the Print Setup option.
The problem is, without the PrinterDefault property, the Printer object is still the default printer, and the printer the user selects in the Print Setup dialog is not retained, i.e. if you open it again, the printer is reset to the default printer.
I can't seem to find any help on existing forum sites, so does anyone have a clue how to be able to do the following?
1. Allow the user to select a printer using the Print Setup dialog (done).
2. Do not set the windows default printer to the selected printer (done).
*3. If they open up the Print Setup dialog, show the printer last selected.
*4. When they decide to hit the Print button, print to the printer last selected.
There must be a property or flag or something out there (or maybe even an api call?) that I am not seeing.
Thanks in advance,
-Keith
Common Dialog/PrintDialog API Print Range
All,
I have exhaustively searched this website as well as other to find how to activate the Current Page or the Pages radio options on either the commondialog control or the PrintDialog API. If anyone could point me in the right direction that would be helpful.
I have been setting the .Flags to cdlPDPageNums, in fact, I have tried all available flags in some combination. Maybe there is a trick to an And/or clause in the setting of the flag that I am just not getting correct.
Thanks in advance
How To Print Form Using Common Dialog Control ?
I am using a MDI parent form with a menu command to print form.
1. How do I use a Common Dialog Control to let users select options before print?
2. If the user opens more than one form and clicks print, how could it print the active one?
Any sample code will be very helpful. Thanks.
Common Dialog Box Question (save And Print)
heres a three parter...
1) is there a way to clear out the history for file name when using the save common dialog box control?
2) how do i print the contents of a rich text box when using print common dialog box...
the code i have Code:RichTextBox1.SelPrint Printer.hDC prints whatever is selected in the textbox and if nothing is selected, it prints out the whole thing...
but when the printer dialog box appears and you have something selected and you want to print the whole thing by picking all in 'page range' it still prints out what was selected.
3) is there a way to set the margins when printing using the common dialog box control?
when i print, the margins are very small
anyone know how to deal with these?
thanks!
primal
Print Page Size Help
i am using printer.print
how do i tell the computer i want to print to Legal size????
Printer.PaperSize
but what is the answer for legal?
Images Print Size In Crystal Report 8.5
Dear Sir,
Your suggestions really helpful for those who want to learn Crystal report. Good Job.
I have a problem.
I am using Crystal Report 8.5 (Crystal report viewer Control) with vb6.0.
I have to create a report, which arrange Images (*. Jpeg, *. Tiff) in a particular way so that they can use optimum space on A4 page.
The images are to be chosen by my client dynamically / at run Time.
I have completed the Job by using ‘AddPictureObject’. The Project is Executing Fine.
Now, the problem is comes with ‘Printing Size’ and ‘Actual Size.’
Currently my client is using Adobe Photoshop for arranging and printing the images.
Photoshop Print’s the images in ‘Print size’ (same when inserting image in Ms Word) not in ‘Actual size’ (Same as when open through Internet Explorer or Crystal report). Crystal report shows the image in ‘actual size’ not in ‘print size’.
What should I do to get the images in ‘Print Size’?
(If I am changing the Size of image then the image gets distorted. I can’t distort image, due to they are Jewelry images and need to be very clear.)
Thanks in advance.[B]
Print Existing Excel File Using Common Dialog
What I need is to click on my command button and open a common dialog box for printing. Then print a specific excel file I created. What code do I add to print my excel file.
Private Sub cmdPrint_Click()
Dim printDlg As PrinterDlg
Set printDlg = New PrinterDlg
printDlg.PrinterName = Printer.DeviceName
printDlg.DriverName = Printer.DriverName
printDlg.Port = Printer.Port
printDlg.PaperBin = Printer.PaperBin
Printer.TrackDefault = False
printDlg.CancelError = True
Dim NewPrinterName As String
Dim objPrinter As Printer
Dim strsetting As String
NewPrinterName = UCase$(printDlg.PrinterName)
On Error GoTo ErrorHandler
printDlg.ShowPrinter Me.hWnd
If Printer.DeviceName <> NewPrinterName Then
For Each objPrinter In Printers
If UCase$(objPrinter.DeviceName) = NewPrinterName Then
Set Printer = objPrinter
End If
Next
End If
Printer.Copies = printDlg.Copies
Printer.Orientation = printDlg.Orientation
Printer.ColorMode = printDlg.ColorMode
Printer.Duplex = printDlg.Duplex
Printer.PaperBin = printDlg.PaperBin
Printer.PaperSize = printDlg.PaperSize
Printer.PrintQuality = printDlg.PrintQuality
With Printer
Debug.Print .DeviceName
If .Orientation = 1 Then
strsetting = "Portrait. "
Else
strsetting = "Landscape. "
End If
Debug.Print "Copies = " & .Copies, "Orientation = " & _
strsetting
If .ColorMode = 1 Then
strsetting = "Black and White. "
Else
strsetting = "Color. "
End If
Debug.Print "ColorMode = " & strsetting
If .Duplex = 1 Then
strsetting = "None. "
ElseIf .Duplex = 2 Then
strsetting = "Horizontal/Long Edge. "
ElseIf .Duplex = 3 Then
strsetting = "Vertical/Short Edge. "
Else
strsetting = "Unknown. "
End If
End With
ErrorHandler:
If Err.Number = 32755 Then
Exit Sub
End If
Print A Rich Text File Without Common Dialog?
i was wondering if there was a way to print a .rtf (rich text file) without using the common dialog control, so that no dialog boxes come up.
i found some code that would print a .txt file, but it can't do rich text.
any ideas?
Printer Defauls Not Being Changed By Common Dialog Print Control
I am having a problem with printing. If I change the default settings of the printer, the changes I make in the common dialog print control are not being updated so my print job is sent with my new printing preferences. I have attached my code below. Any suggestions?
With cmd
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
End With
Printer.Font = "courier new"
Printer.FontSize = 10
Printer.Height = (1440 * 11)
Printer.CurrentX = 5300
Printer.CurrentY = 600
Printer.FontBold = True
Printer.Print Filename
Print Custom Page Size In Win 2000
I need to print continuous 5 1/2 inch forms on an OKIDATA 390 Plus and OKIDATA 393 Turbo printer from a VB application in Windows 2000. I got code from microsoft.com HOWTO Q282474 and incorporated it into my VB application so that it selects a custom size form before printing. Sometimes it works and sometimes it just doesn't seem to be using the form even though I have watched it select the form in the debugger. I haven't been able yet to isolate all the factors coming into play but while I am trying to do that, is there anyone who has worked with printing custom page sizes and knows some rules of thumb...or is there another way to print a 5 1/2 inch form?
Thanks a lot
Tina D
Print Dialog Box (Common Dialog Box)
Hi,
Does anyone know how to make the pages section of a print dialog box enabled. I'm referring to the print range frame. I know you can set the
flags property of the common dialog control, but setting this to &H2 which is what should make it become enabled does not do anything. Am I
overlooking something?
thanks
Common Dialog Print Control In VB6 Not Updating Defaults In Printer Driver
I want the user to be able to pick double sided printing and the choice to be able to staple the paper by selecting it in the vb runtime common dialog print control. All of the changes that are made at runtime are not being sent to the printer. Whether you pick to staple or not to staple the page after it prints works from wordpad and notepad but not from my applications. How can you make sure that all selections made in the dialog box is passed to the printer. VB does not support all of the options in the printer object that is in our options dialog of the Common Dialog Control. If anyone knows a way around using the common dialog and actually accessing the core dialog box for the printer, that would be an acceptable method for me also.
With cmd
.PrinterDefault = true
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
End With
Printer.Font = "courier new"
Printer.FontSize = 10
Printer.Height = (1440 * 11)
Printer.CurrentX = 5300
Printer.CurrentY = 600
Printer.FontBold = True
Printer.Print Filename
Datareport Print To Specific Printer Or Change Page Size
Sorry for fad English
i have a datareport thats print a ticket (1/4 A4) .
1.- im defined a specific papersize in the printer settings (control pannel) and seting it as default paper
2.- the ticket printing its OK
3.- i need to print too a day report into A4 paper...i receive "report width is larger than the paper width"
4.- im trying to set the papersize before print the dtareport (print.papersize = vbPRPSA4) (dont works)
5.- im trying to send print to another printer (copy) with A4 paper setting as default (dont works)
6.- im triying to show printer dialog to select the oter printer or change the paper settings (datareport.printreport true) (dont works)
PLEASE HELP ME !
** win 2K
** epson lx-300+
Problem With Print, Page Setup, And Print Preview In A Text Editor...
Yes, I have another question.
When I use these exact same functions (with WebBrowser.ExecWB in place of txtScrapbook.Text) in my web browser, it works perfectly. But when I use them in reference to a text box, it doesn't.
Can you tell me where the problem lies, or give me an alternative method? I have a common dialog box already for other functions, so feel free to make use of it if you need to. Thanks.
Code:Private Sub PageSetup_Click()
txtScrapbook.Text OLECMDID_PAGESETUP, OLECMDEXECOPT_DODEFAULT
'opens page setup dialog
End Sub
Private Sub Print_Click()
txtScrapbook.Text OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
'opens common dialog box prompting user to print current web page/parts of current web page
End Sub
Private Sub PrintPreview_Click()
txtScrapbook.Text OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT
'opens print preview dialog
End Sub
Print Picture Box (print A Form That Is Too Large For The Screen Or Page)
I got a picture box (Picture1), which contain several picture box'es, labels and
Flex Grid tables, -which I would like to print. Picture1 is quite high (higher than the screen). I found some code that i modified, but the printing only get the labels proper. The Flex Grids and picture box'es only show the border, and not the contents.
Code:Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4& ' Draw the window's client area.
Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows.
Private Const PRF_OWNED = &H20& ' Draw all owned windows.
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Print_Click()
Dim rv As Long
Me.ScaleMode = vbTwips ' default
With Picture2
.Top = Picture1.Top
.Left = Picture1.Left
.Width = Picture1.Width
.Height = Picture1.Height
End With
Me.Visible = True
DoEvents
Picture1.SetFocus
Picture2.AutoRedraw = True
rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Picture2.Picture = Picture2.Image
Picture2.AutoRedraw = False
Printer.Print ""
Printer.PaintPicture Picture2.Picture, 0, 0
Printer.EndDoc
End Sub
Edited by - Zigar on 11/27/2003 3:31:21 AM
Print Column Header On Each Print Out Page
I am trying to put the header of each column on each print out page.
Right now I have it only appearing on the first page of my printouts.
How do you do that in Excel 2003?
Cant Enable Print From And To Textboxes In Print Dialog Box
On Error GoTo GetOut:
CommonDialog1.CancelError = True
CommonDialog1.Flags = cdlPDPageNums
CommonDialog1.ShowPrinter
CommonDialog1.FromPage = 1
CommonDialog1.ToPage = 2
CommonDialog1.PrinterDefault = True
Printer.Print Text1
Printer.EndDoc
Exit Sub
GetOut:
Exit Sub
HELP Print Listview Print To Many Page
HI
I am using this to print Listview
When I print 1 page then it is ok but
if data from Listview go on 3 or 4 page then fyrst page is ok
efter fyrst page I only get 1 data on on each page
so this can be many page
Can somone help me what is wrong in this ??
Printer.Font = "Tahoma"
Printer.FontBold = True
Printer.FontUnderline = False
Printer.FontSize = 10
Printer.Print "Print from listview"
Printer.FontUnderline = False
Printer.Print vbNewLine
Printer.CurrentX = 1440
Printer.CurrentY = 1440
PrintListView lvwDataCopy
Printer.EndDoc
Private Sub PrintListView(lvw As ListView)
Const Margin = 60
Const COL_MARGIN = 240
Dim ymin As Single
Dim ymax As Single
Dim xmin As Single
Dim xmax As Single
Dim num_cols As Integer
Dim column_header As ColumnHeader
Dim list_item As ListItem
Dim i As Integer
Dim num_subitems As Integer
Dim col_wid() As Single
Dim X As Single
Dim y As Single
Dim line_hgt As Single
xmin = Printer.CurrentX
ymin = Printer.CurrentY
' ******************
' Get column widths.
num_cols = lvw.ColumnHeaders.Count
ReDim col_wid(1 To num_cols)
' Check the column headers.
For i = 1 To num_cols
col_wid(i) = _
Printer.TextWidth(lvw.ColumnHeaders(i).Text)
Next i
' Check the items.
num_subitems = num_cols - 1
For Each list_item In lvw.ListItems
' Check the item.
If col_wid(1) < Printer.TextWidth(list_item.Text) _
Then _
col_wid(1) = Printer.TextWidth(list_item.Text)
' Check the subitems.
For i = 1 To num_subitems
If col_wid(i + 1) < _
Printer.TextWidth(list_item.SubItems(i)) _
Then _
col_wid(i + 1) = _
Printer.TextWidth(list_item.SubItems(i))
Next i
Next list_item
' Add a column margin.
For i = 1 To num_cols
col_wid(i) = col_wid(i) + COL_MARGIN
Next i
' *************************
' Print the column headers.
Printer.CurrentY = ymin + Margin
Printer.CurrentX = xmin + Margin
X = xmin + Margin
For i = 1 To num_cols
Printer.CurrentX = X
Printer.Print FittedText( _
lvw.ColumnHeaders(i).Text, col_wid(i));
X = X + col_wid(i)
Next i
xmax = X + Margin
Printer.Print
line_hgt = Printer.TextHeight("X")
y = Printer.CurrentY + line_hgt / 2
Printer.Line (xmin, y)-(xmax, y)
y = y + line_hgt / 2
' Print the rows.
num_subitems = num_cols - 1
For Each list_item In lvw.ListItems
X = xmin + Margin
' Print the item.
Printer.CurrentX = X
Printer.CurrentY = y
Printer.Print FittedText( _
list_item.Text, col_wid(1));
X = X + col_wid(1)
' Print the subitems.
For i = 1 To num_subitems
Printer.CurrentX = X
Printer.Print FittedText( _
list_item.SubItems(i), col_wid(i + 1));
X = X + col_wid(i + 1)
Next i
y = y + line_hgt * 1.5
Next list_item
ymax = y
' Draw lines around it all.
Printer.Line (xmin, ymin)-(xmax, ymax), , B
X = xmin + Margin / 2
For i = 1 To num_cols - 1
X = X + col_wid(i)
Printer.Line (X, ymin)-(X, ymax)
Next i
End Sub
Print A Page Without My Print Button!!!
My question concern my web page:
How can i print an html page without it's print button.
I figure out how to hide the button when pressed(with layers)
but when it's finish printing or the user cancel,
how can i make the button visible,i know how but on
what event.
some1 have an idea??
Overriding Default &"Print Page 1&" Dialog Box
I'm using VB6 and Win2K. Here is the relevant part of my code:
VB Code:
Do While intNumCop > 0 frmINDICATOR.Show PctDone = icounter / imax icounter = icounter + 1 With frmINDICATOR .FrameProgress.Caption = Format(PctDone, "0%") .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10) End With DoEvents With ImgEdit1 .Image = "j:SS" .Display .PrintImage 1, 1, 2 End With intNumCop = intNumCop - 1Loop Unload frmINDICATOR
Both with statements work fine, but the ImgEdit1 pops up a "printing page 1" dialog box. How can I override this or otherwise hide it so that only my progress meter is visible? I tried VBA code of application.screenupdating = false, but that's not available in VB6.
I also tried Lockwindowupdate with no luck. If I put it around my progress bar it blocks that just fine, but if I put it around the PrintImage "with" statement, the "Printing page 1" dialog box still pops up.
RESOLVED - Can't Get Page Setup Dialog To Show Page Size Correctly
Hey guys and gals, I am hoping someone will have an idea on this one . . .
I am trying to show the page setup dialog and prepopulate the values of the page setup dialog before it is shown. All of the form pre-population seems to work except paper size. I can retrieve paper size just fine after the user clicks ok on the form, I just can't seem to set it before the form is populated.
I created a tiny test app to illustrate my problem.
VB Code:
' on a formOption Explicit Private Sub Command1_Click() With Printer' Height & Width; Printer object — the physical dimensions' of the paper set up for the printing device; not available' at design time. If set at run time, values in these properties' are used instead of the setting of the PaperSize property.' .Width = 14' .Height = 8.5 .PaperSize = vbPRPSLegal .Orientation = vbPRORLandscape End With ShowPageSetupDlg MeEnd Sub '********************************************************************' IN A MODULE! Option Explicit Const CCHDEVICENAME = 32Const CCHFORMNAME = 32Const GMEM_MOVEABLE = &H2Const GMEM_ZEROINIT = &H40Const DM_DUPLEX = &H1000&Const DM_ORIENTATION = &H1&Const PSD_MARGINS = &H2Const PSD_DISABLEPRINTER = &H20Const PSD_INTHOUSANDTHSOFINCHES As Long = &H4Const PSD_DISABLEPAPER As Long = &H200 Private Declare Function PageSetupDlg Lib "comdlg32.dll" _ Alias "PageSetupDlgA" (pPagesetupdlg As PageSetupDlg) As Long Private Declare Sub CopyMemory Lib "kernel32" _ Alias "RtlMoveMemory" _ (hpvDest As Any, _ hpvSource As Any, _ ByVal cbCopy As Long) Private Declare Function GlobalLock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32" _ (ByVal hMem As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32" _ (ByVal wFlags As Long, _ ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32" _ (ByVal hMem As Long) As Long Private Type POINTAPI x As Long Y As LongEnd TypePrivate Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Type PageSetupDlg lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long flags As Long ptPaperSize As POINTAPI rtMinMargin As RECT rtMargin As RECT hInstance As Long lCustData As Long lpfnPageSetupHook As Long lpfnPagePaintHook As Long lpPageSetupTemplateName As String hPageSetupTemplate As LongEnd TypePrivate Type DEVMODE_TYPE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTToption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As LongEnd Type Public Function ShowPageSetupDlg(frm As Form) As Boolean Dim DevMode As DEVMODE_TYPE Dim lpDevMode As Long Dim m_PSD As PageSetupDlg Dim bReturn As Integer On Error Resume Next 'Set the current orientation and duplex setting DevMode.dmDeviceName = Printer.DeviceName DevMode.dmFields = DM_ORIENTATION Or DM_DUPLEX' DevMode.dmPaperWidth = Printer.Width' DevMode.dmPaperLength = Printer.Height DevMode.dmOrientation = Printer.Orientation DevMode.dmPaperSize = Printer.PaperSize DevMode.dmDuplex = Printer.Duplex DevMode.dmSize = Len(DevMode) On Error GoTo 0 'Allocate memory for the initialization hDevMode structure 'and copy the settings gathered above into this memory m_PSD.hDevMode = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, Len(DevMode)) lpDevMode = GlobalLock(m_PSD.hDevMode) If lpDevMode > 0 Then CopyMemory ByVal lpDevMode, DevMode, Len(DevMode) bReturn = GlobalUnlock(m_PSD.hDevMode) End If With m_PSD .rtMargin.Top = 0.5 * 1000 .rtMargin.Bottom = 0.5 * 1000 .rtMargin.Left = 0.5 * 1000 .rtMargin.Right = 0.5 * 1000 .ptPaperSize.x = 14 * 1000 .ptPaperSize.Y = 8.5 * 1000 .lStructSize = Len(m_PSD) 'Set the structure size .hwndOwner = frm.hWnd 'Set the owner window .hInstance = App.hInstance 'Set the application instance .flags = PSD_MARGINS Or PSD_DISABLEPRINTER Or PSD_INTHOUSANDTHSOFINCHES End With 'Show the pagesetup dialog If PageSetupDlg(m_PSD) Then ShowPageSetupDlg = True' sngMarginTop = (m_PSD.rtMargin.Top) / 1000' sngMarginBottom = (m_PSD.rtMargin.Bottom) / 1000' sngMarginLeft = (m_PSD.rtMargin.Left) / 1000' sngMarginRight = (m_PSD.rtMargin.Right) / 1000' sngPageW = (m_PSD.ptPaperSize.x) / 1000' sngPageH = (m_PSD.ptPaperSize.Y) / 1000 ' Get DEVMODE structure from PRINTDLG lpDevMode = GlobalLock(m_PSD.hDevMode) CopyMemory DevMode, ByVal lpDevMode, Len(DevMode) Call GlobalUnlock(m_PSD.hDevMode) ' Set default printer properties On Error Resume Next If Not (Printer Is Nothing) Then Printer.Copies = DevMode.dmCopies Printer.Orientation = DevMode.dmOrientation Printer.PaperSize = DevMode.dmPaperSize' lPaperSize = DevMode.dmPaperSize Printer.PrintQuality = DevMode.dmPrintQuality End If On Error GoTo 0 End IfEnd Function
Thanks in advance for any insight!
Saving Images W/Common Dialog
:/
I'm trying to save a picture in a picturebox
Code:
Private Sub mnuSave_Click()
cdlDialog.Filter = "Images (*.jpg) | *.jpg"
cdlDialog.ShowSave ' show save dialog box..cm
SavePicture picImg.Picture, cdlDialog.FileName
End Sub
I'm getting error 380 "Invalid Property Value".
|