|
-
Jul 3rd, 2002, 06:23 AM
#1
Thread Starter
Lively Member
>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
-
Jul 3rd, 2002, 06:42 AM
#2
Thread Starter
Lively Member
-
Jul 3rd, 2002, 06:50 AM
#3
Frenzied Member
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!
-
Jul 3rd, 2002, 07:03 AM
#4
Thread Starter
Lively Member
dude, i'm a newbie...
"savepicture pic1.picture, "C:\mypic.bmp" doesn't just pop outta my head...
-
Jul 3rd, 2002, 07:05 AM
#5
Frenzied Member
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!
-
Jul 3rd, 2002, 07:15 AM
#6
Thread Starter
Lively Member
first off all, it doesn't work...
second of all, *** is msdn??
-
Jul 3rd, 2002, 07:27 AM
#7
Frenzied Member
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!
-
Jul 3rd, 2002, 07:28 AM
#8
Thread Starter
Lively Member
thats nice..
but 'em.... how about that code??
Last edited by tonnic; Jul 3rd, 2002 at 07:37 AM.
-
Jul 3rd, 2002, 07:44 AM
#9
Frenzied Member
Sanity is a full time job
Puh das war harter Stoff!
-
Jul 3rd, 2002, 07:47 AM
#10
Frenzied Member
alright use this code instead of yours... should do it
VB 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 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
Picture1.AutoRedraw = True
w = Screen.Width / Screen.TwipsPerPixelX
w = Screen.Height / Screen.TwipsPerPixelY
hdcScreen = GetDC(0)
r = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy)
SavePicture Picture1.Image, "C:\yourfile.bmp"
End Sub
Sanity is a full time job
Puh das war harter Stoff!
-
Jul 3rd, 2002, 07:48 AM
#11
Thread Starter
Lively Member
the goddamn code that should make my ****ing screenshot taker work!
-
Jul 3rd, 2002, 01:52 PM
#12
Frenzied Member
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!
-
Jul 3rd, 2002, 03:04 PM
#13
Thread Starter
Lively Member
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
-
Jul 3rd, 2002, 03:21 PM
#14
Hyperactive Member
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
-
Jul 5th, 2002, 03:10 PM
#15
Frenzied Member
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!
-
Jul 5th, 2002, 06:48 PM
#16
Frenzied Member
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:
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 GetWindowDC 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 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
Picture1.AutoRedraw = True
w = Screen.Width / Screen.TwipsPerPixelX
h = Screen.Height / Screen.TwipsPerPixelY
hdcScreen = GetDC(0)
'hdcScreen = GetWindowDC(0)
'StretchBlt Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, w, h, &HCC0020
Form1.ScaleMode = vbPixels
Picture1.Width = w
Picture1.Height = h
BitBlt Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, &HCC0020
SavePicture Picture1.Image, "C:\yourfile.bmp"
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|