Capture Web Page 4

Category: Jose Roca

Date: 02-16-2022

Return to Index


 
'Compilable Example:  (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
 
Enum Equates Singular
   IDC_Button = 500
   IDC_TextBox
End Enum
 
Global hDlg,hTextBox,hButton As Dword
 
Function PBMain() As Long
   Dialog New Pixels, 0, "PowerBASIC",300,300,250,150, %WS_OverlappedWindow To hDlg
   Control Add Button, hDlg, %IDC_Button,"Capture OffScreen TextBox", 10,10,180,20
   Control Handle hDlg, %IDC_Button To hButton
   Control Add TextBox, hDlg, %IDC_TextBox,"OffScreen TextBox", -75,50,150,20
   Control Handle hDlg, %IDC_TextBox To hTextBox
   Dialog Show Modal hDlg Call DlgProc
End Function
 
CallBack Function DlgProc() As Long
   Local hBMP,hDC_Graphic,hDC_TextBox,hBitmap As Dword, iResult As Long
   Local hDCMem,hDC As Dword
 
   Select Case Cb.Msg
      Case %WM_Command
         Select Case Cb.Ctl
            Case %IDC_Button
               hDC = GetWindowDC(hTextBox)
               hDCmem = CreateCompatibleDC(hDC)
               hBitmap = CreateCompatibleBitmap(hDC, 150,20)
               SelectObject hDCmem,hBitmap
 
               iResult = PrintWindow(hTextBox, hDC,%PW_ClientOnly)
 
               Graphic Bitmap New 150,20 To hBMP
               Graphic Attach hBMP,0
               Graphic Get DC To hDC_Graphic
 
               Bitblt hDC_Graphic,0,0,150,20,hDC,0,0,%SRCCopy
 
               'put memory bitmap on clipboard
               Clipboard Reset
               Clipboard Set Bitmap hBMP
               ? "TextBox image placed on clipboard!" + Str$(iResult)
         End Select
   End Select
End Function
 
'gbs_01435
'Date: 10-17-2014              


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm