| 07 | ¦p¦ó·j´M¬Y¸ô®|¤Uªº©Ò¦³°ÆÀɦW(§t©Ò¦³¤l¥Ø¿ý) |
|
¡@ |
'©ñ¤@Ólistbox©Mbutton...
Public Class Form1 |
| 06 | °½¤Ñ´«¤é-§âPropertyGrid¤¤ImageÄݩʪº[¡K]´«¦¨¦Ûqªº«ö¶s |
| ¡@ |
'¥ÎAPI»\¦í image [...]ªº¤è¦¡ 'PictureBox,PropertyGrid,Button,Timer ¦U¤@Ó Public Class Form1 Structure RECT Public Left As Integer Public Top As Integer Public Right As Integer Public Bottom As Integer End Structure Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Integer, ByVal lpClassName As String, ByVal nMaxCount As Integer) As Integer Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Integer) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '쥻¼g¦b³o¶}ÀÉ,¦ý·|³Qfocus¤Á´«¼vÅT...¬G§ï¦ÜMouseDown End Sub Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown Dim OPF As New OpenFileDialog OPF.Filter = "¹ÏÀÉ|*.gif;*.jpg;*.bmp;*.png" If OPF.ShowDialog = DialogResult.OK Then PictureBox1.ImageLocation = OPF.FileName '¸ü¤J¹Ï§Î PropertyGrid1.SelectedObject = PictureBox1 '«¸ü§ó·s (.refresh ¦n¹³¨S¥Î~@@) End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True : Timer1.Interval = 100 With Button1 .Visible = False .BackColor = Color.Red .Size = New Size(17, 17) .Text = "¡K" End With End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim rect1 As RECT Dim aWnd As Integer = Me.Handle 'ªí³æ Static v As Integer If PropertyGrid1.SelectedGridItem.Label = "Image" Then '¦pªG¿ï¦b image ÄݩʤW Dim bWnd As Integer = FindWindowEx(aWnd, 0, vbNullString, "PropertyGrid") '§ä¨ìPropertyGrid Dim cWnd As Integer = FindWindowEx(bWnd, 0, vbNullString, "PropertyGridView") '§ä¨ìPropertyGrid¤º®e°Ï Dim lpClassName As String = Space$(256) GetClassName(cWnd, lpClassName, 256) Dim lpClassName1 As String = Split(lpClassName, "app")(1) '¨ú±oªí³æ«á½s¸¹...§ä[...]®É¦³¥Î¨ì! Dim dWnd As Integer = FindWindowEx(cWnd, 0, "WindowsForms10.BUTTON.app" & lpClassName1, vbNullString) If dWnd <> 0 Then If IsWindowVisible(dWnd) Then '¬O¤£¬O¦b¥i¨£½d³ò¤º Call GetWindowRect(dWnd, rect1) '¨ú±o¦ì¸m½d³ò Dim brd As Integer = (Me.Width - Me.ClientRectangle.Width) / 2 'n¦©°£ªºªí³æÃ䮨 Button1.Location = New Point(rect1.Left - Me.Left - brd - 1, rect1.Top - Me.Top - (Me.Height - Me.ClientRectangle.Height - brd) - 1) Button1.BringToFront() Button1.Visible = True v = 0 Else v = v + 1 If v = 2 Then Button1.Visible = False : v = 0 '§PÂ_¨ì2¦¸ ¤~½T©wÁôÂÃ!(쥻ªº[...]¦³ÂI¿ð¶w...nµ¥¥¦¤@¤U!) End If Else Button1.Visible = False End If Else Button1.Visible = False End If End Sub Private Sub PropertyGrid1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles PropertyGrid1.GotFocus Timer1.Enabled = True '±o¨ì¾nÂI¤~°Ê End Sub Private Sub PropertyGrid1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles PropertyGrid1.LostFocus Timer1.Enabled = False End Sub End Class |
|
¹Ï§Îªº±ÛÂà»PÁY©ñ |
|
|
¡@ |
'·Æ°Ê·Æ¹«ºu½üÁY©ñ¤j¤p¡A«ö¦íF1¦A·Æºu½ü(¥i«e¡B«áºu)±ÛÂà¹Ï¤ù Public Class Form1 Dim img1 As Image, imgS As Image Const PI = 3.14159265 Dim k As Boolean Dim ang As Integer '¥Ø«eªº¨¤«× Dim dang As Integer = 5 '¨C¦¸±ÛÂ઺¨¤«× Dim dsize As Integer = 1 '¨C¦¸ÁY©ñªº®tÈ Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDownIf e.KeyCode = Keys.F1 Then k = True End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUpIf e.KeyCode = Keys.F1 Then k = False End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadMe.KeyPreview = True '±µ¦¬Áä½L 'PictureBox1 ¦Û¦æ¸ü¤J§A¦Û¤vªº¹ÏPictureBox1.SizeMode = PictureBoxSizeMode.StretchImage '³]¬°¥iÁY©ñimgS = PictureBox1.Image '¼È¦sì¹Ï End Sub Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel'ÁY©ñ If e.Delta > 0 And k = False Then PictureBox1.Size = PictureBox1.Size.Add(PictureBox1.Size, New Size(dsize, dsize))If e.Delta < 0 And k = False Then PictureBox1.Size = PictureBox1.Size.Subtract(PictureBox1.Size, New Size(dsize, dsize)) '±ÛÂà If e.Delta > 0 And k = True Then ang = (ang + dang) Mod 360 : PictureBox1.Image = Rotate(imgS, ang)If e.Delta < 0 And k = True Then ang = (ang - dang) Mod 360 : PictureBox1.Image = Rotate(imgS, ang) End Sub Public Function Rotate(ByVal imgSource As Image, ByVal degree As Integer) As Imagedegree = degree Mod 360 If degree < 0 Then degree = 360 + degree If imgSource Is Nothing Then Return Nothing Dim ImgTarget As Image = Nothing Try Select Case degreeCase 0 To 89 ImgTarget = Rotate0_90(imgSource, degree) Case 90 To 179 ImgTarget = Rotate90_180(imgSource, degree) Case 180 To 269 ImgTarget = Rotate180_270(imgSource, degree) Case 270 To 359 ImgTarget = Rotate270_360(imgSource, degree) End Select Catch End Try Return ImgTargetEnd Function Private Function Rotate0_90(ByVal img As Image, ByVal degree As Integer) As ImageDim ImgTarget As Bitmap Dim alpha As Double = (degree / 180) * PI Dim iWidth As Integer = img.Width * Math.Cos(alpha) + img.Height * Math.Sin(alpha) Dim iHeight As Integer = img.Width * Math.Sin(alpha) + img.Height * Math.Cos(alpha) ImgTarget = New Bitmap(iWidth, iHeight, Drawing.Imaging.PixelFormat.Format24bppRgb) Dim g As Graphics g = Graphics.FromImage(ImgTarget) g.TranslateTransform(img.Height * Math.Sin(alpha), 0) g.RotateTransform(degree) g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height))Return ImgTarget End Function Private Function Rotate90_180(ByVal img As Image, ByVal degree As Integer) As ImageDim ImgTarget As Bitmap Dim alpha As Double = ((degree - 90) / 180) * PI Dim iHeight As Integer = img.Width * Math.Cos(alpha) + img.Height * Math.Sin(alpha) Dim iWidth As Integer = img.Width * Math.Sin(alpha) + img.Height * Math.Cos(alpha) ImgTarget = New Bitmap(iWidth, iHeight, Drawing.Imaging.PixelFormat.Format24bppRgb) Dim g As Graphics g = Graphics.FromImage(ImgTarget) g.TranslateTransform(iWidth, img.Height * Math.Sin(alpha)) g.RotateTransform(degree) g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height))Return ImgTarget End Function Private Function Rotate180_270(ByVal img As Image, ByVal degree As Integer) As ImageDim ImgTarget As Bitmap Dim alpha As Double = ((degree - 180) / 180) * PI Dim iWidth As Integer = img.Width * Math.Cos(alpha) + img.Height * Math.Sin(alpha) Dim iHeight As Integer = img.Width * Math.Sin(alpha) + img.Height * Math.Cos(alpha) ImgTarget = New Bitmap(iWidth, iHeight, Drawing.Imaging.PixelFormat.Format24bppRgb) Dim g As Graphics g = Graphics.FromImage(ImgTarget) g.TranslateTransform(img.Width * Math.Cos(alpha), iHeight) g.RotateTransform(degree) g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height))Return ImgTarget End Function Private Function Rotate270_360(ByVal img As Image, ByVal degree As Integer) As ImageDim ImgTarget As Bitmap Dim alpha As Double = ((degree - 270) / 180) * PI Dim iHeight As Integer = img.Width * Math.Cos(alpha) + img.Height * Math.Sin(alpha) Dim iWidth As Integer = img.Width * Math.Sin(alpha) + img.Height * Math.Cos(alpha) ImgTarget = New Bitmap(iWidth, iHeight, Drawing.Imaging.PixelFormat.Format24bppRgb) Dim g As Graphics g = Graphics.FromImage(ImgTarget) g.TranslateTransform(0, img.Width * Math.Cos(alpha)) g.RotateTransform(degree) g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height))Return ImgTarget End Function End Class |
|
¦p¦ó°õ¦æTextBoxùتº¹Bºâ¦¡? |
|
|
¡@ |
Public Class Form1 |
|
¦p¦ó¨ú±o©Ò¦³°õ¦æ¤¤ªºµ{§Ç? |
|
|
¡@ |
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For Each i As Process In Process.GetProcesses '¨ú±o©Ò¦³°õ¦æ¤¤ªºµ{§Ç Debug.Print(i.ProcessName & vbTab & i.Id) 'If i.ProcessName = "notepad" Then i.Kill() '¦pªG¦³µ§°O¥»«hÃö³¬¥¦ Next End SubEnd Class |
|
¦p¦ó§ì·í¤U®y¼ÐªºI´ºÃC¦â? |
|
|
¡@ |
Public Class Form1 Dim g As Graphics, b As Bitmap Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove b = PictureBox1.BackgroundImage Debug.Print(Hex(b.GetPixel(e.X, e.Y).R) & " " & Hex(b.GetPixel(e.X, e.Y).G) & " " & Hex(b.GetPixel(e.X, e.Y).B))End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMoveb = Me.BackgroundImage Debug.Print(Hex(b.GetPixel(e.X, e.Y).R) & " " & Hex(b.GetPixel(e.X, e.Y).G) & " " & Hex(b.GetPixel(e.X, e.Y).B)) End Sub ¡@ '¥H¤U¯Â¬°µe¤@¨ÇªFªF¦n´ú¸Õ...®M¥Î®É½Ð¦Û©¿²¤~ Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadPictureBox1.BackColor = Color.Black : PictureBox1.Location = New Point(100, 100) PictureBox1.Size = New Size(100, 100) : PictureBox1.BackgroundImage = New Bitmap(100, 100) g = System.Drawing.Graphics.FromImage(PictureBox1.BackgroundImage) g.DrawLine(Pens.Blue, 0, 0, 50, 50) : g.DrawLine(Pens.Red, 100, 0, 0, 100) Me.BackgroundImage = New Bitmap(1024, 768) g = System.Drawing.Graphics.FromImage(Me.BackgroundImage) g.FillRectangle(Brushes.Yellow, New Rectangle(0, 0, 100, 100))g.FillRectangle(Brushes.Green, New Rectangle(0, 0, 50, 50)) End Sub End Class |
|
¼³§JµP¶Ã¼ÆµoµP-§tªá¦â |
|
|
¡@ |
Public Class Form1 µ²ªG:
12♦ 11♦ 6♣ 1♣ 13♠ 3♦ 9♠ 10♥ 4♣ 10♠ 8♠ 5♦ 5♣ ¡@ |