Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997



Application Security Testing: An Integral Part of DevOps

Printing From The RichText Control

The on-line documentation on using the RichText control to print tells how it is supposed to work. It does not mention two basic problems. First, the RichText control doesn't work with the common dialog hDC. Second, to skip the error generated when using the Printer object hDC, you must use On Error Resume Next. These code fragments show how to print properly from the RichText control:
 On error resume next
printer.print ""
richtext.selprint printer.hdc
This wrapper function uses both the CommonDialog control and the Printer object:
 Function FilePrintDlgProc(rprnDlg As _
	CommonDialog, rRTF As _
	RichTextBox) As Boolean
	On Local Error GoTo Error_Handler:
	With rprnDlg
		.CancelError = True
		.Flags = cdlPDReturnDC + cdlPDNoPageNums
		If rRTF.SelLength = 0 Then
			.Flags = .Flags + cdlPDAllPages
			.Flags = .Flags + cdlPDSelection
		End If
		On Local Error Resume Next
		Printer.Print ""
		rRTF.SelPrint Printer.hDC

		FilePrintDlgProc = True

		End With
		Exit Function
	If Err <> cdlCancel Then
		MsgBox "Error " & Err & "; " & Error
	End If

End Function
Steven Mitchell
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date