フォームの背景は半透明に文字は不透明に

タグの編集
投稿者 ラキシス  () 投稿日時 2008/10/24 03:09:56
可能なのかどうか分かりませんが、フォームの背景は半透明に文字は不透明にする事は可能でしょうか?
特定の色を半透明にするとか・・・

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Me.KeyPreview = True
        Me.Opacity = 0.5
        Me.BackColor = Color.Black
        Me.Size = New Size(300, 50)
    End Sub

    Private mousePoint As Point

    Private Sub Form1_MouseDown(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        If (e.Button And MouseButtons.Left) = MouseButtons.Left Then
            mousePoint = New Point(e.X, e.Y)
        End If
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
        If (e.Button And MouseButtons.Left) = MouseButtons.Left Then
            Me.Left += e.X - mousePoint.X
            Me.Top += e.Y - mousePoint.Y
        End If
    End Sub

    Private Sub Form1_KeyDown(ByVal sender As ObjectByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Debug.WriteLine(e.KeyCode)
        Select Case e.KeyCode.ToString
            Case "P"
                Dim g As Graphics = Me.CreateGraphics()
                Dim fnt As New Font("MS UI Gothic", 20)

                g.DrawString("これはテストです。", fnt, Brushes.White, 10, 10)  '←この文字は不透明にしたい 

                fnt.Dispose()
                g.Dispose()

            Case "Escape"
                Me.Close()

            Case Else
        End Select

    End Sub

End Class
投稿者 るしぇ  (社会人) 投稿日時 2008/10/24 04:50:35
TransparencyKey で特定の色を透明にはできるけど、
半透明は難しそう。

ものすごくトリッキーな方法として、半透明なフォームと
透明な文字だけフォームを表示して一緒に動かすとか。。。