Solved

PrintForm not print out  the .ocx controls.

Posted on 1998-12-12
5
200 Views
Last Modified: 2010-05-03
I tried PrintForm but con not print out the .cox controls in the form, only the standard controls were printed out.

Any thing wrong I did? How to print the .cox controls as well?

Cheers.

Learn
0
Comment
Question by:learn
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
Sendoh earned 50 total points
ID: 1449720
Hi !

you may try create a picturebox and set the visible to false.
then write the following code:

Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

Private Declare Function BitBlt Lib "gdi32" _
    (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
    ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
    ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Sub Command1_Click()
    Picture1.Width = Form1.Width
    Picture1.Height = Form1.Height
    BitBlt Picture1.hDC, 0, 0, Form1.Width, Form1.Height, _
            Form1.hDC, 0, 0, SRCCOPY
    Printer.PaintPicture Picture1.Image, 0, 0
End Sub

0
 

Author Comment

by:learn
ID: 1449721
Hi Sendoh

You again :-)

OK, I will try what you suggested.
Do you believe VB can not print out the .ocx controls in a form by PrinForm?

Cheers.

Learn
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 1449722
Yes !! I'd tried it out already.
Somehow it just can't printout the custom ocx control.
I've got some addition comment, If you need to print the form border as well, then you had to
       parentHwnd = getParent(form1.hwnd)
       parentDC = getDC(parentDC)
       BitBlt picture1.hdc, 0, 0, Form1.Width, _
               Form1.Height, parentDC, startX, startY, SRCCOPY

Note: startX and startY are the screen coordinate for form1.
0
 

Author Comment

by:learn
ID: 1449723
Hi Sendoh

Thank you for your added comment.

>Yes !! I'd tried it out already.

My English is not very good :-) When you say "Yes", do you mean "PrintForm can not print the .ocx controls in the printer"?

Happy Xmas.

Learn
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 1449724
Yeap ! I think so.
I think there is some reason behind. Who knows ??
BTW,
Merry Christmas !! ^_^
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

911 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

21 Experts available now in Live!

Get 1:1 Help Now