forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Screen/Window capture with VDSug.dll

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 21, 2003 7:21 pm    Post subject: Screen/Window capture with VDSug.dll Reply with quote

This does NOT save the capture to file, it just blits it to
the VDS window. Not sure if VDSug structs will allow
saving a bitmap or not, but I'm guessing chances are
kinda slim...

You can get VDSug.dll here:

http://www.trinex.net/users/mac/vdsug/

___________________________________________________________________________________________________________________________________________________________________________________________________
Code:

rem -- Screen capture for a specific window (use "Program Manager" for
rem -- full screen capture). Does NOT save to file. Minimizes for a
rem -- second while capturing. "13369376" is the numeric value of the
rem -- Windows API SRCCOPY flag.

rem -- use correct path to VDSug.dll --
EXTERNAL @path(%0)vdsug.dll

UG DLLLOAD, 1, user32.dll
UG DLLINITFUNC, 1, 1, GetWindowDC
UG DLLINITFUNC, 1, 2, PaintDesktop
UG DLLINITFUNC, 1, 3, ReleaseDC

UG DLLLOAD, 2, gdi32.dll
UG DLLINITFUNC, 2, 4, BitBlt
UG DLLINITFUNC, 2, 5, CreateCompatibleDC
UG DLLINITFUNC, 2, 6, CreateCompatibleBitmap
UG DLLINITFUNC, 2, 7, SelectObject
UG DLLINITFUNC, 2, 8, DeleteObject
UG DLLINITFUNC, 2, 9, DeleteDC

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"VDSug Screen Capture",-1,0,500,200,PAINT,RESIZABLE
  %%display_handle = @winexists("VDSug Screen Capture")
  DIALOG ADD,BUTTON,Test,5,5,60,22
  DIALOG ADD,BUTTON,Clear,5,70,60,22
  DIALOG ADD,EDIT,E1,5,135,260,22,"Program Manager"
  DIALOG ADD,TEXT,T1,9,400,,,"<< Window Title"
DIALOG SHOW

rem -- get DC for our VDS display window --
OPTION ERRORTRAP,t1
%%displayDC = @ug(DLLFUNC, GetWindowDC, int, handle:%%display_handle)
:t1

%%clear = 1

:PAINT
  if @not(%%clear)
     rem -- repaint our capture display --
     OPTION ERRORTRAP,paint_trap
     %%result = @ug(DLLFUNC, BitBlt, int, int:%%displayDC, int:5, int:60, int:%%width, int:%%height, int:%%memoryDC, int:0, int:0, int:13369376)
     :paint_trap
  end
:RESIZE
:EVLOOP
  OPTION ERRORTRAP
  WAIT EVENT
  goto @event()

:TestBUTTON
  if @not(@winexists(@dlgtext(E1)))
     WARN "You must enter a valid window title in the edit box."
     goto EVLOOP
  end
  %%clear = ""
  WINDOW ICONIZE, %%display_handle

  rem -- if previous target DC, release it and delete memory DC --
  if %%targetDC
     OPTION ERRORTRAP,t2
     %%result = @ug(DLLFUNC, ReleaseDC, int, handle:%%target_handle, int:%%targetDC)
     :t2
     OPTION ERRORTRAP,t3
     %%result = @ug(DLLFUNC, DeleteDC, int, int:%%memoryDC)
     :t3
  end

  rem -- get current target window handle --
  %%target_handle = @winexists(@dlgtext(E1))

  rem -- in case target is minimized --
  WINDOW NORMAL, %%target_handle

  %%width = @winpos(%%target_handle, W)
  %%height = @winpos(%%target_handle, H)

  rem -- get DC for target window --
  OPTION ERRORTRAP,t4
  %%targetDC = @ug(DLLFUNC, GetWindowDC, int, handle:%%target_handle)
  :t4

  rem -- create compatible DC in memory to store window capture --
  OPTION ERRORTRAP,t5
  %%memoryDC = @ug(DLLFUNC, CreateCompatibleDC, int, int:%%targetDC)
  :t5

  rem -- create compatible bitmap for memory DC from target window DC --
  OPTION ERRORTRAP,t6
  %%compatibleBMP = @ug(DLLFUNC, CreateCompatibleBitmap, int, int:%%targetDC, int:%%width, int:%%height)
  :t6

  rem -- select the bitmap into the memory DC --
  OPTION ERRORTRAP,t7
  %%result = @ug(DLLFUNC, SelectObject, int, int:%%memoryDC, int:%%compatibleBMP)
  :t7

  rem -- delete the bitmap, we're done with it --
  OPTION ERRORTRAP,t8
  %%result = @ug(DLLFUNC, DeleteObject, int, int:%%compatibleBMP)
  :t8

  rem -- blit the target window into the memory DC --
  WINDOW ACTIVATE, %%target_handle
  WAIT
  OPTION ERRORTRAP,t9
  %%result = @ug(DLLFUNC, BitBlt, int, int:%%memoryDC, int:0, int:0, int:%%width, int:%%height, int:%%targetDC, int:0, int:0, int:13369376)
  :t9

  rem -- blit the memory DC to the VDS display window --
  OPTION ERRORTRAP,t10
  %%result = @ug(DLLFUNC, BitBlt, int, int:%%displayDC, int:5, int:60, int:%%width, int:%%height, int:%%memoryDC, int:0, int:0, int:13369376)
  :t10
  WINDOW NORMAL, %%display_handle
  goto EVLOOP

:ClearBUTTON
  %%clear = 1
  DIALOG HIDE
  DIALOG SHOW
  goto EVLOOP

:CLOSE
  exit

BTW, I prefer the "code" tags... Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group