|
|
|
การทำให้ picturebox เป็น Transparen file .png VB2010 |
|
|
|
|
|
|
|
Code (VB.NET)
Imports System.Drawing
Imports System.Runtime.InteropServices
Public Class FrmPlanDesign
Const Nuppe As Integer = 100
Dim Nupud(Nuppe) As PictureBox
Dim Nupp As PictureBox
Dim i As Integer = 1
Private Sub FrmPlanDesign_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim c() As String = {"ต้นไม้", "พืช & ไม้พุ่ม", "ดอกไม้"} 'เลือกชนิดของสิ่งของต่างๆ
TSCBChangCat.Items.AddRange(c)
TSCBChangCat.SelectedIndex = 0
End Sub
Private Sub Nupp_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static mousePosX As Single, mousePosY As Single
Nupp.Cursor = Cursors.SizeAll
If e.Button = 0 Then
mousePosX = e.X
mousePosY = e.Y
Else
Nupp.Left = Nupp.Left + (e.X - mousePosX)
Nupp.Top = Nupp.Top + (e.Y - mousePosY)
End If
End Sub
Private Sub PBTree1_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree1_1.Click
Const PicWidth As Integer = 100 'กำหนดค่าความกว้างของภาพ
Const PicHeight As Integer = 100 'กำหนดค่าความสูงของภาพ
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree1_1.png") 'เลือก File ในไดร์
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove 'เลือก อีเวนต์ให้กับNupp
Nupud(i) = Nupp
i = i + 1
End Sub
Private Sub PBTree1_2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree1_2.Click
Const PicWidth As Integer = 200
Const PicHeight As Integer = 200
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.BackColor = Color.Transparent
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree1_2.png")
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove
Nupud(i) = Nupp
i = i + 1
End Sub
Private Sub PBTree2_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree2_1.Click
Const PicWidth As Integer = 100
Const PicHeight As Integer = 80
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree2_1.png")
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove
Nupud(i) = Nupp
i = i + 1
End Sub
Private Sub PBTree2_2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree2_2.Click
Const PicWidth As Integer = 200
Const PicHeight As Integer = 170
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.BackColor = Color.Transparent
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree2_2.png")
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove
Nupud(i) = Nupp
i = i + 1
End Sub
Private Sub PBTree3_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree3_1.Click
Const PicWidth As Integer = 100
Const PicHeight As Integer = 100
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.BackColor = Color.Transparent
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree3_1.png")
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove
Nupud(i) = Nupp
i = i + 1
End Sub
Private Sub PBTree3_2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree3_2.Click
Const PicWidth As Integer = 200
Const PicHeight As Integer = 200
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.BackColor = Color.Transparent
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree3_2.png")
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove
Nupud(i) = Nupp
i = i + 1
End Sub
Private Sub PBTree4_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree4_1.Click
Const PicWidth As Integer = 100
Const PicHeight As Integer = 100
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.BackColor = Color.Transparent
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree4_1.png")
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove
Nupud(i) = Nupp
i = i + 1
End Sub
Private Sub PBTree4_2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PBTree4_2.Click
Const PicWidth As Integer = 200
Const PicHeight As Integer = 200
Nupp = New PictureBox
Nupp.Parent = PanelDraw
Nupp.BackColor = Color.Transparent
Nupp.Image = Image.FromFile("E:\Project\PICTURE\OK\tree4_2.png")
Nupp.Size = New Size(PicWidth, PicHeight)
Nupp.SizeMode = PictureBoxSizeMode.StretchImage
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 1, Integer)
Nupp.Visible = True
AddHandler Nupp.MouseMove, AddressOf Nupp_MouseMove
Nupud(i) = Nupp
i = i + 1
End Sub
End Class
Tag : MySQL, VBScript, VS 2010 (.NET 4.x)
|
|
|
|
|
|
Date :
2012-03-16 10:19:09 |
By :
Kimlung |
View :
1078 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณค่ะ
|
|
|
|
|
Date :
2012-03-25 21:12:18 |
By :
kimlung |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|