Results 1 to 16 of 16

Thread: >easy< taking screenshot > save it as bmp

  1. #1

    Thread Starter
    Lively Member tonnic's Avatar
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    107

    >easy< taking screenshot > save it as bmp

    hi there, i just want to make a screenshot of my screen and save it as a bmp: thats it.

    soooo, something like:

    private sub command1_click
    take screenshot (c:\screenshot.bmp)
    end sub


    i've found several, but they all suck. Example, i've attached one.
    It DOES make a good screenshot, but it puts the screenie in a frame or something, so its useless...

    please help me

    -Tonnic

  2. #2

    Thread Starter
    Lively Member tonnic's Avatar
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    107
    comooooon, anybody?

  3. #3
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    well there's probably no1 answering because you can find an example in the MSDN... well after the screenshot was put into a "frame" which most likely is a picturebox (if not make it so it is one) go like
    savepicture pic1.picture, "C:\mypic.bmp"

    (or similar...)
    Sanity is a full time job

    Puh das war harter Stoff!

  4. #4

    Thread Starter
    Lively Member tonnic's Avatar
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    107
    dude, i'm a newbie...

    "savepicture pic1.picture, "C:\mypic.bmp" doesn't just pop outta my head...

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    No Problem!!
    so it works for you? good!

    and hey the msdn is alway the first source to look!
    Sanity is a full time job

    Puh das war harter Stoff!

  6. #6

    Thread Starter
    Lively Member tonnic's Avatar
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    107
    first off all, it doesn't work...

    second of all, *** is msdn??

  7. #7
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    mircosoft developer network
    the cds come with the VB and if you don't have any for some reason it can be found online too!
    Sanity is a full time job

    Puh das war harter Stoff!

  8. #8

    Thread Starter
    Lively Member tonnic's Avatar
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    107
    thats nice..

    but 'em.... how about that code??
    Last edited by tonnic; Jul 3rd, 2002 at 07:37 AM.

  9. #9
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    what code?
    Sanity is a full time job

    Puh das war harter Stoff!

  10. #10
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    alright use this code instead of yours... should do it
    VB Code:
    1. Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    2. 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
    3.  
    4. Private Sub Command1_Click()
    5. Dim wScreen As Long
    6. Dim hScreen As Long
    7. Dim w As Long
    8. Dim h As Long
    9. Picture1.Cls
    10.  
    11. wScreen = Screen.Width \ Screen.TwipsPerPixelX
    12. hScreen = Screen.Height \ Screen.TwipsPerPixelY
    13.  
    14. Picture1.ScaleMode = vbPixels
    15. Picture1.AutoRedraw = True
    16. w = Screen.Width / Screen.TwipsPerPixelX
    17. w = Screen.Height / Screen.TwipsPerPixelY
    18.  
    19. hdcScreen = GetDC(0)
    20.  
    21. r = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy)
    22. SavePicture Picture1.Image, "C:\yourfile.bmp"
    23. End Sub
    Sanity is a full time job

    Puh das war harter Stoff!

  11. #11

    Thread Starter
    Lively Member tonnic's Avatar
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    107
    the goddamn code that should make my ****ing screenshot taker work!

  12. #12
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    well isn't that code I posted working? (It's possible since I haven't tried it..., but if not it should be no problem to fix it...)
    Sanity is a full time job

    Puh das war harter Stoff!

  13. #13

    Thread Starter
    Lively Member tonnic's Avatar
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    107
    no, the code isn't working... i've said that...

    and it may be easy to fix, but wouldn't know how...

    please test the code and make it work

  14. #14
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299
    Please try this. Make sure the picturebox is not visible. This works like a charm. Set form1_scalewidth=pixels. good luck.
    Code:
    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 Declare Function FindWindow Lib "user32" _
       Alias "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As String) 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 = Screen.Width / Screen.TwipsPerPixelX
    h = Screen.Height / Screen.TwipsPerPixelY
    
    hdcScreen = GetDC(FindWindow("Progman", vbNullString))
    
    picture1.width=wScreen
    picture1.height=hScreen
    Picture1.AutoRedraw = True
    
    r = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy)
    Picture1.Refresh
    SavePicture Picture1.Image, "C:\yourfile.bmp"
    End Sub

  15. #15
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    lol jesus christ. i dunno why u guys bother, obviously he cud not be bothered to search one little bit for himself and then has the cheak to arse around with less manners than the animals at the farm down my road!

  16. #16
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    yeah psy is right...
    well here the code
    you can delete some parts and clean it up and make the picbox invisible...
    next time try to be little more polite... look at the other posts and you wont find a lot of F*** and *** there...
    I keep the bad programming habit given by your sample code..
    VB Code:
    1. Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    2. 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
    3. Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    4.  
    5. 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
    6.  
    7.  
    8. Private Sub Command1_Click()
    9. Dim wScreen As Long
    10. Dim hScreen As Long
    11. Dim w As Long
    12. Dim h As Long
    13. Picture1.Cls
    14.  
    15. wScreen = Screen.Width \ Screen.TwipsPerPixelX
    16. hScreen = Screen.Height \ Screen.TwipsPerPixelY
    17.  
    18. Picture1.ScaleMode = vbPixels
    19. Picture1.AutoRedraw = True
    20. w = Screen.Width / Screen.TwipsPerPixelX
    21. h = Screen.Height / Screen.TwipsPerPixelY
    22.  
    23. hdcScreen = GetDC(0)
    24. 'hdcScreen = GetWindowDC(0)
    25.  
    26.  'StretchBlt Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, w, h, &HCC0020
    27.    Form1.ScaleMode = vbPixels
    28.    Picture1.Width = w
    29.   Picture1.Height = h
    30.  
    31.  BitBlt Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, &HCC0020
    32.  
    33. SavePicture Picture1.Image, "C:\yourfile.bmp"
    34. End Sub
    Sanity is a full time job

    Puh das war harter Stoff!

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