von Gödel2607 » So, 16.05.2010 10:42
Ich habe schon vor einiger Zeit in BASIC für OOO 2.X eine Büroanwendung geschrieben, die ein eigenes Fenster mit Buttons usw als Basis benutzt. Da wir jetzt auf OOO 3.X umsteigen wollen, habe ich diese Anwendung übertragen. Sie läuft auch fehlerlos, allerdings kann der Titel des Fensters nicht mehr gesetzt werden. Der folgende Code zeigt das Problem:
Code: Alles auswählen
REM ***** BASIC *****
Sub Main
oAwtToolkit = CreateUnoService( "com.sun.star.awt.Toolkit" )
oTopWindow = CreateTopWindow( oAwtToolkit, 100, 200, 500, 400 )
oTopWindow.setBackground( RGB( 240, 240, 255 ) )
oFrame = CreateUnoService( "com.sun.star.frame.Frame" )
oFrame.initialize( oTopWindow )
oFrame.setCreator( StarDesktop )
oFrame.setTitle("TEST")
'ThisComponent.CurrentController.Frame.title = "TEST"
End Sub
Function CreateTopWindow( oAwtToolkit, x, y, w, h )
oWindowDesc = CreateUnoStruct( "com.sun.star.awt.WindowDescriptor" )
With oWindowDesc
.Type = com.sun.star.awt.WindowClass.TOP
.WindowServiceName = ""
.Bounds = MakeRectangle( x, y, w, h )
.WindowAttributes = 0
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.SHOW
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.BORDER
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.SIZEABLE
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.MOVEABLE
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.CLOSEABLE
End With
oXWindowPeer = oAwtToolkit.createWindow( oWindowDesc )
CreateTopWindow = oXWindowPeer
end Function
Function MakeRectangle( ByVal nX As Long, ByVal nY As Long,_
ByVal nWidth As Long, ByVal nHeight As Long ) As com.sun.star.awt.Rectangle
oRectangle = createUnoStruct( "com.sun.star.awt.Rectangle" )
With oRectangle
.X = nX
.Y = nY
.Width = nWidth
.Height = nHeight
End With
MakeRectangle() = oRectangle
End Function
Unter OOO 2.X war es problemlos möglich, den Fenstertitel mit oFrame.setTitle() zu setzen. Daß sich da etwas geändert hat, schreibt auch Thomas Krumbein in seinem Basic-Buch auf Seite 201/202. Die dort vorgeschlagene Methode ThisComponent.currentController funktioniert allerdings in dem Beispiel (und auch bei meiner Applikation) nicht sondern führt zu einer Fehlermeldung.
Weiß jemand Rat?
Ich habe schon vor einiger Zeit in BASIC für OOO 2.X eine Büroanwendung geschrieben, die ein eigenes Fenster mit Buttons usw als Basis benutzt. Da wir jetzt auf OOO 3.X umsteigen wollen, habe ich diese Anwendung übertragen. Sie läuft auch fehlerlos, allerdings kann der Titel des Fensters nicht mehr gesetzt werden. Der folgende Code zeigt das Problem:
[code]REM ***** BASIC *****
Sub Main
oAwtToolkit = CreateUnoService( "com.sun.star.awt.Toolkit" )
oTopWindow = CreateTopWindow( oAwtToolkit, 100, 200, 500, 400 )
oTopWindow.setBackground( RGB( 240, 240, 255 ) )
oFrame = CreateUnoService( "com.sun.star.frame.Frame" )
oFrame.initialize( oTopWindow )
oFrame.setCreator( StarDesktop )
oFrame.setTitle("TEST")
'ThisComponent.CurrentController.Frame.title = "TEST"
End Sub
Function CreateTopWindow( oAwtToolkit, x, y, w, h )
oWindowDesc = CreateUnoStruct( "com.sun.star.awt.WindowDescriptor" )
With oWindowDesc
.Type = com.sun.star.awt.WindowClass.TOP
.WindowServiceName = ""
.Bounds = MakeRectangle( x, y, w, h )
.WindowAttributes = 0
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.SHOW
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.BORDER
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.SIZEABLE
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.MOVEABLE
.WindowAttributes = .WindowAttributes + com.sun.star.awt.WindowAttribute.CLOSEABLE
End With
oXWindowPeer = oAwtToolkit.createWindow( oWindowDesc )
CreateTopWindow = oXWindowPeer
end Function
Function MakeRectangle( ByVal nX As Long, ByVal nY As Long,_
ByVal nWidth As Long, ByVal nHeight As Long ) As com.sun.star.awt.Rectangle
oRectangle = createUnoStruct( "com.sun.star.awt.Rectangle" )
With oRectangle
.X = nX
.Y = nY
.Width = nWidth
.Height = nHeight
End With
MakeRectangle() = oRectangle
End Function [/code]
Unter OOO 2.X war es problemlos möglich, den Fenstertitel mit oFrame.setTitle() zu setzen. Daß sich da etwas geändert hat, schreibt auch Thomas Krumbein in seinem Basic-Buch auf Seite 201/202. Die dort vorgeschlagene Methode ThisComponent.currentController funktioniert allerdings in dem Beispiel (und auch bei meiner Applikation) nicht sondern führt zu einer Fehlermeldung.
Weiß jemand Rat?