이 작업을 수행하려면 bitmaps
과 picturebox
이 필요합니다.
다음 PictureBox를 보여
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
pngImage = Image.FromFile(FOLDER_PATH & "\completed.png") //load it once
picBoxImage = CType(pngImage.Clone, Image)
PictureBox1.Size = New Size(CInt(463/2), CInt(242/2))
PictureBox1.Parent = GroupBox6
PictureBox1.Image = picBoxImage
PictureBox1.Visible = False //you dont want it at the beggining
End Sub
서브 :
형태 Load 이벤트
Private pngImage, picBoxImage As Image
두 이미지를 초기화 : 첫 번째는 png
이미지와 상기 제 하나 picturebox
이미지
Private Sub ShowCompletedMessage()
Dim screenLocation As Point
Dim gr As Graphics
//you can pass these values as parameters in the sub if you want to make the code more generic
Dim x As Integer = CInt(((GroupBox6.Width/2) - (463/4)))
Dim y As Integer = 10
Dim width As Integer = CInt(463/2)
Dim height As Integer = CInt(242/2)
//Ensure that picturebox is not visible. If it is you don't need to take a screenshot
If PictureBox1.Visible = True Then
Return
End If
gr = Graphics.FromImage(picBoxImage)
//you need to transform the coordinates to screen ones
screenLocation = GroupBox6.PointToScreen(New Point(x, y))
//draw the portion of the screen to your bitmap
gr.CopyFromScreen(screenLocation.X, screenLocation.Y, 0, 0, New Size(width, height), CopyPixelOperation.SourceCopy)
//draw the png image on top
gr.DrawImage(pngImage, 0, 0, width, height)
PictureBox1.Location = New Point(x, y)
PictureBox1.BringToFront()
PictureBox1.Visible = True
gr.Dispose()
gr = Nothing
Return
End Sub
메시지를 표시하고 싶을 때마다 위의 하위 메뉴를 호출하십시오. 당신은 언제 어디에서 결정합니다. 당신은 당신이 더 이상 필요하지 않은 경우 picturebox
을 숨길 필요가
PictureBox1.Visible = False
당신은 사용자가 프로세스를 완료 할 때 오버레이로 이미지를 표시하고 기본 컨트롤을 숨기시겠습니까? 그룹 박스에서 이미지를 그리는 대신 상태가 "취소됨"일 때 Groupbox 대신 표시되는 PictureBox 컨트롤을 사용하는 것이 더 쉽다고 생각합니다. – Markus
@ Markus 그림 상자를 사용하면 투명하지 않기 때문에 이미지를 컨트롤에 붙이면됩니다. 하지만 제 경우에는 txtbox와 레이블이 이미지를 덮고 있습니다. 나는 페인트 칠을하고 그룹 박스 안의 gropbox와 다른 컨트롤의 앞쪽으로 보내고 싶습니다. – Muj
제가 생각할 수있는 두 가지 해결책이 있습니다. 1. 레이어 된 윈도우를 만들고 컨트롤 위에 표시합니다. 2. 이미지가 나타날 부분의 스크린 샷을 찍은 다음 picbox에 그려넣고 png 이미지 –