RSS Forums RSS
Please support our VB.NET advertiser: Programming Forums
Views: 9210 | Replies: 1 | Thread Tools  Display Modes
Reply
Join Date: Aug 2005
Posts: 13
Reputation: fieryidris is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
fieryidris's Avatar
fieryidris fieryidris is offline Offline
Newbie Poster

moving a form with no border

  #1  
Aug 23rd, 2005
i have been using the microsoft visual basic 2005 express edition beta which is my first attempt at doing anything with visual basic so it has been taking me a long time to learn myself how to do things - mainly by using google and also reading through all the posts on forums such as this one.
the thing i am completely stuck on though is that i would like to use a borderless form for the sake of being able to completely control the appearance of my program on the screen but realise that people would want to be able to move it about in the same way that msn messenger can be dragged around the screen using the mouse when the windowframe is hidden.
i have kept copying in different pieces of code from all sorts of websites below are just 2 examples but nothing i have tried works in the current program.
http://www.a1vbcode.com/snippet-316.asp
http://support.microsoft.com/kb/q173773/

does anyone know the solution to this? i will carry on trawling for answers but if someone knows a working set of bits of code i will be very grateful if they could tell me.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 13
Reputation: fieryidris is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
fieryidris's Avatar
fieryidris fieryidris is offline Offline
Newbie Poster

Re: moving a form with no border : solution

  #2  
Aug 30th, 2005
finally , after a whole week of looking , i've found something that works

http://www.planet-source-code.com/URLSEO/vb/scripts/ShowCode!asp/txtCodeId!3965/lngWId!10/anyname.htm

//**************************************
//
// Name: Most professional way of moving
// a borderless form without APIs and witho
// ut mouse pointer coordinates
// Description:Want to move a form by cl
// ick and dragging on the client area beca
// use your form is bordless/captionless? T
// his IS the way to do it at low level pro
// gramming without the use of APIs... full
// y .NET-wise.
// By: Rodolfo Gonzalez Ruiz
//
// Assumes:Basically the code uses the W
// ndProc and changes the window message to
// make it believe that you are clicking on
// the form/window title bar.
//
// Side Effects:User must click on the f
// orm client area, if a control is placed
// on top, clicking on it will not drag the
// window.
//
//This code is copyrighted and has // limited warranties.Please see http://
// www.Planet-Source-Code.com/vb/scripts/Sh
// owCode.asp?txtCodeId=3965&lngWId=10 //for details. //**************************************
//



'Place this code anywhere on your form code
#Region " ClientAreaMove Handling "
Const WM_NCHITTEST As Integer = &H84
Const HTCLIENT As Integer = &H1
Const HTCAPTION As Integer = &H2
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_NCHITTEST
MyBase.WndProc(m)
If m.Result = HTCLIENT Then m.Result = HTCAPTION
'If m.Result.ToInt32 = HTCLIENT Then m.Result = IntPtr.op_Explicit(HTCAPTION) 'Try this in VS.NET 2002/2003 if the latter line of code doesn't do it... thx to Suhas for the tip.
Case Else
'Make sure you pass unhandled messages back to the default message handler.
MyBase.WndProc(m)
End Select
End Sub
#End Region
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the VB.NET Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:59 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC