タイトル | : Re^7: フォームの境界線を消す |
記事No | : 8372 |
投稿日 | : 2008/10/23(Thu) 16:46 |
投稿者 | : kan |
> 一体どうしたいのかな? > どうぞお好きなように。
好きなようにしたらできました。
とはいうのは冗談で。 下記のようにしてみました。 長くなるので、ドラッグアンドドロップでのフォームの移動は割愛。 とりあえず動いてる。
Public Class Form1 Private Const WS_EX_TOOLWINDOW As Integer = &H80 Private Const WS_EX_CLIENTEDGE As Integer = &H200 Private Const WS_EX_WINDOWEDGE As Integer = &H100 Protected Overrides ReadOnly Property CreateParams() As CreateParams Get Dim cp As CreateParams = MyBase.CreateParams cp.ExStyle = cp.ExStyle Or WS_EX_TOOLWINDOW Return cp End Get End Property
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Text = String.Empty Me.ControlBox = False Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None Me.ShowInTaskbar = False End Sub
#Region "フォームサイズ変更関連" ''www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=38887&forum=7&start=8
Private Const WM_NCHITTEST As Integer = &H84 Private Const HTERROR = (-2) Private Const HTTRANSPARENT = (-1) Private Const HTNOWHERE = 0 Private Const HTCLIENT = 1 Private Const HTCAPTION = 2 Private Const HTSYSMENU = 3 Private Const HTGROWBOX = 4 Private Const HTSIZE = HTGROWBOX Private Const HTMENU = 5 Private Const HTHSCROLL = 6 Private Const HTVSCROLL = 7 Private Const HTMINBUTTON = 8 Private Const HTMAXBUTTON = 9 Private Const HTLEFT = 10 Private Const HTRIGHT = 11 Private Const HTTOP = 12 Private Const HTTOPLEFT = 13 Private Const HTTOPRIGHT = 14 Private Const HTBOTTOM = 15 Private Const HTBOTTOMLEFT = 16 Private Const HTBOTTOMRIGHT = 17 Private Const HTBORDER = 18 Private Const HTREDUCE = HTMINBUTTON Private Const HTZOOM = HTMAXBUTTON Private Const HTSIZEFIRST = HTLEFT Private Const HTSIZELAST = HTBOTTOMRIGHT
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case m.Msg Case WM_NCHITTEST Dim p As Point p = Me.PointToClient(New Point(m.LParam.ToInt32 Mod 65536, m.LParam.ToInt32 \ 65536))
If p.X > Me.ClientRectangle.Right Then Exit Select If p.X < Me.ClientRectangle.Left Then Exit Select If p.Y < Me.ClientRectangle.Top Then Exit Select If p.Y > Me.ClientRectangle.Bottom Then Exit Select
If p.X < Me.ClientRectangle.Left + 5 Then If p.Y < Me.ClientRectangle.Top + 5 Then m.Result = HTTOPLEFT Exit Sub End If If p.Y > Me.ClientRectangle.Bottom - 5 Then m.Result = HTBOTTOMLEFT Exit Sub End If m.Result = HTLEFT Exit Sub End If If p.X > Me.ClientRectangle.Right - 5 Then If p.Y < Me.ClientRectangle.Top + 5 Then m.Result = HTTOPRIGHT Exit Sub End If If p.Y > Me.ClientRectangle.Bottom - 5 Then m.Result = HTBOTTOMRIGHT Exit Sub End If m.Result = HTRIGHT Exit Sub End If If p.Y < Me.ClientRectangle.Top + 5 Then m.Result = HTTOP Exit Sub End If If p.Y > Me.ClientRectangle.Bottom - 5 Then m.Result = HTBOTTOM Exit Sub End If End Select MyBase.WndProc(m) End Sub
#End Region
End Class
|