How best to move a control

Post

Posted
Rating:
#1 (In Topic #209)
Regular
bill-lancaster is in the usergroup ‘Regular’
 I want to click on a label control and move it to a different position on a form, just the way it happens in the IDE.
I've tried a few things but the result is rather jerky.
Any suggestions welcome.
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
…a little code:

Code (gambas)

  1.  
  2.  
  3. Public Sub Form_Open()
  4.  
  5.   With Label1 = New Label(Me) As "Label1"
  6.     .X = 100
  7.     .Y = 100
  8.     .W = 30
  9.     .H = 30
  10.     .Background = Color.Orange
  11.  
  12.  
  13.  
  14. Public Sub Label1_MouseDown()
  15.  
  16.   spx = Mouse.X
  17.   spy = Mouse.Y
  18.  
  19.  
  20.  
  21. Public Sub Label1_MouseMove()
  22.  
  23.   With Label1
  24.     .X = .X + Mouse.X - spx
  25.     .Y = .Y + Mouse.Y - spy
  26.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
bill-lancaster is in the usergroup ‘Regular’
 Thank you very much  vuott.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
 Hi Bill,
Now that vuott has provided a good solution…..
Just out of curiosity, why do you want to move a label ?

Cheers - Quin.
I code therefore I am
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
bill-lancaster is in the usergroup ‘Regular’
 Good question!
I've made a simple family tree project.  Sometimes there are more siblings (name etc shown in a label) than will fit across the screen so by moving the labels left or right enables all of the siblings to be viewed.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
 Hi Bill,
You could put the view object where you create your family tree in a scroll view control and in that way you could just have a 'static' tree drawn and the user could just scroll the contents.
Would be interested in seeing the code when you finished as I would be interested in seeing how you handled the data relationship management.

Also I discovered that there is a 'move' procedure in some controls now.
I don't remember it being there but was not specifically looking for it either.
It allows a move with an optional resize which is cool.

From the Gambas wiki:…
Control.Move (gb.qt4)
Sub Move ( X As Integer, Y As Integer [ , Width As Integer, Height As Integer ] )
Moves and/or resizes the control.

Cheers - Quin.
I code therefore I am
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
bill-lancaster is in the usergroup ‘Regular’
 Hello Quin,
My mistake, In fact it was a project where I use mplayer to manage audio.  I have a progress bar to show current position in the item and I wanted to be able to move a marker to a stop point underneath the progress bar.
With the family tree project I just change the X value of the labels (together with their vertical & horizontal connecting lines).  Your suggestion of a scroll bar could be of interest.  The database is a copy of the standard GEDCOM mysql db used in my web based family tree (a free genealogy manager called webtrees).  I'd be happy to provide more details if you wish.

I'd be happy to copy you with the project when it's a bit more stable.

Regards
Bill
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
 Thanks Bill,
Put me on the list for code sharing once you're done. - Thanks
I collect code snippets and once I have enough of a similar type , I create a "tool-box class" for them.

Cheers - Quin.
I code therefore I am
Online now: No Back to the top
1 guest and 0 members have just viewed this.