0

キオスク アプリケーションを作成しています。私はそれを全画面表示にして、フォームに直接描画しています:

Private Function CreateHeader(ByVal headerText As String) As Boolean
    Try
        Dim oGFX As Graphics = Graphics.FromHwnd(hwnd:=_oP.Handle)
        Dim oRect As Rectangle = New Rectangle(x:=0, y:=0, Width:=_screenSize.X, Height:=150)
        Dim oBMP As New Bitmap(GetEmbeddedResourceStream("Kiosk.logo.jpg"))

        Dim oBrush As Brush = New SolidBrush(Color.FromArgb(red:=0, green:=0, blue:=153))


        oGFX.FillRectangle(brush:=oBrush, rect:=oRect)
        oGFX.DrawImage(image:=oBMP, _
                           x:=0, _ 
                           y:=0, _
                       width:=oBMP.Width, _ 
                      height:=oBMP.Height)

        If Not String.IsNullOrEmpty(headerText) Then
            Dim oFont As New Font("Impact", 48, FontStyle.Regular)
            Dim g As Graphics = Me.CreateGraphics()

            Dim oStringSize As SizeF = g.MeasureString(headerText, oFont)

            g = Nothing

            oGFX.DrawString(s:=headerText, _
                         font:=oFont, _
                        brush:=Brushes.White, _
                            x:=(oRect.Width - Math.Round(oStringSize.Width, 0)) / 2, _
                            y:=(oRect.Height - Math.Round(oStringSize.Height, 0)) / 2)
        End If

        Return True
    Catch ex As Exception
        Return False
    End Try
End Function

すべてが正常に描画されますが、Alt または Tab を (個別に、または一緒に、任意の順序で) 2 番目に押すと、描画した四角形が消えます。関数をもう一度呼び出すと、どのボタンを押しても再描画されたままになります。呼び出す必要がある何らかの .NET 関数があるので、描画関数を 1 回だけ呼び出す必要がありますか?

ありがとう。

4

1 に答える 1

2

オーバーライドしてOnPaintペイントを行う必要があります。その後、必要に応じて再ペイントできます。現時点では、画面の下でのみ有効な描画は無効になっています。

于 2009-03-16T13:39:18.637 に答える