Hello everybody,
Désolé de mon anglais
I have already managed to place some controls by programming ( ListBox and Labels )
Here is the file .odb
Now what I want is to affect "post-it", that is to say, to move each ListBox programmatically.
To reach my goal, I start slowly. For now, what I want is that once having placed my 20 ListBox and Labels (4 x 5) by clicking on the "New Group" button, be able to click on the ListBox and have (display) coordinates.
After making clicking a Control (ListBox), I get to see the name that I decided to give it.
Then I wanted to show just the X coordinate of control. But I am told that the getPosition method is not found. Yet for each control, I did well setPosition (Point) at the time of creation.
I do not see at all what the problem is.
For contact information for controls, I used the same procedure:
I wish I had an answer to my question. and I thank you even before the answer.
Cordially.
[Solved] [Base] Get position of a Control ListBox (Macro)
[Solved] [Base] Get position of a Control ListBox (Macro)
Last edited by bcf179en on Mon Mar 21, 2016 3:43 pm, edited 1 time in total.
LibreOffice Version: 4.2.8.2 Ubun 14.04
Re: [Base]-Get position of a Control ListBox (Macro)
If you're looking for position information, you need the object from the DrawPage, not the Forms.
So change the assignment for oObj to and the function to
And now this will work:
So change the assignment for oObj to
Code: Select all
oObj = FindObjectByName(ThisComponent.DrawPage, oControl.Name)
Code: Select all
Function FindObjectByName(oDrawPage As Object, nomObj as String) As Object
Dim objX As Object
Dim x As Long
For x = 0 To oDrawPage.Count - 1
objX = oDrawPage.getByIndex(x)
If objX.Control.Name = nomObj Then
FindObjectByName = objX ' objet trouvé
MsgBox objX.Control.Name
Exit Function
EndIf
Next x
End Function
Code: Select all
MsgBox oObj.getposition.x
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
-
- Volunteer
- Posts: 1548
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: [Base]-Get position of a Control ListBox (Macro)
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Re: [Base]-Get position of a Control ListBox (Macro)
Hello,
Thank you.
What is the difference between
and
.
In my opinion the first one get the position in the ListBox, yes or not?
Thank you.
What is the difference between
Code: Select all
oEvt.X
and
Code: Select all
oEvt.Source.X
In my opinion the first one get the position in the ListBox, yes or not?
LibreOffice Version: 4.2.8.2 Ubun 14.04
-
- Volunteer
- Posts: 1548
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: [Base]-Get position of a Control ListBox (Macro)
The Event that triggers your macro is a mouse click so it reports the position of the mouse inside the control/ListBox.
For the ListBoxes on your form Xpos will always be somewhere between 0-189 (the Width is 190), regardless of which one you select.
whereas
gets the position on the form of the control/ListBox so Xpos only changes if you select a Listbox in a different column. On your form Groupe5 will report the same value for Xpos as Groupe1, but Groupe2 will be different.
Code: Select all
Xpos = oEvt.X
whereas
Code: Select all
Xpos = oEvt.Source.PosSize.X
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
[Solved][Base] Get position of a Control ListBox (Macro)
Thank you!!!!
LibreOffice Version: 4.2.8.2 Ubun 14.04