FormBorderStyle=None, but I cant move my form around?

I searched, but I did not find what I was looking for..

Page 1 of 1

7 Replies - 9730 Views - Last Post: 12 February 2009 - 12:55 AM Rate Topic: -----

#1 jeffijoe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 11-February 09

FormBorderStyle=None, but I cant move my form around?

Posted 11 February 2009 - 03:44 AM

Heya all, Im new here. I just started VB.NET coding, and I think I come along quiet well. Offcourse, I get a few errors, but When googling it, I always come to dream.In.Code, so I thought I'd better register here.

Now, my problem is, that when I set FormBorderStyle to None, it looks so cool, but I cant move my form around in debug mode (Nor when launching my finished builded application)


Here is my whole Code in my application, as I dont know what parts I should post here:

Public Class Form1

	Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

		Dim start As String

		start = "This shows the server Staff. I want the names lined up in a column, just no idea how xD"

		MsgBox(start)

	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

		If FileIO.FileSystem.FileExists("cabalmain.exe") Then
			Dim p As Process = Process.Start("cabalmain.exe", "breaklee")
			p.WaitForExit()
		Else
			MsgBox("Could not find CabalMain.exe! Did you put this in your Cabal Folder?;)")
		End If
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

		Dim vote As String

		vote = "This will take you to the Vote Page, specified in the .ini ^^/>"

		MsgBox(vote)

	End Sub

	Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click



	End Sub

	Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

		WebBrowser1.Navigate("http://77.212.63.28/test/forum.txt")


	End Sub

	Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

		Dim start As String

		start = "This will show the rankings. The rankings are taken from the Database. By that, I mean that it takes the status from the DB. It goes after level, and Alz.;)"

		MsgBox(start)

	End Sub

	Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

		Dim start As String

		start = "This takes you to the donor page ^^/>"

		MsgBox(start)

	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

		Dim start As String

		start = "This takes you to the Server site, specified in the .ini :D"

		MsgBox(start)

	End Sub

	Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
		Dim p As New Process
		p.StartInfo.FileName = "iexplore.exe"
		p.StartInfo.Arguments = "http://forum.ragezone.com/members/jeffijoe-501677.html"
		p.Start()
	End Sub

	Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

		Application.Exit()

	End Sub

	Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
		Me.WindowState = FormWindowState.Minimized

	End Sub

	Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

		MsgBox("Welcome to the Jeffijoe Client, made by Jeffijoe, Owner of TriForCe Cabal. Look around on the Client to see all the functions. Everytime you move your mouse over a word, and it flashes, it have a function. Today find out on what it does, simply click it. The X button Exits the Client, and the _ will minimize it.")




	End Sub

	Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

	End Sub

	Private Sub Content_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Content.Click

		MsgBox("Click a button like Register, Rankings, or something, and the result will appear in the Web Browser under me :D																											Unless the server is offline, then you should get a navigation error;)")


	End Sub
End Class






Is This A Good Question/Topic? 0
  • +

Replies To: FormBorderStyle=None, but I cant move my form around?

#2 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: FormBorderStyle=None, but I cant move my form around?

Posted 11 February 2009 - 06:50 AM

i cannot take credit for this code it was pulled from planet source, but this should do the trick
	'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


Was This Post Helpful? 0
  • +
  • -

#3 jeffijoe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 11-February 09

Re: FormBorderStyle=None, but I cant move my form around?

Posted 11 February 2009 - 09:33 AM

View Postdklingman, on 11 Feb, 2009 - 05:50 AM, said:

i cannot take credit for this code it was pulled from planet source, but this should do the trick
	'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



Are you sure this is for VB.NET? :P

EDIT:

That did not work. Look:

Posted Image

This post has been edited by jeffijoe: 11 February 2009 - 10:11 AM

Was This Post Helpful? 0
  • +
  • -

#4 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: FormBorderStyle=None, but I cant move my form around?

Posted 11 February 2009 - 11:46 AM

what version of vb.net are you using this should work in 2005 and/or 2008. all i did was drop it into a form ran the app and was able to move the window around that did not have a border

This post has been edited by dklingman: 11 February 2009 - 11:57 AM

Was This Post Helpful? 0
  • +
  • -

#13 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: FormBorderStyle=None, but I cant move my form around?

Posted 11 February 2009 - 11:59 AM

You could use the mouse events of the Form to accomplish this (thus avoiding using Win32 API's). Something like this

Public Class Form1 
  Dim doDrag As Boolean   
  Dim x As Integer   
  Dim y As Integer  

  Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown  
	  doDrag = True
	  x = Windows.Forms.Cursor.Position.X - Me.Left
	  y = Windows.Forms.Cursor.Position.Y - Me.Top
  End Sub	   

  Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove 
	  If doDrag Then 
		  Me.Top = Windows.Forms.Cursor.Position.Y - y 
		  Me.Left = Windows.Forms.Cursor.Position.X - x 
	  End If
   End Sub	  

  Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp  
	  doDrag = False
  End Sub  
End Class 



Hope that helps :)
Was This Post Helpful? 1

#14 jeffijoe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 11-February 09

Re: FormBorderStyle=None, but I cant move my form around?

Posted 11 February 2009 - 01:05 PM

View PostPsychoCoder, on 11 Feb, 2009 - 10:59 AM, said:

You could use the mouse events of the Form to accomplish this (thus avoiding using Win32 API's). Something like this

Public Class Form1 
  Dim doDrag As Boolean   
  Dim x As Integer   
  Dim y As Integer  

  Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown  
	  doDrag = True
	  x = Windows.Forms.Cursor.Position.X - Me.Left
	  y = Windows.Forms.Cursor.Position.Y - Me.Top
  End Sub	   

  Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove 
	  If doDrag Then 
		  Me.Top = Windows.Forms.Cursor.Position.Y - y 
		  Me.Left = Windows.Forms.Cursor.Position.X - x 
	  End If
   End Sub	  

  Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp  
	  doDrag = False
  End Sub  
End Class 



Hope that helps :)


Sorry, it didnt. Maybe I coded it in the wrong place? I double clicked Form1. Is that right?

EDIT: I made it work, thanx. But it laggs quiet alot when I drag it around. Its like the content and buttons take alittle time before they drag along. Like Delay. Is that supposed to be? :D

EDIT2::

Uhm, when I select the Designer, I get this error:

Posted Image

What will I do now? I think its because I have 2 Puplic Class Codes, but I did not find any other way to inplement the code you gave me, anywhere else.
Hope you look at this post, because this is one of the last things that will finish my project :D

This post has been edited by jeffijoe: 11 February 2009 - 01:13 PM

Was This Post Helpful? 0
  • +
  • -

#15 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: FormBorderStyle=None, but I cant move my form around?

Posted 11 February 2009 - 02:29 PM

here's how mine is notice the code and the form. when i run this i have not lag zero.

Posted Image
Was This Post Helpful? 0
  • +
  • -

#16 jeffijoe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 11-February 09

Re: FormBorderStyle=None, but I cant move my form around?

Posted 12 February 2009 - 12:55 AM

Well I got it right. And by lagg, I mean when I drag it around. You know, move it. Might be cuz of the background and all the buttons I have.. xD

This post has been edited by jeffijoe: 12 February 2009 - 12:56 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1