Solved

Printing Picture Boxes

Posted on 1999-01-07
2
140 Views
Last Modified: 2010-05-03
I have to print a picture box that contains controls on it.
So i need to print the controls that are in the picture box while maintaining the same spacing.
0
Comment
Question by:herling
2 Comments
 
LVL 2

Expert Comment

by:spenner
Comment Utility
What about capturing the area inside the picture box as another picture and then printing that.  You could use the following code to capture the area and put it into a picture box, and then print the new picture box which contains a picture of the controls in their proper positions.

'@@@@@@@@ Insert this Code into a Module @@@@@@@@

'The screen capture code listed below takes parameters X,Y,
'Width,and Height.

'declares
    DefInt A-Z
    Declare Sub ReleaseDC Lib "User" (ByVal hWnd, ByVal hDC)
    Declare Sub OpenClipBoard Lib "User" (ByVal hWnd)
    Declare Sub EmptyClipBoard Lib "User" ()
    Declare Sub SetClipBoardData Lib "User" (ByVal CBFormat, ByVal hBitMap)
    Declare Sub CloseClipBoard Lib "User" ()
    Declare Sub SelectObject Lib "GDI" (ByVal hDC, ByVal hObj)
    Declare Sub DeleteDC Lib "GDI" (ByVal hDC)
    Declare Sub BitBlt Lib "GDI" (ByVal DestDC, ByVal X, ByVal Y, ByVal BWidth, ByVal BHeight, ByVal SourceDC, ByVal X, ByVal Y, ByVal Constant&)
    Declare Function CreateDC Lib "GDI" (ByVal Driver$, ByVal Dev&, ByVal O&, ByVal Init&)
    Declare Function CreateCompatibleDC Lib "GDI" (ByVal hDC)
    Declare Function CreateCompatibleBitmap Lib "GDI" (ByVal hDC, ByVal BWidth, ByVal BHeight)

'*********************************************************************
' Capture the screen for specified x,y co-ordinates
'

Sub ScrnCap(Lt, Top, Rt, Bot)
    rWidth = Rt - Lt
    rHeight = Bot - Top
    SourceDC = CreateDC("DISPLAY", 0, 0, 0)
    DestDC = CreateCompatibleDC(SourceDC)
    BHandle = CreateCompatibleBitmap(SourceDC, rWidth, rHeight)
    SelectObject DestDC, BHandle
    BitBlt DestDC, 0, 0, rWidth, rHeight, SourceDC, Lt, Top, &HCC0020
    Wnd = Screen.ActiveForm.hWnd
    OpenClipBoard Wnd
    EmptyClipBoard
    SetClipBoardData 2, BHandle
    CloseClipBoard
    DeleteDC DestDC
    ReleaseDC DHandle, SourceDC
End Sub

'@@@@@@@@ Insert this Code into a Form @@@@@@@@

'*********************************************************************
' Send the co-ordinates to the screen-capture routine
'

Sub CaptureScreen()
    Form1.Visible = False
    ScrnCap 0, 0, 640, 480
    Form1.Visible = True
    picture1 = Clipboard.GetData()
End Sub
0
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
Comment Utility
Here is how I print a bitmap in my Print Preview

On Error GoTo ERROR_LOAD_BITMAP
frmPreview.PictList = LoadPicture(sPicture)

' *** Paint the bitmap
frmPreview.pictPreview(0).PaintPicture frmPreview.PictList, previewLine.nCurrentX + (nMarginWidth / 2), previewLine.nCurrentY + (nMarginHeight / 2)
     
Set frmPreview.PictList = Nothing

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now