Picture box turn out blank why?

wing87
02-09-2005, 11:43 AM
i have a sub for making a print screen (http://www.nomorepasting.com/paste.php?pasteID=31256) but if i use .Refresh on the picture box the picturebox just turns out blank why? i need to use .Refresh

OnErr0r
02-09-2005, 12:04 PM
Change the PictureBox.AutoRedraw = True.

wing87
02-09-2005, 12:41 PM
dosent change any thing!

OnErr0r
02-09-2005, 01:01 PM
This works fine, assuming Picture1.AutoRedraw = True:


Option Explicit

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode 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 ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

Private Const HALFTONE = 4

Private Sub Form_Load()
StretchDesktop Picture1
End Sub

Public Sub StretchDesktop(ByVal pic As PictureBox)
Dim lDC As Long

lDC = GetDC(0) ' Get the Desktop DC
SetStretchBltMode pic.hdc, HALFTONE ' Tell StretchBlt to resize with higher quality
pic.ScaleMode = vbPixels ' ScaleWidth/ScaleHeight in pixels
StretchBlt pic.hdc, 0, 0, pic.ScaleWidth, pic.ScaleHeight, lDC, 0, 0, Screen.Width \ Screen.TwipsPerPixelX, Screen.Height \ Screen.TwipsPerPixelY, vbSrcCopy
pic.Refresh
ReleaseDC 0, lDC
End Sub

OnErr0r
02-09-2005, 01:06 PM
P.S. If you want to have some fun, add this: ;)


Private Sub Form_Resize()
If WindowState <> vbMinimized Then
Picture1.Move 0, 0, ScaleWidth, ScaleHeight
StretchDesktop Picture1
End If
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum