|
-
Mar 16th, 2001, 04:10 AM
#1
Thread Starter
Addicted Member
Hello all!
I have got a "small" question. I am writing a program in which the user can create his own interface. The user has to be able move en resize objects. The moving isn't the problem, but the resizing is. How can i automaticly show the resize mousicon whenn the pointer is on the objects border? Is it also possible to do the following :
The user clicks on a object. and he selects "edit" Then i want to show the square resize marks around the object. You know the ones at the corners and in de middle of the sides. Just like you get whenn u are using visualbasic and you are designing a form.
I hope somebody can help me!
Many thanks in advance,
Per
-
Mar 16th, 2001, 08:06 AM
#2
Hyperactive Member
Hi,
here is the way I was thinking of solving your problems:
resize-mousepointer:
check if the position of the mousepointer = object.top And > object.left and < object.left + object.width
do the same for the bottom, the left and right side of the object.
click edit botton:
draw a rectangle on every position,
form.line(object.top,object.left)-(object.top -5, object.left-5) ,,b
form.line(object.top,object.left+ (object.width /2) -2.5)-(object.top -5, object.left+ (object.width /2) +2.5
) ,,b
etc.
Sorry I haven't provided some code, but I also need to think about my weekend
-
Mar 16th, 2001, 08:26 AM
#3
Here is some code written by Aaron Young.
Add to a Module
Code:
Public Sub DragControl(ByRef oControl As Object, ByVal Button As Integer, ByVal X As Single, ByVal Y As Single, Optional ByVal bInit As Boolean, Optional ByVal bMoveable As Boolean, Optional ByVal bResizable As Boolean)
Static lXoff As Single, lYoff As Single, bSizing As Boolean
Dim bBoth As Boolean, bSized As Boolean
If bInit Then
If (Y > (oControl.Height - 150) Or X > (oControl.Width - 150)) And bResizable Then
bSizing = True
End If
lXoff = X
lYoff = Y
Exit Sub
End If
If bResizable Then
bBoth = True
If Y > (oControl.Height - 150) Then
oControl.MousePointer = vbSizeNS
Else
bBoth = False
End If
If X > (oControl.Width - 150) Then
oControl.MousePointer = IIf(bBoth, vbSizeNWSE, vbSizeWE)
Else
If Not bBoth Then oControl.MousePointer = vbDefault
End If
End If
If bResizable And bSizing Then
If Button = vbLeftButton Then
If (Y > (oControl.Height - 150) Or X > (oControl.Width - 150)) Then
bBoth = True
If Y > (oControl.Height - 150) Then
oControl.MousePointer = vbSizeNS
If Button = vbLeftButton Then
oControl.Height = oControl.Height + Y - lYoff
lYoff = oControl.Height
lXoff = oControl.Width
bSized = True
End If
Else
bBoth = False
End If
If X > (oControl.Width - 150) Then
oControl.MousePointer = IIf(bBoth, vbSizeNWSE, vbSizeWE)
If Button = vbLeftButton Then
oControl.Width = oControl.Width + X - lXoff
lYoff = oControl.Height
lXoff = oControl.Width
bSized = True
End If
End If
End If
Else
oControl.MousePointer = vbDefault
bSizing = False
End If
End If
If Not bSized And bMoveable And Not bSizing Then
If Button = vbLeftButton Then oControl.Move oControl.Left + X - lXoff, oControl.Top + Y - lYoff
End If
End Sub
Usage: (Add to a Form with a CommandButton)
Code:
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DragControl Command1, Button, X, Y, True, True, True
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
DragControl Command1, Button, X, Y, False, True, True
End Sub
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
|