J'ai une Fenêtre avec une barre de défilement (ScrollBar) qui n'est pas fonctionel. Les graphiques ne se déplacent pas sur l'arrière-plan. Comme faire la fonctionner. Il y a quelqu'un qui me aide.
Code : Tout sélectionner
REM ***** BASIC *****
Dim oWindow as Object, paintlistener as Object, graphic as Object
Sub Main
oAwtToolkit = CreateUnoService( "com.sun.star.awt.Toolkit" )
' Create a top level window.
oWindow = CreateNewWindow( oAwtToolkit, 100, 200, 400, 500 )
oDoc = ThisComponent
oParentFrame = oDoc.CurrentController.Frame
'oPeer = oParentFrame.ContainerWindow
'oToolkit = oPeer.Toolkit
'oWindow = CreateNewWindow(oToolkit,oPeer,100,100,200,250)
oFrame = CreateUnoService("com.sun.star.frame.Frame")
oFrame.initialize(oWindow)
oFrame.setCreator(oParentFrame)
oFrame.setName("NewFrame")
oFrame.Title = "New Frame"
oParentFrame.getFrames().append(oFrame)
'oWindow.setVisible(True)
oWindow.Title = "Mon Graphique"
oWindow.setBackground(RGB(255,255,255) )'' RGB( 210, 210, 255 )
''
oBtnCtrl = MakeButtonCtrl( oAwtToolkit, oWindow, "OK", 62, 200, 76,30 )
oMouseListener = CreateUnoListener("Mouse_", "com.sun.star.awt.XMouseListener")
oBtnCtrl.addMouseListener(oMouseListener)
'
oScrollCtrl = MakeScrollCtrl( oAwtToolkit, oWindow, "ScrollBar1", 0, 20,20,400)
'
paintlistener = createUnoListener("XPaintListener_", "com.sun.star.awt.XPaintListener")
oWindow.addPaintListener(paintlistener)
End Sub
''--------------------------------------------------------------------
Function CreateNewWindow(oAwtToolkit,nX,nY,nWidth,nHeight) As Object
aRect = CreateUnoStruct("com.sun.star.awt.Rectangle")
With aRect
.X = nX
.Y = nY
.Width = nWidth
.Height = nHeight
End With
aWinDesc = CreateUnoStruct("com.sun.star.awt.WindowDescriptor")
With aWinDesc
'.Type = com.sun.star.awt.WindowClass.CONTAINER
.Type = com.sun.star.awt.WindowClass.TOP
.WindowServiceName = "dialog"
.ParentIndex = -1
.Bounds = aRect
''.Parent = oAwtToolkit.getDesktopWindow()
'--.Parent = parentWindow 'oParent'''null' '
.WindowAttributes =0
.WindowAttributes =.WindowAttributes+ com.sun.star.awt.WindowAttribute.SHOW
.WindowAttributes =.WindowAttributes+ com.sun.star.awt.WindowAttribute.MOVEABLE
.WindowAttributes =.WindowAttributes+ com.sun.star.awt.WindowAttribute.SIZEABLE
.WindowAttributes =.WindowAttributes+ com.sun.star.awt.WindowAttribute.BORDER
.WindowAttributes =.WindowAttributes+ com.sun.star.awt.WindowAttribute.CLOSEABLE
''+ com.sun.star.awt.WindowAttribute.MINSIZE
End With
CreateNewWindow = oAwtToolkit.createWindow(aWinDesc)
End Function
Function MakeButtonCtrl(oAwtToolkit, oWindow,cLabel,nX,nY,nWidth,nHeight )
oButtonModel = CreateUnoService("com.sun.star.awt.UnoControlButtonModel")
oButtonCtrl = CreateUnoService("com.sun.star.awt.UnoControlButton")
oButtonCtrl.setModel(oButtonModel)
oButtonCtrl.createPeer(oAwtToolkit, oWindow)
oButtonModel.Label = cLabel
oButtonModel.DefaultButton = True
oButtonCtrl.setPosSize(nX,nY,nWidth,nHeight,com.sun.star.awt.PosSize.POSSIZE)
MakeButtonCtrl = oButtonCtrl
End Function
''--------------------------------------------------------
Function MakeScrollCtrl( oAwtToolkit, oWindow, Optional cLabel,nX1,nY1,nWidth1,nHeight1)'
' Create a new button model.
oScrollModel = CreateUnoService( "com.sun.star.awt.UnoControlScrollBarModel")
oScrollModel.BlockIncrement = 20
oScrollModel.ScrollValueMin=5
'ScrollBarOrientation =1
oScrollModel.Orientation = 1'Horizontal=0 ' Vertical=1
oScrollModel.Border=2
oScrollModel.ScrollValueMax = 100'
oScrollModel.LineIncrement = 5'
oScrollModel.VisibleSize = 20'nVisble
oScrollModel.LiveScroll = True
' Create a new button control.
oScrollCtrl = CreateUnoService( "com.sun.star.awt.UnoControlScrollBar")
oScrollCtrl.setPosSize(nX1,nY1,nWidth1,nHeight1,com.sun.star.awt.PosSize.POSSIZE)
' Tell the control that it has a model.
oScrollCtrl.setModel( oScrollModel )
oScrollCtrl.createPeer( oAwtToolkit, oWindow )
MakeScrollCtrl = oScrollCtrl
End Function
'--------------------------------------------------------
Sub XPaintListener_WindowPaint(oEv)
If oEv.count > 0 Then Exit Sub
win = oEv.Source
Graphic = win.createGraphics
graphic.FillColor = rgb(30,144,255)
graphic.LineColor = -1
graphic.drawEllipse(20+50,20,160,160)
graphic.FillColor = rgb(23,23,135)
graphic.drawRoundedRect(5+50,82,190,36,10,10)
font = win.AccessibleContext.Font
fontdesc = font.FontDescriptor
fontdesc.Name = "Arial"
fontdesc.Family = 5
fontdesc.Weight = 200
fontdesc.Height = 22
graphic.selectFont(fontdesc)
graphic.TextColor = rgb(255,255,255)
graphic.drawText(11+50,87," OPEN OFFICE")
''
graphic.drawEllipse(40+50,240,160,160)
End sub
Sub Mouse_mousePressed(oEv as Object)
oEv.Source.AccessibleContext.AccessibleParent.dispose
End Sub
Sub Mouse_disposing(oEv as Object)
End Sub
Sub Mouse_mouseEntered(oEv as Object)
End Sub
Sub Mouse_mouseExited(oEv as Object)
End Sub
Sub Mouse_mouseReleased(oEv as Object)
End Sub
sub XPaintListener_disposing(oEv)
end sub