Picture box turn out blank why?

02-09-2005, 12:43 PM
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

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

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

02-09-2005, 02: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
ReleaseDC 0, lDC
End Sub

02-09-2005, 02: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