 |
|
ผมลองใช้วิธีนี้
https://www.thaicreate.com/dotnet/forum/074113.html
Code (VB.NET)
Public Class Form1
Private m_Drawing As Boolean = False
Private m_LastPoint As Point = Nothing
' เมื่อกดเมาส์ลงจะเริ่มวาดภาพครับและจะทำการจดจำพิกัดของเมาส์ไปในตัวครับ.
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
Me.MouseDown
m_Drawing = True
m_LastPoint = New Point(e.X, e.Y)
Dim gr As Graphics = Me.CreateGraphics()
End Sub
'จากนั้นเมื่อเมาส์เคลื่อนที่ก็จะทำการวาดอีกครั้ง.
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
Me.MouseMove
If Not m_Drawing Then Exit Sub
Dim gr As Graphics = Me.CreateGraphics()
gr.DrawLine(Pens.Blue, m_LastPoint, New Point(e.X, e.Y))
m_LastPoint = New Point(e.X, e.Y)
End Sub
' เมื่อปล่อยเมาส์จะหยุดวาดทันที.
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
Me.MouseUp
m_Drawing = False
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim gr As Graphics = Me.CreateGraphics()
gr.Clear(Me.BackColor)
End Sub
End Class
Code (VB.NET) คลิกปุ่ม เซฟ Form1 เป็นรูป
Dim bmp As New Bitmap(Form1.Width, Panel1.Height)
Form1.DrawToBitmap(bmp, New Rectangle(0, 0, Form1.Width, Form1.Height))
bmp.Save("D:\TestSing.jpg")
มัน เซฟ ฟอรม์เป็นภาพได้ แต่ เวลาวาดเขียน ลงบนฟอร์ม มันไม่ขึ้น ลายเส้นที่เราลากเมสร์ครับ มันเอาแต่ ฟอร์มเปล่ามามาเป็นรูป
ต้องปรับตรงไหนหรอครับ
|
ประวัติการแก้ไข 2013-07-15 08:34:54
 |
 |
 |
 |
Date :
2013-07-15 08:27:46 |
By :
ang89gunner |
|
 |
 |
 |
 |
|
|
 |