Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2005

Tip: Looking for answers? Try searching our database.

Resize form w/out border

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ryan Joseph So - 13 Jan 2005 02:30 GMT
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?
Robby - 13 Jan 2005 08:34 GMT
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

> Hi,
>
[quoted text clipped - 4 lines]
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Ryan Joseph So - 14 Jan 2005 01:36 GMT
Thanks for the info.
Claes Bergefall - 13 Jan 2005 09:37 GMT
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

> Hi,
>
[quoted text clipped - 4 lines]
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Ryan Joseph So - 14 Jan 2005 01:35 GMT
Hi Claes,

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.