PrintForm not print out  the .ocx controls.

Posted on 1998-12-12
Medium Priority
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?


Question by:learn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Accepted Solution

Sendoh earned 200 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


Author Comment

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?



Expert Comment

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.

Author Comment

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.


Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

719 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