I have a form which its FormBorderStyle property is set To NONE. My
problem is during run-time I can't resize it using my mouse. Is there a
way to resize it by not changing its FormBorderStyle suring run-time?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Robby
"Ryan Joseph So" <achill...@hotmail.com> wrote in message
news:%23xMFhfR%23EHA...@tk2msftngp13.phx.gbl...
Private Const HTCAPTION As Integer = 2
Private Const HTLEFT As Integer = 10
Private Const HTRIGHT As Integer = 11
Private Const HTTOP As Integer = 12
Private Const HTTOPLEFT As Integer = 13
Private Const HTTOPRIGHT As Integer = 14
Private Const HTBOTTOM As Integer = 15
Private Const HTBOTTOMLEFT As Integer = 16
Private Const HTBOTTOMRIGHT As Integer = 17
Private Const WM_NCHITTEST As Integer = &H84
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_NCHITTEST Then
Dim pt As New Point(m.LParam.ToInt32)
pt = Me.PointToClient(pt)
If pt.X < 5 AndAlso pt.Y < 5 Then
m.Result = New IntPtr(HTTOPLEFT)
ElseIf pt.X > (Me.Width - 5) AndAlso pt.Y < 5 Then
m.Result = New IntPtr(HTTOPRIGHT)
ElseIf pt.Y < 5 Then
m.Result = New IntPtr(HTTOP)
ElseIf pt.X < 5 AndAlso pt.Y > (Me.Height - 5) Then
m.Result = New IntPtr(HTBOTTOMLEFT)
ElseIf pt.X > (Me.Width - 5) AndAlso pt.Y > (Me.Height - 5) Then
m.Result = New IntPtr(HTBOTTOMRIGHT)
ElseIf pt.Y > (Me.Height - 5) Then
m.Result = New IntPtr(HTBOTTOM)
ElseIf pt.X < 5 Then
m.Result = New IntPtr(HTLEFT)
ElseIf pt.X > (Me.Width - 5) Then
m.Result = New IntPtr(HTRIGHT)
Else
MyBase.WndProc(m)
End If
Else
MyBase.WndProc(m)
End If
End Sub
Change the coordinates to something that is appropriate for you
(the code above uses a "border" that is 5 pixels wide)
If you want to be able to drag the window you can return HTCAPTION
/claes
"Ryan Joseph So" <achill...@hotmail.com> wrote in message
news:#xMFhfR#EHA....@tk2msftngp13.phx.gbl...
Thank you very much for the quick reply and for the codes. This is all I
need.