Bonsoir Jovial,
Jovial a écrit :
Bonjour :-)
Je recherche des informations ou exemple pour créer et supprimer par
programmation un bouton de control et pouvoir gerer sa taille et sa
position
J'ai trouvé le code ci-dessous sur OOoForum pour créer un bouton dans Calc.
En espérant avoir aidé.
Tony
--------------------------------------------------------
Sub formsincalc()
Dim aPos as new com.sun.star.awt.Point
Dim aSize as new com.sun.star.awt.Size
odoc = thisComponent
'create a form..
oform = odoc.createInstance( "com.sun.star.form.component.Form" )
'get the drawpage of the first sheet and insert the form there..
osheet = odoc.getSheets().getByIndex(0)
odrawpage = osheet.getDrawPage()
odrawpage.Forms.insertByName("MyForm", oform)
'now create a Shape that will visualize the Buttonmodel
button_shape = odoc.createInstance("com.sun.star.drawing.ControlShape")
'Position of it..
aPos.X = 5000
aPos.Y = 7000
button_shape.Position = aPos
'Size of it..
aSize.Width = 3000
aSize.Height = 1600
button_shape.Size = aSize
'now create a simple button for it..
button_model =
odoc.createInstance("com.sun.star.form.component.CommandButton")
button_model.Name = "CmdButton"
button_model.Label = "Click here"
'now connect model and shape with each other
button_shape.Control = button_model
'now insert it into the form..
odrawpage.Forms.getByName("MyForm").insertByIndex(0, button_model)
'now add it to the drawpage so that it becomes visible..
odrawpage.add(button_shape)
End Sub