Hallo
zunächst vielen Dank für die Hilfe. Ich habe jetzt mal den kompletten Code hier eingebracht. ist ein bischen viel, aber vielleicht ist das wirklich besser, als die Code Schnippsel. Das oDlg.dispose() habe ich eingebaut, damit wenn der Dialog beendet wird, der Speicher wieder freigegeben wird. Das Ganze habe ich Programmiert mit OpenOffice 2.0 auf fedora Core 4.
REM ***** BASIC *****
' modul : dlgLohnzettel
' desc : stellt den dialog dlgLohnzettel zur verfuegung
' autjor : Gerd Schuckar <
gerd@schuckar.de>
' version 23.2.2006
' -------------------------------------------------------
option explicit
private oDlg as Object
private oDlgModel as Object
Sub showDialog()
on error goto Errorhandler
const DIALOG_TITLE as String = " ----> Fiktiver Lohnzettel <---- "
dim oWindow as Object
dim oLstStkl as object
dim oLstKist as Object
dim oLstKiFreib as Object
dim oLblMessage as Object
' ----------------------------
' Buttons
dim iButHeigt as Integer ' Hoehe eines Buttons
dim iButWidth as Integer ' Breite eines Buttons
dim oCmdNeu as Object ' Button Neu
dim oListenerNeu as Object
dim oCmdRechnen as Object ' Button Rechnen
dim oListenerRechnen as Object
dim oCmdCancel as Object ' Button cancel
dim oCancelClick_ as Object
dim oCmdInfo as Object ' Button Info
dim oListenerInfo as Object
' -----------------------------------------------
' Text - und Inputfelder
dim iTxtHeigt as Integer ' Hoehe eines Buttons
dim iTxtWidth as Integer ' Breite eines Buttons
oDlgModel = CreateUnoService("com.sun.star.awt.UnoControlDialogModel")
buildDialog(oDlgModel,"dlgLohnzettel", 50, 20, 250,300,DIALOG_TITLE)
' --------------------------
' make the Dialog functional
oDlg = CreateUnoService("com.sun.star.awt.UnoControlDialog")
oDlg.setModel(oDlgModel)
' ---------------------------
' make inputfield with labels
iTxtHeigt = 10 ' Hoehe eines Buttons
iTxtWidth = 50 ' Breite eines Buttons
buildTextField(oDlgModel,"lblLohn", 20, 20, 50, iTxtHeigt,"Lohn")
buildInputField(oDlgModel,"numLohn", 100, 20, 50, iTxtHeigt, "")
buildTextField(oDlgModel,"lblVWL_AG", 20, 32, 70, iTxtHeigt,"Arbeitgeberzuschuß VWL")
buildInputField(oDlgModel,"numVWL_AG", 100, 32, 50, iTxtHeigt, "")
buildTextField(oDlgModel,"lblDirektversicherung", 20, 44, 70, iTxtHeigt,"Direktversicherung")
buildInputField(oDlgModel,"numDirektversicherung", 100, 44, 50, iTxtHeigt, "")
' -------------------------------
' ListBox Steuerklasse with label
buildTextField(oDlgModel,"lblSteuerklasse", 20, 56, 70, iTxtHeigt,"Steuerklasse")
buildListBox(oDlgModel,"lstStkl", 1, 100, 56, 25, iTxtHeigt, "")
oLstStkl = oDlg.getControl("lstStkl")
with oLstSTkl
.additem("I",0)
.additem("II",1)
.additem("III",2)
.additem("VI",3)
.additem("V",4)
.additem("VI",5)
end with
' ------------------------------------
' Listbox kirchensteuersatz with label
buildTextField(oDlgModel,"lblKirchensteuer", 20, 68, 70, iTxtHeigt,"Kirchensteuer")
buildListBox(oDlgModel,"lstKist", 1, 100, 68, 25, iTxtHeigt, "")
oLstKist = oDlg.getControl("lstKist")
with oLstKist
.additem(0,0)
.additem(8,1)
.additem(9,2)
end with
' --------------------------------------
' Listbox Kinderfreibetrag with label
buildTextField(oDlgModel,"lblKinderfreibetrag", 20, 80, 70, iTxtHeigt,"Kinderfreibetrag")
buildListBox(oDlgModel,"lstKiFreib", 0, 100, 80, 25, iTxtHeigt, "")
oLstKiFreib = oDlg.getControl("lstKiFreib")
with oLstKiFreib
.additem(0,0)
.additem(0.5,1)
.additem(1.0,2)
.additem(1.5,3)
.additem(2.0,4)
.additem(2.5,5)
.additem(3.0,6)
.additem(3.5,7)
end with
' --------------------------------------
' labels for output fields
buildTextField(oDlgModel,"lblEKSteuer", 20, 100, iTxtWidth+20, iTxtHeigt,"Einkommensteuer")
buildTextField(oDlgModel,"lblKistSteuer", 20, 112, iTxtWidth+20, iTxtHeigt,"Kirchensteuer")
buildTextField(oDlgModel,"lblSoli", 20, 124, iTxtWidth+20, iTxtHeigt,"Solidaritätszuschlag")
buildTextField(oDlgModel,"lblRV", 20, 136, iTxtWidth+20, iTxtHeigt,"Rentenversicherung")
buildTextField(oDlgModel,"lblGKV", 20, 148, iTxtWidth+20, iTxtHeigt,"Krankenversicherung")
buildTextField(oDlgModel,"lblPV", 20, 160, iTxtWidth+20, iTxtHeigt,"Pflegeversicherung")
buildTextField(oDlgModel,"lblALU", 20, 172, iTxtWidth+20, iTxtHeigt,"Arbeitslosenversicherung")
buildTextField(oDlgModel,"lblAbZg", 20, 184, iTxtWidth+20, iTxtHeigt,"Abzüge gesamt")
buildTextField(oDlgModel,"lblNetto", 20, 196, iTxtWidth+20, iTxtHeigt,"Netto Einkommen")
' --------------------------------------
' Output Fields 1 -> Ohne Ersparniss
buildTextField(oDlgModel,"lblOutEKSteuer", 100, 100, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutKist", 100, 112, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutSoli", 100, 124, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutRV", 100, 136, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutGKV", 100, 148, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutPV", 100, 160, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutALU", 100, 172, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutAbZg",100, 184, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutNetto", 100, 196, iTxtWidth, iTxtHeigt,"")
' --------------------------------------
' Output Fields 2 -> mit Ersparniss durch Direktversicherung
buildTextField(oDlgModel,"lblOutEKSteuer2", 170, 100, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutKist2", 170, 112, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutSoli2", 170, 124, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutRV2", 170, 136, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutGKV2", 170, 148, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutPV2", 170, 160, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutALU2", 170, 172, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutAbZg2",170, 184, iTxtWidth, iTxtHeigt,"")
buildTextField(oDlgModel,"lbloutNetto2", 170, 196, iTxtWidth, iTxtHeigt,"")
' ---------------------------------------------------
' build the textfield for system messages with a frame
buildTextField(oDlgModel,"lblMessage",20, 215,iTxtWidth*4.2,iTxtHeigt*5,"System - Info",2)
' --------------------------------
' build the Buttons and the Events
iButHeigt = 15
iButWidth = 40
buildButton(oDlgModel,"cmdRechnen",20, 270,iButWidth,iButHeigt,"Rechnen")
oListenerRechnen = CreateUnoListener("Rechnen_","com.sun.star.awt.XActionListener")
oCmdRechnen = oDlg.getControl("cmdRechnen")
oCmdRechnen.AddActionListener(oListenerRechnen) ' Daten berechnen
buildButton(oDlgModel,"cmdNeu",65, 270,iButWidth,iButHeigt,"Neu")
oListenerNeu = CreateUnoListener("Neu_","com.sun.star.awt.XActionListener")
oCmdNeu = oDlg.getControl("cmdNeu")
oCmdNeu.AddActionListener(oListenerNeu) ' Daten neu eingeben
buildButton(oDlgModel,"cmdCancel",110, 270,iButWidth,iButHeigt,"Abbrechen")
oCancelClick_ = CreateUnoListener("CancelClick_","com.sun.star.awt.XActionListener")
oCmdCancel = oDlg.getControl("cmdCancel")
oCmdCancel.AddActionListener(oCancelClick_) ' Anwendung beenden
buildButton(oDlgModel,"cmdInfo",190, 270,iButWidth,iButHeigt,"Info")
oListenerInfo = CreateUnoListener("Info_","com.sun.star.awt.XActionListener")
oCmdInfo = oDlg.getControl("cmdInfo")
oCmdInfo.AddActionListener(oListenerInfo) ' Info anzeigen
oWindow = CreateUnoService("com.sun.star.awt.Toolkit")
' -----------------------------------------
' and now, show the dialog
with oDlg
.setModel(oDlgModel)
.createPeer(oWindow,null)
.execute()
.dispose()
end with
on error goto 0
exit sub
Errorhandler:
MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")",48,"dlgLohnzettel showDialog"
on error goto 0
End Sub ' showDialog
' ------------------------------
' Mouse Events
sub MouseClick_actionPerformed(oEvent as Object)
on error goto ErrorHandler
if Event.Source.Model.Name = "cmdReset" then
msgbox "cmdReset gedrueckt" ' clearDialog()
elseif Event.Source.Model.Name = "cmdRechnen" then
msgbox "cmdRechne gedrueckt" ' rechne()
end if ' Event.Source.Model.Name
on error goto 0
exit sub
Errorhandler:
MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")",48,"MouseClick_actionPerformed"
on error goto 0
end sub ' MouseClick_actionPerformed
' ----------------------------------------------
' Dialog beenden
sub CancelClick_actionPerformed(oEvent as Object)
' dim t as string
' t = "Event from: " & event.source.model.name
' msgbox t
oDlg.endExecute()
end sub ' CancelClick_actionPerformed
'
' ---------- End of modul dlgLohnzettel ----------
REM ***** BASIC *****
' modul : mdlDlgTools
' desc : stellt tools zum Dialog Aufbau zur Verfuegung
' author : Gerd schuckar <
gerd@schuckar.de>
' version : 24.2.2006
' ------------------------------------------------------
private sub buildDialog(oDlgMod as Object, _
sDlgName as String, _
dlgPosX as integer, dlgPosY as integer, _
dlgWidth as Integer, dlgHeight as Integer, _
dlgTitle as String)
dim oMod as Object
oMod = oDlgMod.CreateInstance("com.sun.star.awt.UnoControlDialogModel")
with oMod
.setPropertyValue("PositionX", dlgPosX)
.setPropertyValue("PositionY", dlgPosY)
.setPropertyValue("Width", dlgWidth)
.setPropertyValue("Height", dlgHeight)
.setPropertyValue("Name", sDlgName)
.setPropertyValue("Title", dlgTitle)
end with
oDlgModel= oMod
end sub ' buildDialog
private sub buildListBox(oDlgMod as Object, _
sLstName as String, lstAlign as integer, _
lstPosX as integer, lstPosY as integer, _
lstWidth as Integer, lstHeight as Integer, _
lstLabel as String)
dim oMod as Object
oMod = oDlgMod.CreateInstance("com.sun.star.awt.UnoControlListBoxModel")
with oMod
.setPropertyValue("Name",sLstName)
.setPropertyValue("Align",lstAlign)
.setPropertyValue("TabIndex",1)
.setPropertyValue("PositionX",lstPosX)
.setPropertyValue("PositionY",lstPosY)
.setPropertyValue("Width",lstWidth)
.setPropertyValue("Height",lstHeight)
.setPropertyValue("Dropdown",true)
end with
oDlgModel.insertByname(sLstName,oMod)
end sub ' buildListBox
private sub buildInputField(oDlgMod as Object, _
sNumName as String, _
numPosX as integer, numPosY as integer, _
numWidth as Integer, numHeight as Integer, _
numLabel as String)
dim oMod as Object
oMod = oDlgMod.CreateInstance("com.sun.star.awt.UnoControlEditModel")
with oMod
.setPropertyValue("Name",sNumName)
.setPropertyValue("Align",2)
.setPropertyValue("TabIndex",1)
.setPropertyValue("PositionX",numPosX)
.setPropertyValue("PositionY",numPosY)
.setPropertyValue("Width",numWidth)
.setPropertyValue("Height",numHeight)
.setPropertyValue("Text",numLabel)
end with
oDlgModel.insertByname(sNumName,oMod)
end sub ' buildInputField
private sub buildTextField(oDlgMod as Object, _
sLblName as String, _
lblPosX as integer, lblPosY as integer, _
lblWidth as Integer, lblHeight as Integer, _
sLblText as String, Optional lblBorder as integer)
dim oMod as Object
dim iOptional as integer
iOptional = 0
if not isMissing (lblBorder) then
iOptional = lblBorder
endif
oMod = oDlgMod.CreateInstance("com.sun.star.awt.UnoControlFixedTextModel")
with oMod
.setPropertyValue("Name",sLblName)
.setPropertyValue("Align",0)
.setPropertyValue("TabIndex",1)
.setPropertyValue("PositionX",lblPosX)
.setPropertyValue("PositionY",lblPosY)
.setPropertyValue("Width",lblWidth)
.setPropertyValue("Height",lblHeight)
.setpropertyValue("Border", iOptional)
.setPropertyValue("Label",slblText)
end with
oDlgModel.insertByname(sLblName,oMod)
end sub ' buildTextField
private sub buildButton(oDlgMod as Object, _
sButName as String, _
butPosX as integer, butPosY as integer, _
butWidth as Integer, butHeight as Integer, _
butLabel as String)
dim oMod as Object
oMod = oDlgMod.CreateInstance("com.sun.star.awt.UnoControlButtonModel")
with oMod
.setPropertyValue("Name",sButName)
.setPropertyValue("Align",1)
.setPropertyValue("TabIndex",1)
.setPropertyValue("PositionX",butPosX)
.setPropertyValue("PositionY",butPosY)
.setPropertyValue("Width",butWidth)
.setPropertyValue("Height",butHeight)
.setPropertyValue("Label",butLabel)
end with
oDlgModel.insertByname(sButName,oMod)
end sub ' buildButton
'
' ---------- End of modul mdlDlgTools ----------
Gruß
Gerd