Ist mir alles zu spön. Hatte gerade Profanes am Wickel. Verdrängung und Schwerpunkt '89 noch von Hand, dann mit Profan 6.6 und der Listview.inc berechnet. Heute, weil für Erstellung von "wide-blade-spoons" gebraucht, auf Gridbox umgestellt.
$H windows.ph
$H messages.ph
$H commctrl.ph
WindowStyle 16+512
Window 600,410
WindowTitle "Volumen, Schwerpunkt, ...."
cls ~GetSysColor(15)
Set("Decimals",2)
Declare LV&, Ende&, Ende%, Rechne&, Teile&, Teile%, LV_Font&, x&, x%, x!, x$, y&, y%, y!
Declare Item&, Abst&, plus&, minus&, Wert&, Neu1&,Neu2&,Neu3&,Neu4&,Teil_L&,LV1&,Spez&
LV_Font&=CreateFont("Verdana",16,0,0,0,0)
SetDialogFont LV_Font&
x$="Werte in der Tabelle nach Doppellinksklick eingeben.\n"
x$=x$+"Fläche geht vor a*b.\n"
x$=x$+"Fläche, bzw. a*b geht vor Radius.\n"
x$=x$+"Radius und Fläche, bzw. a*b führt zu abgerundeten Kanten.\n"
x$=x$+"Wird zur Fläche ein Radius eingegeben, wird die Ursprungsfläche verändert.\n"
Create("Tooltip",%hwnd,%hwnd,x$)
CreateText(%hwnd,"Abschnitte",10,60,70,22)
CreateText(%hwnd,"Länge",100,10,70,22)
CreateText(%hwnd,"Teil-Länge",100,60,70,22)
CreateText(%hwnd,"spez. Gew.",10,10,90,22)
x$="Inhalt;0;160;Wert;1;120"
LV1& = Create("GridBox", %hwnd, x$, 0, 280, 10, 300, 80)
setstyle Lv1&,getstyle(Lv1&) | ~LVS_NOCOLUMNHEADER
SetFont LV1&,LV_Font&
Addstring(LV1&,"Volumen|0")
Addstring(LV1&,"Schwerpunkt von 0|0")
Addstring(LV1&,"Gewicht|0")
Addstring(LV1&,"Moment|0")
Teile%=4
Teile&=CreateText(%hwnd,"4",12,82,20,22)
SetFont Teile&,LV_Font&
plus& = Create("Button",%hwnd,"+",33,80,22,22)
minus& = Create("Button",%hwnd,"-",56,80,22,22)
Spez& = Create("Edit",%hwnd,"1",10,30,70,22)
@sendmessage(Spez&,$00C5,7,0)
Abst& = Create("Edit",%hwnd,"1",100,30,70,22)
@sendmessage(Abst&,$00C5,7,0)
Teil_L&=CreateText(%hwnd,str$(val(gettext$(Abst&))/Teile%),100,82,70,22)
SetFont Teil_L&,LV_Font&
Create("GroupBox",%hwnd,"zu Null",480,114,100,140)
Neu1& = Create("Button",%hwnd,"Fläche",490,140,80,22)
Neu2& = Create("Button",%hwnd,"Seite-a",490,164,80,22)
Neu3& = Create("Button",%hwnd,"Seite-b",490,188,80,22)
Neu4& = Create("Button",%hwnd,"Radius",490,212,80,22)
Ende& = Create("Button",%hwnd,"ENDE",480,340,100,22)
Rechne& = Create("Button",%hwnd,"Rechne",480,316,100,22)
x$="x;1;0;Pos.;1;60;Fläche;1;120;Seite-a;1;80;Seite-b;1;80;Radius;1;80"
LV& = Create("GridBox", %hwnd, x$, 0, 10, 110, 460, 250)
Addstring(LV&,"0.5|0|0|0|0|0")
Addstring(LV&,"2|1|0|0|0|0")
Addstring(LV&,"1|2|0|0|0|0")
Addstring(LV&,"2|3|0|0|0|0")
Addstring(LV&,"0.5|4|0|0|0|0")
SetFont LV&,LV_Font&
SubClass %hwnd, 1
UserMessages 2000
WhileNot Ende%
WaitInput
case Clicked(Ende&): Ende% = 1
case getfocus(Abst&) : NUMWERT Abst&, 3
case getfocus(Spez&) : NUMWERT Spez&, 3
case getfocus(Rechne&) : RECHNE
case getfocus(Neu1&) : ITEM_LEER 2
case getfocus(Neu2&) : ITEM_LEER 3
case getfocus(Neu3&) : ITEM_LEER 4
case getfocus(Neu4&) : ITEM_LEER 5
settext Teil_L&,str$(val(gettext$(Abst&))/Teile%)
If (%umessage = 2000) AND (&ulparam > 1)
x$ = GetText$(LV&, &uwparam, &ulparam)
x&= &ulparam
y&= &uwparam
x%=0
y%=SendMessage(LV&,$101D, x&,0)
Whileloop 0,x&-1,1
x%=x%+SendMessage(LV&,$101D, &loop,0)
EndWhile
Wert& = Create("Edit",LV&,x$,x%+2,19+(y&*17),y%-2,18)
@sendmessage(Wert&,$00C5,9,0)
SetFont Wert&,LV_Font&
setfocus(wert&)
@SendString(Wert&,"+({END})")
While getfocus(wert&)
waitinput
case getfocus(Wert&) : NUMWERT Wert&, 2
EndWhile
case trim$(gettext$(wert&))="" : settext Wert&,"0"
SetText LV&, y&, x&, translate$(gettext$(wert&),",",".")
DestroyWindow(Wert&)
setfocus(%hwnd)
ElseIf getfocus(Minus&) AND (Teile%>4)
SetText LV&, GetCount(LV&)-3, 0, "0.5"
DeleteString(LV&,GetCount(LV&)-1)
DeleteString(LV&,GetCount(LV&)-1)
dec Teile%,2
settext Teile&,str$(Teile%)
settext Teil_L&,str$(val(gettext$(Abst&))/Teile%)
setfocus(%hwnd)
ElseIf getfocus(Plus&)
SetText LV&, GetCount(LV&)-1, 0, "1"
Addstring(LV&,"2|"+str$(GetCount(LV&))+"|0|0|0|0")
Addstring(LV&,"0.5|"+str$(GetCount(LV&))+"|0|0|0|0")
inc Teile%,2
settext Teile&,str$(Teile%)
settext Teil_L&,str$(val(gettext$(Abst&))/Teile%)
setfocus(%hwnd)
Endif
Endwhile
Usermessages 0
SubClass %hwnd, 0
END
'#############################################################################
SubClassProc
If SubClassMessage(%hWnd, ~WM_NOTIFY)
If Long(&sLParam,8)=-3
item&=Long(&sLParam,12)
If item&<>-1
SendMessage(%hwnd, 2000, item&, Long(&sLParam,16))
EndIf
EndIf
EndIf
EndProc
Proc ITEM_LEER
Parameters x%
WhileLoop 0,(GetCount(LV&)-1) ,1
SetText LV&,&loop,x%,"0"
EndWhile
EndProc
Proc RECHNE
Set("Decimals",2)
Declare S1!,F!, V!,G!,S!,T!
T!=val(gettext$(Abst&))/Teile%
WhileLoop 0,(GetCount(LV&)-1) ,1
y! = sqr(val(Gettext$(LV&,&loop,5)) * 2) * Pi() / 4 ' Radius
x! = val(Gettext$(LV&,&loop,3)) * val(Gettext$(LV&,&loop,4)) 'Vier-Eck
case val(Gettext$(LV&,&loop,2))=0 : SetText LV&,&loop,2,str$(x!) 'keine Fläche dann a*b
If val(Gettext$(LV&,&loop,2))=0
SetText LV&,&loop,2,str$(Y!) 'keine Fläche dann R
Else
x!=sqr(val(Gettext$(LV&,&loop,5)) * 2) - y!
SetText LV&,&loop,2, str$(val(Gettext$(LV&,&loop,2))- x! ) 'Fläche - Rundung
EndIf
F! = F! + (val(Gettext$(LV&,&loop,2)) * val(Gettext$(LV&,&loop,0)))
S1!=S1! + (val(Gettext$(LV&,&loop,2)) * val(Gettext$(LV&,&loop,0)) * val(Gettext$(LV&,&loop,1)))
EndWhile
If (F!=0) OR (S1!=0)
MessageBox("Eingaben fehlen,\noder dürfen nicht Null sein.\n\nBitte Ändern!","Hinweis",32)
RETURN
EndIf
V!= F!*2/3*val(gettext$(Abst&))/Teile%
SetText LV1&,0,1,str$(V!)
S!=S1!/F!*val(gettext$(Abst&))/Teile%
SetText LV1&,1,1,str$(S!)
G!=V!*val(gettext$(Spez&))
SetText LV1&,2,1,str$(G!)
SetText LV1&,3,1,str$(S!*G!)
EndProc
Proc NUMWERT
' AUSWERTUNG auf Zeichen und Stellen
Parameters ED.N&,ED.N%
var n.a$="abcdefghijklmnopqrstuvwxyz"
n.a$=n.a$+Upper$("abcdefghijklmnopqrstuvwxyz")
n.a$=n.a$+"!§$%&/()=?´´*':;-_²³{[]}\^°<>|++-"
var n.c$=""
WhileLoop len(n.a$)
n.c$ = MID$(n.a$,&Loop,1) ' c$= der nte Stringteil
Settext ED.N&,@Translate$(gettext$(ED.N&),n.c$,"") ' unzulässige löschen
Settext ED.N&,@Translate$(gettext$(ED.N&),"..",".") ' doppelte löschen
Settext ED.N&,@Translate$(gettext$(ED.N&),",,",",") ' doppelte löschen
EndWhile
Settext ED.N&,@Translate$(gettext$(ED.N&),",",".")
n.a$=trim$(gettext$(ED.N&))
WhileLoop ED.N%+1
@Match$("~.", n.a$)
If (%MatchPos>0) AND (%MatchPos<ED.N%+1)
n.a$="0"+n.a$
EndIf
EndWhile
If len(n.a$)=ED.N%
case @IsKey(8):n.a$=left$(n.a$,len(n.a$))
casenot @IsKey(8):n.a$=left$(n.a$,ED.N%)+"."
EndIf
SetText ED.N&,n.a$
sendmessage(ED.N&,$00B1,len(gettext$(ED.N&)),len(gettext$(ED.N&))+1) 'Cursor ans Ende
SetFocus(ED.N&)
EndProc
Alles anzeigen
Vielleicht wirds gebraucht.