기타 [vb.net] 원문자 넣기 -> 한글 1자, 숫자 0~99, 영대 1자, 영소 2자
페이지 정보
본문
Private Sub TextBox3_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox3.KeyDown
If e.KeyCode <> 13 Then Return
Dim P As New PictureBox
P.Size = New Size(50, 50)
P.BackColor = Color.Transparent
Dim bmp As Bitmap = New Bitmap(P.Width, P.Height)
bmp.MakeTransparent()
Dim G As Graphics = Graphics.FromImage(bmp) '// P.CreateGraphics()
Dim drawString As String = TextBox3.Text
Dim drawFont As Font = New Font("맑은 고딕", 22, FontStyle.Bold)
Dim drawBrush As SolidBrush = New SolidBrush(Color.Red)
Dim x As Single = 1.0F, y As Single = 1.0F
Dim drawFormat As StringFormat = New StringFormat()
drawFormat.FormatFlags = TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter Or TextFormatFlags.WordBreak
drawFormat.Alignment = StringAlignment.Center
Dim drawRect As New RectangleF(x, y + 3, P.Width - (x * 2), P.Height - (y * 2))
G.DrawString(drawString, drawFont, drawBrush, drawRect, drawFormat)
Dim rect As Rectangle = New Rectangle(1, 1, P.Width - 4, P.Height - 4)
Dim myPen As Pen = New Pen(Color.Red, 4)
G.DrawEllipse(myPen, rect)
P.Location = New Point(25, 25)
picCanvas.Controls.Add(P)
P.BringToFront() : P.Visible = True : P.Enabled = True
P.Image = bmp
AddHandler P.MouseDown, Sub(ByVal pic As PictureBox, ByVal pMe As MouseEventArgs)
Dim mx = Control.MousePosition.X - pic.Location.X
Dim my = Control.MousePosition.Y - pic.Location.Y
pic.Tag = New Point(mx, my)
End Sub
AddHandler P.MouseMove, Sub(ByVal pic As PictureBox, ByVal pMe As MouseEventArgs)
If pMe.Button = Windows.Forms.MouseButtons.Left Then
Dim startPoint As Point = DirectCast(pic.Tag, Point)
Dim mPoint As Point = Control.MousePosition
mPoint.X -= startPoint.X
mPoint.Y -= startPoint.Y
pic.Location = mPoint
End If
End Sub
AddHandler P.MouseUp, Sub(ByVal pic As PictureBox, ByVal pMe As MouseEventArgs)
End Sub
AddHandler P.MouseDoubleClick, Sub(ByVal pic As PictureBox, ByVal pMe As MouseEventArgs)
pic.Parent.Controls.Remove(pic)
End Sub
End Sub
- 이전글[vb.net] Thread Example 22.09.08
- 다음글[VB.NET] 윈도우 프로그램과 폼안의 객체만 따로 캡쳐하기 22.09.06
댓글목록
등록된 댓글이 없습니다.