|
-
Jan 14th, 2022, 05:49 AM
#1
Thread Starter
Addicted Member
Re: PDF Reader ActiveX Control
 Originally Posted by jtw400
This is a great project! I modified it a little to draw to an offscreen DC and then bitblt to the picture box. That helps display more complicated PDFs faster....
Hello jtw400,
it would be nice to post these changes in this thread, so that the community can test and integrate them.
Thanks in advance
Best regards
François
-
Jan 14th, 2022, 08:05 AM
#2
New Member
Re: PDF Reader ActiveX Control
 Originally Posted by saturnian
Hello jtw400,
it would be nice to post these changes in this thread, so that the community can test and integrate them.
Thanks in advance
Best regards
François
Here you go... use this whenever needed to draw a page from a PDF already opened with "PDFLoad"
Code:
Dim TempDC As Long, TempBMP As Long, hDesktop As Long, hBrush As Long, pRect As RECT
hDesktop = GetDesktopWindow()
GetClientRect PDFView.hwnd, pRect
TempDC = CreateCompatibleDC(GetDC(hDesktop))
TempBMP = CreateCompatibleBitmap(PDFView.hdc, pRect.Right, pRect.Bottom)
SelectObject TempDC, TempBMP
hBrush = CreateSolidBrush(RGB(255, 255, 255))
FillRect TempDC, pRect, hBrush
RenderPageToDC TempDC, nPage - 1, 0, 0, pRect.Right * Screen.TwipsPerPixelX, pRect.Bottom * Screen.TwipsPerPixelY
BitBlt PDFView.hdc, 0, 0, pRect.Right, pRect.Bottom, TempDC, 0, 0, vbSrcCopy
DeleteDC TempDC
DeleteObject TempBMP
DeleteObject hBrush
'///// Declarations
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
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
Declare Function FillRect Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|