OO-Snippets: position and size of form-controls

Commons

KeywordsForm, Control, Position, Size
LanguageOOBasic
ApplicationOffice
AuthorsAndrew Pitonyak
Paolo Mantovani
Supported Versions
Supported OS
Question How can I get the position and size of form controls?
Answer

A form control is placed on a drawing shape (com.sun.star.drawing.XControlShape), so you need to obtain the shape underlying the control to manage his size and pos.

Andrew Pitonyaks Tools Library (module "ModuleControls") supplies some facilities in order to work with form controls.

Check those functions:

  • GetControlModel()
  • GetControlShape()
  • GetControlView()
  • Code-Snippet-Listing (snippet-source)

    Sub SeeThingProp
      Dim oForm, oControl, iNumControls%, i%
      Dim v()
      'By default this is where the controls are
      oForm = ThisComponent.Drawpage.Forms.getByName("Standard")
    '  oControl = oForm.getByName("MyPushButton")
      oControl = oForm.getByName("CheckBox")
      Dim vShape
      Dim vPosition, vSize
      Dim s$, vv
      vShape = GetControlShape(ThisComponent, "CheckBox")
      vPosition = vShape.getPosition()
      vSize = vShape.getSize()
    '  RunSimpleObjectBrowser(vSize)
      s = s & "Position = (" & vPosition.X & ", " & vPosition.Y & ")" & CHR$(10)
      s = s & "Height = " & vSize.Height & " Width = " & vSize.Width & CHR$(10)
      MsgBox s
    End Sub
    

    Changelog

    DateUserModification
    0000-00-00andInitial version

    and