Print Page | Close Window

[QUESTION] PrintPreview Using BitBlt

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=17793
Printed Date: 16 May 2024 at 1:35pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [QUESTION] PrintPreview Using BitBlt
Posted By: Xander75
Subject: [QUESTION] PrintPreview Using BitBlt
Date Posted: 18 January 2011 at 9:20am
Hi,

I am currently designing an MDI application that displays a report that uses a Resizer Control to house a PictureBox control as a container for several controls, which include Labels, ReportControl and Barcodes.

As you can see from the attached screenshot Figure 1 (costs blanked for obvious reasons) I have this working as I wish. However a requirement I have is to Print, Print Preview and Export to PDF all of which I have managed to do using BitBlt to get a snapshot of the PictureBox Container.


Figure 1

If the program is on a laptop or screen with a smaller resolution the resizer control correctly shows the scrollbars, however then I have an issue with the Print, Print Preview and Export to PDF... see attached screenshot Figure 2. Although this is an issue, most users here have 19" Monitors therefore should never have this issue, but it would be good to resolve this.


Figure 2

Does anyone know of a way of Printing and Previewing a PictureBox container that contains several different type of controls? Due to the PictureBox being larger than the hidden area it is not painting the controls, instead this is painting what is on top of the hidden area of the PictureBox!

Any help would be appreciated. Also I would be willing to upload the code that does the Print, PrintPreview & Export to PDF if requested. Though I would need to code this into a Sample application, when I get some free time.

I have resolved this for both Printing and Exporting to PDF using the example code below however I need to see if I can get this to work with the Codejock PrintPreview control:


Private Declare Function SendMessage Lib "user32.dll" Alias _
   "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
   ByVal wParam As Long, ByVal lParam As Long) As Long

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
Private Const PRF_OWNED = &H20&    ' Draw all owned windows

Private Sub Command1_Click()
    Dim rv As Long
    Dim ar As Boolean

    With Picture1
        'Save ReDraw value
        ar = .AutoRedraw
 
        'Set persistance
        .AutoRedraw = True

        'Draw controls to picture box
        rv = SendMessage(.hwnd, WM_PAINT, .hDC, 0)
        rv = SendMessage(.hwnd, WM_PRINT, .hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
   
        'Refresh image to picture property
        .Picture = .Image
   
        'Copy picture to Printer
        .PaintPicture .Picture, .Width, .Height
   
        ' Enable the Lines below to reset the PictureBox painted picture after use
'        'Restore backcolor  (Re-load picture if picture was used)
'        Picture1.Line (0, 0)-(.ScaleWidth, .ScaleHeight), .BackColor, BF
'
'        'Restore ReDraw
'        .AutoRedraw = ar
    End With
   
End Sub



-------------
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)



Replies:
Posted By: Xander75
Date Posted: 19 January 2011 at 8:15am
Hi,

Just thought I would say that using the code above has resolved my print and export to pdf issue. However I can only seem to use the PrintPreview using BitBlt... unless anyone knows a way of displaying an image from a PictureBox on the PrintPreview and would like to share!

All these views and not a peep Confused


-------------
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net