你光create位圖,不釋放,肯定崩潰呀。的釋放,DeleteObject釋放Bitmap,DeleteDC釋放DC,另外Graphics.FromHwnd(Form1.DIVPanel.Handle)返回的DC也需要釋放,代碼改成這樣:
10年積累的網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有登封免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
Function?GetSerPic(Optional?ByVal?BitWidth?As?Integer?=?-1,?Optional?ByVal?BitHeight?As?Integer?=?-1)?As?Image
Dim?g?As?Graphics?=?Graphics.FromHwnd(Me.DIVPanel.Handle)
Dim?SourceDC?As?Long?=?g.GetHdc()
Dim?Bhandle,?DestDC?As?Long,?Old?As?Long
DestDC?=?CreateCompatibleDC(SourceDC)
Bhandle?=?CreateCompatibleBitmap(SourceDC,?BitWidth,?BitHeight)
Old?=?SelectObject(DestDC,?Bhandle)
BitBlt(DestDC,?0,?0,?BitWidth,?BitHeight,?SourceDC,?0,?0,?HCC0020)
Dim?bmp?As?Bitmap?=?Image.FromHbitmap(Bhandle)
SelectObject(DestDC,?Old)
DeleteObject(Bhandle)
DeleteDC(DestDC)
g.ReleaseHdc()
Return?bmp
End?Function
shell "路徑" ;先調(diào)用
然后
Private Declare Function GetDC 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 Form_Load()
Me.Hide
Me.AutoRedraw = True
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0, 0, vbSrcCopy
sFile$ = "C:\" Format(Now, "mmddhhmmss") ".BMP"
SavePicture Me.Image, sFile
MsgBox "當(dāng)前屏幕圖像已經(jīng)保存到" sFile, 64
End
End Sub ;保存截圖
當(dāng)然是全部重畫(huà)。
層只不過(guò)是制圖軟件弄出來(lái)的一個(gè)方便的東西而已。
就像你畫(huà)畫(huà),畫(huà)上去如果你要擦掉當(dāng)然是擦到底色咯。(當(dāng)然GDI+也可以像你畫(huà)畫(huà)一樣只擦一部分)
GDI+時(shí)鐘我寫(xiě)過(guò)一個(gè)VB6的。代碼詳見(jiàn)我博客。地址顯然百度不讓貼上= =。所以你可以看下我的資料。
你可以模擬層,就是把所有繪制信息都保存起來(lái)。你的流程應(yīng)當(dāng)是:
如果要繪制了,更新繪制信息(可以是數(shù)組啥的。),交給一個(gè)Draw過(guò)程
Draw過(guò)程:根據(jù)繪制信息,全部繪制。
By vIstaswx ,before junior school graduation exam.
GDI繪圖用字體必須安裝才能使用
在客戶機(jī)部署應(yīng)用程序時(shí),安裝該字體就行