Results 1 to 12 of 12

Thread: How can I make a screenshot?????

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29

    Exclamation

    How can I make a screenshot when my form is starting??

  2. #2

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You forgot a quotation mark

    I have a demo on my site... (right-click -> Save as...)

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29

    Thumbs up Thanks!!

    Thanks for the hints!

    Neon

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29

    Red face Ahhhhhhh!

    I downloaded the Demoe made by Fox but it contained some mistakes!!

    For instance there was a variable not declared so that I wasn't able to use it!!

    Can just someone give me the source code, or the name under which I can search for in the help file, but I use a german VB5!! And I didn't find anything about it!

    Thanks Neon

  6. #6
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Question

    I looked at the source and Option Explicit is defined so there can't be any undefined variable. Maybe because it's made in VB6, you should make a new project and add the form/module of my project to it.

    (That's also a point why I linked to the HP so people see the FAQ, and not only download the demos and when having trouble dunno why...)

  7. #7
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    BTW: You won't find anything in the help without having MSDN installed because
    it's API stuff. And my demos are tested, they all work (or I at least hope so )
    Anyway, here's a tutorial for YOU:

    Open a new project, add a PictureBox "Buffer" to it, don't forget to set all ScaleModes
    to pixel. Then add two buttons "cmdBitBlt" and "cmdStretchBlt".
    Finally add this code:
    Code:
    'To your module
    'API
        Public 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
        Public 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
        
        Public Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
        Public Declare Function GetDesktopWindow Lib "user32" () As Long
        Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    
    'In the form
    Private Sub cmdBitBlt_Click()
        Dim DC  As Long
        
        'Get DC of desktop (=screen)
        DC = GetWindowDC(GetDesktopWindow)
        
        'BitBlt to Buffer
        BitBlt Buffer.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, DC, 0, 0, vbSrcCopy
        
        'Release DC
        ReleaseDC frmMain.hwnd, DC
    End Sub
    
    Private Sub cmdStretchBlt_Click()
        Dim DC  As Long
    
        'Get DC of desktop (=screen)
        DC = GetWindowDC(GetDesktopWindow)
        
        'BitBlt to Buffer
        StretchBlt Buffer.hdc, 0, 0, Buffer.Width, Buffer.Height, DC, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, vbSrcCopy
        
        'Release DC
        ReleaseDC frmMain.hwnd, DC
    End Sub
    If you want to save the file set the AutoRedraw property of the picturebox to true and
    add another button with this code:
    Code:
    SavePicture Buffer.Image, "C:\Test.bmp" 'Or any other file
    Note that you won't see the picture now unless you save it!

  8. #8
    Guest
    his demo worked fine for me.
    the only demos that dont work for me is 2 ddraw demo's,
    the mouse one worked, but the other 2 didnt....

  9. #9

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29

    Unhappy OK,ok!

    Ok, it might be as Fox suggested! I am using VB5 and he wrot it with VB6 as far as I could understand it.
    So I'll try his code later on cause I have to do a lot for the school!!!
    Thanks Neon

  10. #10
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    np

    btw: You're german?

  11. #11

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29

    Cool German??

    Yes I am! Why do you ask??
    What about you, where do you come from??
    Neon

  12. #12
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    [german]
    Ich frag nur Hatte auch mal das deutsche VS, aber das englische ist mir doch lieber...
    [/german]

    Switzerland

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