🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.acrobat.reader
Article #289

Re: AcroPDF activex - bitblt

#289
From: NowItsWhatever
Date: Mon, 14 May 2007 20:38
80 lines
3836 bytes
Ken Halter wrote:
> "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
> '=====================
> 

That seems to work for me.  I am using the DC for that window to BITBLT to another DC.  That other DC has some annotations on it. I calculate the source width and height by performing Call GetWindowRect(lAcroHwnd, tRect) to get top, bottom, left, and right of the rendered PDF image, and the pass them in to BITBLT.  I need guidance about 2 things.

How can I scale up the image when BITBLT'ing to the destination DC?  Also, the AcroPDF window clips the rendered image, and all I get when I BITBLT to the destination DC is the what's visible, not the entire page.  Is there a way of getting the entire page?  Thanks.
Technical Details
Message-ID: <cN32i.67046$Ae.8495@trnddc07>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!out03b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!cycny01.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc07.POSTED!30ec6d2a!not-for-mail
References: <_zk1i.5127$3B5.1994@trnddc08> <OGGhnKklHHA.4688@TK2MSFTNGP03.phx.gbl>

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
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!out03b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!cycny01.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc07.POSTED!30ec6d2a!not-for-mail
From: NowItsWhatever <nospam@nospam.com>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: adobe.acrobat.reader,microsoft.public.vb.controls
Subject: Re: AcroPDF activex - bitblt
References: <_zk1i.5127$3B5.1994@trnddc08> <OGGhnKklHHA.4688@TK2MSFTNGP03.phx.gbl>
In-Reply-To: <OGGhnKklHHA.4688@TK2MSFTNGP03.phx.gbl>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 81
Message-ID: <cN32i.67046$Ae.8495@trnddc07>
Date: Mon, 14 May 2007 20:38:32 GMT
NNTP-Posting-Host: 71.109.157.27
X-Complaints-To: abuse@verizon.net
X-Trace: trnddc07 1179175112 71.109.157.27 (Mon, 14 May 2007 16:38:32 EDT)
NNTP-Posting-Date: Mon, 14 May 2007 16:38:32 EDT