

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
9 messages in org.openoffice.fr.progRE : [prog] How to: Ajouter dynamiqu...| From | Sent On | Attachments |
|---|---|---|
| Philippe Pons | Feb 16, 2008 2:18 am | |
| François Breizh | Feb 16, 2008 3:28 am | |
| Philippe Pons | Feb 16, 2008 3:38 am | |
| chaliapine | Feb 16, 2008 5:57 am | |
| chaliapine | Feb 16, 2008 6:01 am | |
| chaliapine | Feb 16, 2008 6:06 am | |
| Philippe Pons | Feb 16, 2008 8:35 am | |
| Laurent Godard | Feb 18, 2008 12:18 am | |
| chaliapine | Feb 18, 2008 12:48 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | RE : [prog] How to: Ajouter dynamiquement un controle à un dialogue? | Actions... |
|---|---|---|
| From: | chaliapine (chal...@free.fr) | |
| Date: | Feb 16, 2008 6:01:21 am | |
| List: | org.openoffice.fr.prog | |
Problème de lien dans mon message précédent, extension html (vous aurez sûrement corrigé, mais bon...) : http://api.openoffice.org/docs/common/ref/com/sun/star/awt/module-ix.htm l
------------- Pascal
-----Message d'origine----- De : chaliapine [mailto:chal...@free.fr] Envoyé : samedi 16 février 2008 14:58 À : pr...@fr.openoffice.org Objet : [prog] RE : [prog] How to: Ajouter dynamiquement un controle à un dialogue?
Bonjour
On peut effectivement créer des contrôles dans une BDD de manière dynamique. C'est quand même mieux que de tous les créer avant et de rendre visibles ceux que l'on souhaite. Surtout quand on ne sait pas combien il peut y en avoir.
Quelques pistes que j'ai essayées récemment. Pour chaque type d'objet à créer je crée un SUB. En fonction du type d'objet (bouton, label, liste...), l'instance à créer change. On trouvera ici les différents types : http://api.openoffice.org/docs/common/ref/com/sun/star/awt/module-ix.htm l
Dans la procédure de construction, en fonction de ce que je veux construire, j'appelle le SUB idoine. Ci-dessous, un SUB d'ajout de bouton et un SUB de construction dynamique qui fabrique N boutons dans la DLG. Dlg représente l'objet boîte de dialogue (défini donc en global)
Sub construction n=10 ecartVert=14 'écart vertical entre boutons departVert=44 'point de départ vertical du premier bouton For i=1 to n AjoutBouton ( dlg ,"NomBouton" & i ,3 ,departVert-3 + (i-1)*ecartVert ,i) next End sub
Sub AjoutBouton ( dialogue as object,nomBouton as string, positionX as integer,positionY as integer) Dim oDialogModel As Object , oButtonModel As Object NomObj = nomBouton oDialogModel = dialogue.Model 'Définit le modèle d'objet à ajouter
'http://api.openoffice.org/docs/common/ref/com/sun/star/awt/module-ix.ht ml oButtonModel = oDialogModel.createInstance( "com.sun.star.awt.UnoControlButtonModel" )
With oButtonModel .Name = NomObj .Label = "affecter" .PushButtonType="STANDARD" .Tabstop = True .PositionX = positionX 'position horizontale .PositionY = positionY 'position verticale .Width = 27 'largeur .Height = 14 'hauteur End With oDialogModel.insertByName( NomObj , oButtonModel )
'ici c'est un listener qui permet après d'intercepter un clic sur le bouton et d'éxécuter une macro. Pour cela il faut que la macro s'appelle nomDuBouton_actionPerformed
oButtonControl = dialogue.getControl( NomObj ) cEventListenerName =NomObj oActionListener = CreateUnoListener( cEventListenerName + "_", "com.sun.star.awt.XActionListener" ) oButtonControl.addActionListener( oActionListener ) End Sub
-----Message d'origine----- De : news [mailto:ne...@ger.gmane.org] De la part de Philippe Pons Envoyé : samedi 16 février 2008 12:38 À : pr...@fr.openoffice.org Objet : Re: [prog] How to: Ajouter dynamiquement un controle à un dialogue?
François Breizh <francois.breizh <at> orange.fr> writes:
Il est possible de définir tous les contrôles nécessaires puis de modifier leur visibilité par programmation avec <controle>.Model.visible = True ou False
Non ?
Oui, effectivement c'est une solution. Merci, Philippe







