🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.acrobat.reader
Article #107

Re: AcroPDF activex - bitblt

#107
From: NowItsWhatever
Date: Fri, 15 Jun 2007 19:48
92 lines
4081 bytes
NowItsWhatever wrote:
> 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.
> 

Still no ideas about getting the entire page, not just the clipped window?
Technical Details
Message-ID: <52Cci.410$Zh6.398@trnddc04>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc04.POSTED!30ec6d2a!not-for-mail
References: <_zk1i.5127$3B5.1994@trnddc08> <OGGhnKklHHA.4688@TK2MSFTNGP03.phx.gbl> <cN32i.67046$Ae.8495@trnddc07>

Show Full Headers
Complete Article Headers
X-Google-Thread: 109513,7943f89c1a386a1a
X-Google-Thread: 10b213,7943f89c1a386a1a
X-Google-Attributes: gid109513,gid10b213,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc04.POSTED!30ec6d2a!not-for-mail
From: NowItsWhatever <nospam@nospam.com>
User-Agent: Thunderbird 1.5.0.12 (Windows/20070509)
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> <cN32i.67046$Ae.8495@trnddc07>
In-Reply-To: <cN32i.67046$Ae.8495@trnddc07>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 92
Message-ID: <52Cci.410$Zh6.398@trnddc04>
Date: Fri, 15 Jun 2007 19:48:17 GMT
NNTP-Posting-Host: 71.109.150.112
X-Complaints-To: abuse@verizon.net
X-Trace: trnddc04 1181936897 71.109.150.112 (Fri, 15 Jun 2007 15:48:17 EDT)
NNTP-Posting-Date: Fri, 15 Jun 2007 15:48:17 EDT
X-Original-Bytes: 3894