[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

IN VB6 DURING RUNTIME MAKING IT POSSIBLE TO "MOVE" AND "RESIZE" A LABEL AND/OR TEXT.BOX ON SCREEN BY USER

How to create a function for the user to draw some boxes on a form, resize and move on his screen.
Then by a cmd-click save the info on the boxes he created to reshow after a restart
0
BIAPRO
Asked:
BIAPRO
1 Solution
 
SStoryCommented:
Well you can create a control array of labels. Then add them dynamically. I can't remember, but I believe you use the LOAD command. be sure to load it into the control array.  Use the Redim Preserve on that array to add them.

Next you can do the resize in various ways.  You can either make a control that handles resizing, or a class. Or use 8 other controls to be the resize handles.  When the user clicks on it you would take the show the top left one at the the top left of the label, for example, tlsizecontrol.top=label1.top-tlsizecontrol.height: tlsizecontrol.left=label1.left - tlsizecontrol.width.
Then divide the current width of the label and place the top middle sizer there, etc. If you like you can make custom cursors appear when they are dragging.  You will need to write code, such that if mousedown, they start dragging whichever of the 8 controls they are on.  Also you will want to resize the label based on the new position of these handles.  For moving it, it is a simple drag and drop type operation.  on Mouse Down, save and X,Y coord, on mouse move, change the label position based on some distance from the original x,y and the current X,Y.

I have done this in several programs. My favorite way is to create a class (in DOTNET), you could also do this in VB6.  The class gets a reference to the control it should offer resizing for.  The class must have handleMouseDown, HandleMouseMove and HandleMouseUp routines that can be called from the control that houses the labels(whether a picturebox or just the form). Then that class handles all of the drawing of the rectangles, by a method that the container can call from its paint event.

HTH,

Shane
0
 
DhaestCommented:
Implementing Drag-and-Drop in Visual Basic 6
http://www.devx.com/vb/Article/8029/1954?pf=true
0
 
456838Commented:
you can get more infor here. there will have article on the explainantion and some code sample for u

http://msdn2.microsoft.com/en-us/library/xz32ty04(VS.80).aspx

http://www.devx.com/vb/Article/7864
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Here is a very good start...
"Roll your own form designer"
http://www.vbthunder.com/
0
 
BIAPROAuthor Commented:
Yes this is doing it, thanks (again, due to I did get help from you in the past)
Regards Jack, and a nice weekend
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now