Google Grupper har inte längre stöd för nya Usenet-inlägg eller -prenumerationer. Historiskt innehåll förblir synligt.
Stäng

Resize form w/out border

404 visningar
Hoppa till det första olästa meddelandet

Ryan Joseph So

oläst,
12 jan. 2005 21:30:412005-01-12
till
Hi,

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

oläst,
13 jan. 2005 03:34:292005-01-13
till

I think you will have to write your own resize handler using Form.MouseDown
and Form.MouseUp events. On MouseDown you can check if the mouse is in a
corner of the form and save its screen position. On MouseUp you can compare
the mouse's current screen position with the MouseDown positon and resize
the form accordingly.

Robby

"Ryan Joseph So" <achill...@hotmail.com> wrote in message
news:%23xMFhfR%23EHA...@tk2msftngp13.phx.gbl...

Claes Bergefall

oläst,
13 jan. 2005 04:37:042005-01-13
till
Something like this will do it:

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...

Ryan Joseph So

oläst,
13 jan. 2005 20:35:572005-01-13
till
Hi Claes,

Thank you very much for the quick reply and for the codes. This is all I
need.

Ryan Joseph So

oläst,
13 jan. 2005 20:36:032005-01-13
till
Thanks for the info.
0 nya meddelanden