1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | Imports System.Drawing.Imaging Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal pHdc As IntPtr, ByVal iX As Integer, ByVal iY As Integer, ByVal iWidth As Integer, ByVal iHeight As Integer, ByVal pHdcSource As IntPtr, ByVal iXSource As Integer, ByVal iYSource As Integer, ByVal dw As System.Int32) As Boolean Private Const SRC As Integer = &HCC0020 Private Sub ConvertLV2BMP(ByVal lvw As ListView, ByVal sFilePath As String) lvw.Refresh() lvw.Select() Dim g As Graphics = lvw.CreateGraphics Dim ibitMap As New Bitmap(lvw.ClientSize.Width, lvw.ClientSize.Height, g) Dim iBitMap_gr As Graphics = Graphics.FromImage(ibitMap) Dim iBitMap_hdc As IntPtr = iBitMap_gr.GetHdc Dim me_hdc As IntPtr = g.GetHdc 'PictureBox1.Image = ibitMap BitBlt(iBitMap_hdc, 0, 0, lvw.ClientSize.Width, lvw.ClientSize.Height, me_hdc, 0, 0, SRC) g.ReleaseHdc(me_hdc) iBitMap_gr.ReleaseHdc(iBitMap_hdc) If sFilePath = "" Then Exit Sub ibitMap.Save(sFilePath, ImageFormat.Bmp) End Sub |
2020年5月18日 星期一
vb.net ListView存成圖片(抓位置) [Listview export to Image]
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言