🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.acrobat.reader
3 messages
3 total messages Started by NowItsWhatever Sat, 12 May 2007 14:55
AcroPDF activex - bitblt
#287
Author: NowItsWhatever
Date: Sat, 12 May 2007 14:55
1 lines
1166 bytes
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?
Re: AcroPDF activex - bitblt
#288
Author: 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 
Re: AcroPDF activex - bitblt
#289
Author: 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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads