🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.acrobat.reader
Article #288

Re: AcroPDF activex - bitblt

#288
From: Ken Halter
Date: Mon, 14 May 2007 16:10
78 lines
2922 bytes
"NowItsWhatever" <nospam@nospam.com> wrote in message 
news:_zk1i.5127$3B5.1994@trnddc08...
> In a VB6 application, I want to perform a bitblt on the rendered PDF 
> image. The AcroPDF activex properties do not include a handle to a device 
> context (hDC) property.  Is there a "back door" way I can derive the hDC?

This /seems/ to work. I have nothing to test it with...
'=====================
Option Explicit

Private Type RECT
   left As Long
   top As Long
   right As Long
   bottom As Long
End Type

Private Type POINTAPI
   x As Long
   y As Long
End Type

Private Declare Function WindowFromPoint _
   Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Private Declare Function GetWindowRect _
   Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Declare Function GetDC _
   Lib "user32.dll" (ByVal hwnd As Long) As Long

Private Declare Function ReleaseDC _
   Lib "user32.dll" (ByVal hwnd As Long, ByVal hdc As Long) As Long

Private Sub Command1_Click()

   Call AcroPDF1.LoadFile("C:\Temp\Temp.pdf")

End Sub

Private Sub Command2_Click()
   Dim tRect As RECT
   Dim tPoint As POINTAPI
   Dim lAcroHwnd As Long
   Dim lDC As Long
   Static bHereB4 As Boolean

   Me.ScaleMode = vbPixels

   'Find the form's abs coordinates
   Call GetWindowRect(Me.hwnd, tRect)

   'Offset to the middle of the acrobat control
   With tPoint
      .x = tRect.left + ((AcroPDF1.top + AcroPDF1.Height) / 2)
      .y = tRect.top + ((AcroPDF1.left + AcroPDF1.Width) / 2)
   End With

   'Get it's hWnd
   lAcroHwnd = WindowFromPoint(tPoint.x, tPoint.y)

   'Get it's DC (seems to be valid only after second call)
   lDC = GetDC(lAcroHwnd)

   'Show the DC
   Debug.Print lDC, right$("0000000" & Hex$(lDC), 8)

   'Release it
   Call ReleaseDC(lAcroHwnd, lDC)

   Me.ScaleMode = vbTwips

End Sub
'=====================

-- 
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm 
Technical Details
Message-ID: <OGGhnKklHHA.4688@TK2MSFTNGP03.phx.gbl>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newshub.sdsu.edu!msrtrans!TK2MSFTFEEDS01.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP03.phx.gbl
References: <_zk1i.5127$3B5.1994@trnddc08>

Show Full Headers
Complete Article Headers
X-Google-Thread: 109513,7943f89c1a386a1a
X-Google-Thread: 10b213,7943f89c1a386a1a
X-Google-Attributes: gid109513,gid10b213,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com>
References: <_zk1i.5127$3B5.1994@trnddc08>
Subject: Re: AcroPDF activex - bitblt
Date: Mon, 14 May 2007 09:10:49 -0700
Lines: 80
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Response
Message-ID: <OGGhnKklHHA.4688@TK2MSFTNGP03.phx.gbl>
Newsgroups: adobe.acrobat.reader,microsoft.public.vb.controls
NNTP-Posting-Host: smtp.tamsci.com 12.31.176.130
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newshub.sdsu.edu!msrtrans!TK2MSFTFEEDS01.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP03.phx.gbl