これが機能するには、bitmaps
とpicturebox
の2つが必要です。ピクチャを表示する
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
サブ:
形態負荷イベントに
Private pngImage, picBoxImage As Image
2つのイメージを初期化:最初のものはpicturebox
画像がpng
画像および第2ものです
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
@マークス私はそれを保持するコントロールに画像をペイントする理由は、透明ではないので、私は画像ボックスを使用する場合。私の場合、txtboxとラベルは画像をカバーしています。私はちょうどそれをペイントし、おそらくグループボックスの中のgropboxと他のコントロールの前にそれを送ろうとします – Muj
私が考えることができる2つの解決策があります。 1.レイヤードウィンドウを作成し、コントロールの上に表示します。2.画像が表示される部分のスクリーンショットを撮り、picboxに描画してから、 –