Inspiré du code fourni par Hubert Lambert, Piaf crée une boîte de Dialogue resizable, j'ai modifié le code pour une fenêtre qui je peuvez aussi minimizer, mais la fenêtre ne ferme pas. Il y a quelqu'un qui me aide.
Le code.
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 )
oWindow.setBackground(RGB(255,255,255) )
oBtnCtrl = MakeButtonCtrl( oAwtToolkit, oWindow, "OK", 62, 200, 76,30 )
oMouseListener = CreateUnoListener("Mouse_", "com.sun.star.awt.XMouseListener")
oBtnCtrl.addMouseListener(oMouseListener)
paintlistener = createUnoListener("XPaintListenerA_", "com.sun.star.awt.XPaintListener")
oWindow.addPaintListener(paintlistener)
End Sub
''--------------------------------------------------------------------
Function CreateNewWindow(oAwtToolkit,nX,nY,nWidth,nHeight) As Object
'sTypeName=oParent
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.TOP
.WindowServiceName = "dialog" ' ne pas changeable "window"
.ParentIndex = -1
.Bounds = aRect
'--.Parent = parentWindow 'oParent''null' '' ne fonctionne pas
.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
''----------------------------------------------------------------------------------
Sub XPaintListenerA_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,20,160,160)
graphic.FillColor = rgb(23,23,135)
graphic.drawRoundedRect(5,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,87," OPEN OFFICE")
''
graphic.drawEllipse(40,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 XPaintListenerA_disposing(oEv)
end sub