|
-
Jul 27th, 2008, 09:31 PM
#1
Thread Starter
Hyperactive Member
Problem with dragging borderless window?
Hi everyone,
I have a borderless window and picturebox GUI, I'm trying to drag the window from it's handles. My code outputs no errors, but it doesn't work either... Any ideas?
Form = frmMain
Picturebox = Image1
Code:
Private Sub Image1_Click()
Public Class frmMain
Private mouseOffset As Point
Private isMouseDown As Boolean = False
Private Sub Image1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Image1.MouseDown
Dim xOffset As Integer
Dim yOffset As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
xOffset = -e.x - SystemInformation.FrameBorderSize.Width
yOffset = -e.y - SystemInformation.FrameBorderSize.Height
mouseOffset = New Point(xOffset, yOffset)
isMouseDown = True
End If
End Sub
Private Sub Image1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Image1.MouseMove
If isMouseDown Then
Dim mousePos As Point = Control.MousePosition
mousePos.Offset(mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
Private Sub Image1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Image1.MouseUp
isMouseDown = False
End Sub
End Class
End Sub
-
Jul 27th, 2008, 11:22 PM
#2
Re: Problem with dragging borderless window?
Your code doesn't look like it's a correct format for VB6. Also, I see a Private Sub, Image1_MouseDown, within a Private Sub, Image1_Click and you are telling us you get no errors?
Your code.....
Code:
Private Sub Image1_Click()
Public Class frmMain
Private mouseOffset As Point
Private isMouseDown As Boolean = False
Private Sub Image1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Image1.MouseDown
'
'
'
-
Jul 27th, 2008, 11:26 PM
#3
Thread Starter
Hyperactive Member
Re: Problem with dragging borderless window?
I wasn't getting errors upon just starting it from VB6, but when I went to make an EXE it did give errors.
Do you know how I could get this working?
-
Jul 27th, 2008, 11:44 PM
#4
Re: Problem with dragging borderless window?
That's hard to believe. Just simply because you have a Sub within a Sub would cause a syntax error from VB6 not to mention the Class statement.
I don't think this is a VB6 project. Perhaps it is a VB.Net project?
-
Jul 28th, 2008, 01:24 AM
#5
Thread Starter
Hyperactive Member
Re: Problem with dragging borderless window?
I know it seems hard to believe but for whatever reason it was operating without error. Lol. I got the original code from the MSDN boards, but it was in the VB6 section.
And yes I am using VB6. Do you know how I could go about this?
-
Jul 28th, 2008, 09:43 AM
#6
Lively Member
Re: Problem with dragging borderless window?
This is code for dragging the form
Code:
Option Explicit
Dim xx As Single, yy As Single
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> vbLeftButton Then Exit Sub
Me.Left = Me.Left + ((X - xx) / 15)
Me.Top = Me.Top + ((Y - yy) / 15)
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
-
Jul 28th, 2008, 09:56 AM
#7
Lively Member
Re: Problem with dragging borderless window?
this is the code for the form and picturebox
Sorry, I am too busy to refine the code but it works
Code:
Option Explicit
Dim xx As Single, yy As Single
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> vbLeftButton Then Exit Sub
Me.Left = Me.Left + ((X - xx) / 15)
Me.Top = Me.Top + ((Y - yy) / 15)
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> vbLeftButton Then Exit Sub
Me.Left = Me.Left + (X - xx) / 15
Me.Top = Me.Top + (Y - yy) / 15
End Sub
Last edited by Amr Al-Amir; Jul 28th, 2008 at 10:03 AM.
-
Jul 28th, 2008, 10:34 PM
#8
Thread Starter
Hyperactive Member
Re: Problem with dragging borderless window?
Works perfect! only required small amount of change, very good.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|