ich habe hier ein XbpDialog das ich dynamisch mit XbpStatic füllen möchte.
Dafür habe ich mir vorher XbpFont und XbpPresSpace erstellt für die korrekte Berechnung.
der Code sieht jetzt so aus:
Code: Alles auswählen
local oDlg, Mbreit, Mhoch, Mpos_x, Mpos_y, MzeilHoehe, MzeilBreite, MSize, MpresSpace, Mmax_len
local aPos, aSize, aStatics, oFont, drawingArea
Mbreit := 250
Mhoch := 150
aStatics := { "ListenElement 1", "Noch ein weiteres Element", "Element 3" }
Mmax_len := 1
for Mlauf:=1 to len(aStatics)
if len(aStatics[Mlauf]) > Mmax_len
Mmax_len := len(aStatics[Mlauf])
endif
next
//ConfirmBox( nil, str(Mmax_butt), "DEBUG", XBPMB_OK )
aSize:=SetAppWindow():currentSize()
aPos :=SetAppWindow():currentPos()
Mpos_x:=aPos[1]+(aSize[1]-Mbreit)/2
Mpos_y:=aPos[2]+(aSize[2]-Mhoch)/2
oDlg := XbpDialog():new( SetAppWindow():setParent(), SetAppWindow(), {Mpos_x, Mpos_y}, {Mbreit, Mhoch}, , .F.)
oDlg:taskList := .F.
oDlg:border := XBPDLG_RAISEDBORDERTHIN_FIXED
oDlg:close :={|| nEvent := xbeP_Close }
oDlg:KillDisplayFocus:={|| nEvent := xbeP_Close }
//oDlg:keyBoard :={|mp1,mp2,obj| ... }
oDlg:create()
MpresSpac := XbpPresSpace():new()
MpresSpac:create( oDlg:winDevice() , {50,50}, GRA_PU_PIXEL )
oFont:=XbpFont():new( MpresSpac )
oFont:compoundName := "11.Arial"
oFont:create()
MSize := {}
GraSetFont( MpresSpac, oFont )
MSize := GraQueryTextBox( MpresSpac, "O")
MzeilHoehe := MSize[1,2]
MzeilBreite := MSize[3,1]
ConfirmBox( nil, str(Mmax_len)+": "+str(MzeilBreite)+" x "+str(MzeilHoehe), "DEBUG", XBPMB_OK )
Mbreit := MzeilBreite*(Mmax_len+8)
Mhoch := MzeilHoehe*(len(aStatics)+4)
oDlg:setSize( { Mbreit, Mhoch } )
drawingArea := oDlg:drawingArea
MpresPara := {}
MstaticBreite := MzeilBreite*(Mmax_len+4)
for Mlauf:=1 to len(aStatics)
oXbp := XbpStatic():new( drawingArea, , {15,15+MzeilHoehe*(len(aStatics)-Mlauf)}, {MstaticBreite,MzeilHoehe} )
oXbp:setFontCompoundName( oFont:compoundName )
oXbp:autosize := .f.
oXbp:caption := space(4)+aStatics[Mlauf]
oXbp:setName( 100+Mlauf )
if Mlauf==1
presPara := { { XBP_PP_BGCLR, GRA_CLR_BLUE } }
else
presPara := { { XBP_PP_BGCLR, GRA_CLR_PALEGRAY } }
endif
oXbp:create()
oXbp:setPresParam( presPara )
next
oDlg:show()
Da ich vorher die Breite festllege auf 'längster String + 4' und ich beim Festlegen des Inhaltes vorn dran space(4) setze, müsste das Static-Element mit dem längsten String ungefähr da aufhören wo auch der Text zu Ende ist.
Es sieht aber so aus als wäre das Static beinahe doppelt so lang. Auch die vorher ermittelte Höhe stimmt so nicht.
Die Static-Felder überschneiden sich. Habe ich da noch einen Denkfehler oder wo liegt das Problem?
danke schon mal...