Fully functional Screen Capture (like SnagIt)
Posted: Tue Jun 10, 2003 11:06 pm
With the help of those nice people here, i am able to make this screen capture the way it is like in SnagIt.
Feature:
Left mouse down to start cpature
Drag while left mouse is still down to define a rectangle to capture.
Left mouse up to finish capture
Hotkey (Shift + Ctrl + F11) to start capture.
When the capture start, it will sit there until someone press the hot keys and then you should start the capturing process. The captured image will be in the clipboard.
Thanks again to all who help.
Cecil
[/code]
Feature:
Left mouse down to start cpature
Drag while left mouse is still down to define a rectangle to capture.
Left mouse up to finish capture
Hotkey (Shift + Ctrl + F11) to start capture.
When the capture start, it will sit there until someone press the hot keys and then you should start the capturing process. The captured image will be in the clipboard.
Thanks again to all who help.
Cecil
Code: Select all
;Drag with left mouse button to select a part of the screen
;Release the left button to paste it as a bitmap to the clipboard and end
Window_Width = GetSystemMetrics_(#SM_CXSCREEN)
Window_Height = GetSystemMetrics_(#SM_CYSCREEN)
corner1.POINT
corner2.POINT
Procedure CaptureScreen(Left, Top, Width, Height)
dm.DEVMODE ;structure for CreateDC()
srcDC.l
trgDC.l
BMPHandle.l
srcDC = CreateDC_("DISPLAY", "", "", dm)
trgDC = CreateCompatibleDC_(srcDC)
BMPHandle = CreateCompatibleBitmap_(srcDC, Width, Height)
SelectObject_(trgDC, BMPHandle)
BitBlt_(trgDC, 0, 0, Width, Height, srcDC, Left, Top, #SRCCOPY)
OpenClipboard_(#NULL)
EmptyClipboard_()
SetClipboardData_(2, BMPHandle)
CloseClipboard_()
DeleteDC_(trgDC)
ReleaseDC_(BMPHandle, srcDC)
MyImage = CreateImage(0, width, height) ; create a new empty bitmap, retrieve handle
ImageID = GetClipboardData(#PB_ClipboardImage) ; get clipboard bitmap handle
StartDrawing(ImageOutput()) ; start drawing to the bitmap we created
DrawImage(ImageID, 0, 0) ; draw the image from clipboard
DrawingMode(0)
Locate(0, height/2)
FrontColor(255,0,0)
BackColor(0,0,0)
DrawText("Some text.") ; I am making some shareware, so i add some text so people must register.
StopDrawing()
SetClipboardData(#PB_ClipboardImage, MyImage)
ProcedureReturn
EndProcedure
CatchImage(2, ?Logo)
If OpenWindow(0,100,150,291,155,#PB_Window_SystemMenu,"TBK Capture")
CreateGadgetList(WindowID())
ImageGadget(0, 0, 0, 0, 0, UseImage(2))
RegisterHotKey_(WindowID(),1,#MOD_SHIFT|#MOD_CONTROL,#VK_F11)
Repeat
Select WindowEvent()
Case #WM_HOTKEY
Pic_desktop = CreateImage(1, Window_Width, Window_Height)
hDC = StartDrawing(ImageOutput())
BitBlt_(hDC, 0, 0, Window_Width, Window_Height, GetDC_(GetDesktopWindow_()), 0, 0, #SRCCOPY)
StopDrawing()
OpenWindow(1, 0, 0, Window_Width, Window_Height, #WS_POPUP, "Capturing")
CreateGadgetList(WindowID())
ImageGadget(1, 0, 0, Window_Width, Window_Height, Pic_desktop)
Layer1_desktop = CreateImage(2, Window_Width, Window_Height)
hWnd1 = FindWindow_(0, "Capturing")
SetForegroundWindow_(hWnd1)
Case #WM_MOUSEMOVE
If drawbox And SettingCursor=0
UseImage(2)
StartDrawing(WindowOutput())
DrawImage(UseImage(1), 0, 0)
FrontColor(255, 255, 255)
DrawingMode(2|4)
GetCursorPos_(corner2)
Box(corner1\x, corner1\y, corner2\x-corner1\x, corner2\y-corner1\y, $FFFFFF)
StopDrawing()
SettingCursor = 1
SetCursorPos_(corner2\x, corner2\y)
Else
SettingCursor = 0
EndIf
Case #WM_LBUTTONDOWN
GetCursorPos_(corner1)
drawbox = 1
Case #WM_LBUTTONUP
StartDrawing(WindowOutput()) ; don't grab the boxlines
DrawImage(UseImage(1),0,0)
StopDrawing()
;CreateCompatibleBitmap_ cannot handle negative width/height values...
If corner1\x>corner2\x:temp = corner2\x:corner2\x = corner1\x:corner1\x = temp:EndIf
If corner1\y>corner2\y:temp = corner2\y:corner2\y = corner1\y:corner1\y = temp:EndIf
CaptureScreen(corner1\x, corner1\y, corner2\x-corner1\x, corner2\y-corner1\y)
MessageRequester("", "Copied to clipboard...", #MB_ICONINFORMATION)
End
drawbox = 0
; Case #WM_LBUTTONUP:drawbox = 0
EndSelect
Delay(1)
ForEver
EndIf
Logo: IncludeBinary "FOO.bmp"
End