Results 1 to 8 of 8

Thread: Screen Shot

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Does anyone know where i can get source that takes apicture of the screen, i.e. a screen shot, without using the Print Screen button ?

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You could use bitblt with the desktop's wnd's DC, into a picturebox which picture you can copy into the clipboard, that does the same
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    worth a try

    'screen grab...command1 and picture1 required
    '
    Private Declare Function GetDC Lib "user32" _
    (ByVal hwnd As Long) As Long

    Private Declare Function StretchBlt Lib _
    "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long


    Private Sub Command1_Click()
    Dim wScreen As Long
    Dim hScreen As Long
    Dim w As Long
    Dim h As Long
    Picture1.Cls

    wScreen = Screen.Width \ Screen.TwipsPerPixelX
    hScreen = Screen.Height \ Screen.TwipsPerPixelY

    Picture1.ScaleMode = vbPixels
    w = Picture1.ScaleWidth
    h = Picture1.ScaleHeight


    hdcScreen = GetDC(0)

    r = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy)

    End Sub

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Stretchblt is slow, if you nessarily needs to youse it, use painpicture instead. Also, why not make a picture with the size of the desktop and then use bitblt with it?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Thanks, i'm not up to speed on bitblt thingy so i'll try that long bit of code first. Thanks to all those of answered though.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    i tried that big bit of code, it is extreemly slow or does not work, how do i use paint picture. i got this far

    Private Sub Command1_Click()
    Picture1.PaintPicture
    End Sub

    What goes next ?

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    formorpicturebox.Paintpicture picture,x1,y1,w1,h1,x2,y2,w2,h2,vbsrccopy
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Member
    Join Date
    May 2000
    Posts
    43

    Question U could try.......

    Okay this sets the screen shot as the form picture but can easilly be modified:


    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private 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

    Private Sub Form_Load()
    Form1.AutoRedraw = True
    Form1.ScaleMode = 1
    A = GetDesktopWindow()
    s = GetDC(A)
    BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, s, 0, 0, vbSrcCopy
    End Sub



    Right i hope that helps
    Cease

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width