Solved

PrintWindow API Call ( VB 6.0 and 500 Points)

Posted on 2009-03-29
2
1,243 Views
Last Modified: 2013-11-25
I need to use the PrintWindow API Call to save a portion of a window to a picture box. I have done this so far ( see attached code). Any suggestions?
Dim Hwndwindow As Long
Hwndwindow = FindWindow(vbNullString, "Calculator")
Picture1.Visible = True
Picture1.AutoRedraw = True
Picture1.Picture = Nothing
PrintWindow Hwndwindow, Picture1.hDC, 0

Open in new window

0
Comment
Question by:KingSencat
2 Comments
 
LVL 2

Accepted Solution

by:
pathakhemant earned 500 total points
ID: 24016246
Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Command1_Click()
Dim Hwndwindow As Long
Hwndwindow = FindWindow(vbNullString, "Calculator")
Picture1.Visible = True
Picture1.AutoRedraw = True
Picture1.Picture = Nothing
PrintWindow Hwndwindow, Picture1.hDC, 0
End Sub
' OPEN CALCULATOR BEFORE PRESSING COMMAND1_CLICK
ITS WORKING

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB Script to add site to Java Exception List 4 76
Create Files based on Cell Values in a Range in Excel 12 37
Automatic Email Reminder 4 36
VBScript Write Column Headers 3 36
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

785 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