English
Forum

Excelverschnitt

 

Andreas
Koch
Hello together,

here have I something program, what with bisschen gutem sake as Excelverschnitt bezeichnen could. fundamentally and in principle functions it already, had but yet some Improvements necessary. who joke on it has, can itself there Yes time moreover dran calm. I personally had on it interest, How one find out can, in which slot and row itself the Editfeld with the lever Getvar(0) befindet. I have there already all sorts of things ausprobiert, but nothing has really reliably functions. then could to the unsichtbare List view too over these Edits describe (so with Gleichheitszeichen How with Excel).

lovely Greeting

Andreas cook
CompileMarkSeparation
'Programmaufbau: 2 Listviews gleicher Größe, ein sichtbares und ein unsichtbares. Über einen Rechtsklick kann man im Editfeld die unsichtbare Listview beschreiben (der Text wird erst eingebracht, wenn das Editfeld mit Return verlassen wird),
'mit einem linken Doppelklick wird das sichtbare Listview beschrieben. Aktualisieren läuft über das unsichtbare Listview und setzt den berechneten Wert in die sichtbare Listview ein.
'Aktualisiert wird nach dem Editieren von jeder der beiden Listviews. Man kann Verlinkungen in die unsichtbare Listview einfügen: Syntax (z.B.: $C 1$, $A 2$+$D 3$....)
'Berechnet werden können +,-,*,/,Potenzen und Klammern.
 $H LISTVIEW.ph
 $H Messages.ph
 $H Windows.ph
 $I LISTVIEW_Funktionen.Inc
 $I User.Inc
VAR LVDLL& = UseDll("Listview.dll")
@Set("ListDel", "|")
Set("Decimals",2)
WindowStyle 512
Window 0,0-%maxx,%maxy
Declare ende%, Text#, Editable#,Bereich#, CP#, mkey&,Text$, Edit&, Zeile&, Spalte&
Declare Formeledit&, Aktualisieren&, sp_max&, z_max&
Dim CP#, 320
dim Editable#,64
Dim Bereich#,16
Dim Text#,256
var LV1&= CREATELISTVIEW(%hwnd, %HINSTANCE, 0, MixRGBs(~GetSysColor(24),$00ffffffff), -1, $21)
var LV2&= CREATELISTVIEW(%hwnd, %HINSTANCE, 0, MixRGBs(~GetSysColor(24),$00ffffffff), -1, $21)
Formeledit&=Create("Edit",%hwnd,"",%maxx*0.01, %maxy*0.01, %maxx*0.98, %maxy*0.03)
IColumn(LV1&,0,30,2)
IColumn(LV2&,0,30,2)

WhileLoop 63

    if &loop<=24

        Text$=Chr$(64+&Loop)

    ElseIf &loop<=48

        Text$="A"+Chr$(64+&Loop-24)

    ElseIf &loop<=72

        Text$="B"+Chr$(64+&Loop-48)

    EndIf

    IColumn(LV1&,ADDR(Text$),60,2)
    IColumn(LV2&,ADDR(Text$),60,2)
    Byte Editable#,&loop=1

EndWhile

EnableEdits(LV1&,7)
SelectColumnEdits(LV1&,Editable#)
EnableEdits(LV2&,7)
SelectColumnEdits(LV2&,Editable#)

WhileLoop 150

    AddString(LV1&,Str$(&loop))
    AddString(LV2&,Str$(&loop))

EndWhile

ShowListview(LV1&, %maxx*0.01, %maxy*0.15, %maxx*0.98, %maxy*0.78)
InitMessages(%hwnd)

WhileNot Ende%

    If Aktualisieren&

        WhileLoop sp_max&

            Spalte&=&loop

            WhileLoop 0,z_max&

                Zeile&=&Loop
                Getitemtext(LV2&,Text#,Spalte&, Zeile&)
                Text$=String$(Text#,0)
                Text$=Itemrechner(Text$)

                If Val(Text$)=Int(Val(Text$))

                    Text$=SubStr$(Text$,1,".")

                Else

                    Text$=Translate$(Text$,".",",")

                EndIf

                If Text$<>""

                    Setitemtext(LV1&,Addr(Text$),Spalte&, Zeile&)

                EndIf

            EndWhile

        EndWhile

        Aktualisieren&=0

    EndIf

    WaitInput

    If %key=2

        Ende%=1

    EndIf

    mkey&=Getcontrolparas(CP#)

    If Mkey&=2

        Spalte&=Long(CP#,4)
        Zeile&=Long(CP#,8)

        If Spalte&>sp_max&

            sp_max&=Spalte&

        EndIf

        If Zeile&>z_max&

            z_max&=Zeile&

        EndIf

        Getitemtext(LV2&,Text#,Spalte&,Zeile&)
        SetText Formeledit&,String$(Text#,0)
        SetFocus(Formeledit&)

    EndIf

    While Getvar(0)

        Aktualisieren&=1

    EndWhile

    If (GetText$(Formeledit&)<>"") And ~GetAsyncKeyState($0D)

        Text$=GetText$(Formeledit&)
        Setitemtext(LV2&,Addr(Text$),Spalte&,Zeile&)
        SetText Formeledit&,""
        Text$=Itemrechner(Text$)
        Text$=Translate$(Text$,".",",")
        Setitemtext(LV1&,Addr(Text$),Spalte&, Zeile&)
        Aktualisieren&=1

    EndIf

EndWhile

CloseMessages(%hwnd)
FreeDLL LVDLL&

Proc Itemrechner

    Parameters Formel$
    Declare Teilformeln$[], Sizeteilformel%, Formel#, Stufe%, Schreibmodus%, Stufen_Nr%,Platzhalter$, Lastschreibmodus%, Check%, Size%, aux$, Zahlen![], Operatoren$[],LoopEnde%, Ans!,Check%[]
    Declare Spalte$, Zeile$, N1$, N2$, Spalte&, Zeile&, Text#
    Dim Text#,256
    Formel$=Translate$(Formel$,",",".")

    WhileNot SubStr$(SubStr$(Formel$,2,"$"),1," ")=""

        Spalte$=SubStr$(SubStr$(Formel$,2,"$"),1," ")
        Zeile$=SubStr$(SubStr$(Formel$,2,"$"),2," ")

        If SizeOf(Spalte$)=1

            Spalte&=Ord(Spalte$)-64

        ElseIf SizeOf(Spalte$)=2

            Spalte&=(Ord(Spalte$)-64)*24+Ord(SubStr$(Spalte$,2))-64

        EndIf

        Zeile&=Val(Zeile$)-1
        Getitemtext(LV2&, Text#, Spalte&, Zeile&)

        If String$(Text#,0)=""

            Getitemtext(LV1&, Text#, Spalte&, Zeile&)

        EndIf

        Formel$=Translate$(Formel$,"$"+Spalte$+" "+Zeile$+"$",Itemrechner(String$(Text#,0)))

    EndWhile

    '
    SetSize  Teilformeln$[],Len(Formel$,"(")+1
    Teilformeln$[0]=Formel$
    Size%=0

    whileloop 0,SizeOf(Teilformeln$[])-2,1

        Stufe%=&loop
        Stufen_Nr%=Stufe%
        aux$=Teilformeln$[Stufe%]

        WhileLoop SizeOf(aux$)

            check%=1
            Lastschreibmodus%=Schreibmodus%

            if SubStr$(aux$,&loop)="("

                Inc Schreibmodus%

            ElseIf   SubStr$(aux$,&loop)=")"

                Dec Schreibmodus%

            EndIf

            if (Schreibmodus%=1) And (Lastschreibmodus%=0)

                Inc Size%
                Stufen_Nr%=Size%
                Platzhalter$="§"+Str$(Stufen_Nr%)
                check%=0

            ElseIf (Schreibmodus%=0) And (Lastschreibmodus%=1)

                Stufen_Nr%=Stufe%
                Teilformeln$[Stufen_Nr%]=Translate$(Teilformeln$[Stufen_Nr%],"("+Teilformeln$[Size%]+")",Platzhalter$)
                check%=0

            EndIf

            If (Stufen_Nr%<>Stufe%) And check%

                Teilformeln$[Stufen_Nr%]=Teilformeln$[Stufen_Nr%]+SubStr$(aux$,&loop)

            EndIf

        EndWhile

    EndWhile

    WhileLoop SizeOf(Teilformeln$[])-2,0,-1

        aux$=""
        Stufe%=&loop
        Clear Operatoren$[], Zahlen![]

        WhileLoop SizeOf(Teilformeln$[&loop])

            If (SubStr$(Teilformeln$[Stufe%],&loop)="+") Or (SubStr$(Teilformeln$[Stufe%],&loop)="-") Or (SubStr$(Teilformeln$[Stufe%],&loop)="*") Or (SubStr$(Teilformeln$[Stufe%],&loop)="/") Or (SubStr$(Teilformeln$[Stufe%],&loop)="^")

                Operatoren$[SizeOf(Operatoren$[])]=SubStr$(Teilformeln$[Stufe%],&loop)

                if SubStr$(aux$,2,"§")<>""

                    Zahlen![SizeOf(Zahlen![])]=Val(Teilformeln$[val(SubStr$(aux$,2,"§"))])

                Else

                    Zahlen![SizeOf(Zahlen![])]=Val(aux$)

                EndIf

                aux$=""

            Else

                aux$=aux$+SubStr$(Teilformeln$[Stufe%],&loop)

            EndIf

        EndWhile

        if SubStr$(aux$,2,"§")<>""

            Zahlen![SizeOf(Zahlen![])]=Val(Teilformeln$[val(SubStr$(aux$,2,"§"))])

        Else

            Zahlen![SizeOf(Zahlen![])]=Val(aux$)

        EndIf

        Size%=SizeOf(Zahlen![])

        WhileNot Size%=1

            Calculate

        EndWhile

        Teilformeln$[&loop]=str$(Zahlen![0])

    EndWhile

    Proc Calculate

        Declare aux$[], aux![], Operator%,Check%
        Check%=1

        WhileLoop 0,SizeOf(Operatoren$[])-1,1

            Operator%=&loop

            If Operatoren$[&loop]="^"

                Ausrechnen(&loop)
                Check%=0
                BREAK

            EndIf

        EndWhile

        If Check%

            WhileLoop 0,SizeOf(Operatoren$[])-1,1

                If (Operatoren$[&loop]="*") or (Operatoren$[&loop]="/")

                    Check%=0
                    Ausrechnen(&loop)
                    BREAK

                EndIf

            EndWhile

        EndIf

        If Check%

            WhileLoop 0,SizeOf(Operatoren$[])-1,1

                If (Operatoren$[&loop]="+") or (Operatoren$[&loop]="-")

                    Ausrechnen(&loop)
                    BREAK

                EndIf

            EndWhile

        EndIf

    EndProc

    Proc Ausrechnen

        Parameters Item&
        Declare Ans!

        If Operatoren$[Item&]="^"

            Ans!=Zahlen![Item&]^(Zahlen![Item&+1])

        ElseIf Operatoren$[Item&]="*"

            Ans!=Zahlen![Item&]*(Zahlen![Item&+1])

        ElseIf Operatoren$[Item&]="/"

            Ans!=Zahlen![Item&]/(Zahlen![Item&+1])

        ElseIf Operatoren$[Item&]="+"

            Ans!=Zahlen![Item&]+(Zahlen![Item&+1])

        ElseIf Operatoren$[Item&]="-"

            Ans!=Zahlen![Item&]-(Zahlen![Item&+1])

        EndIf

        Zahlen![Item&+1]=Ans!

        WhileLoop 0,SizeOf(Zahlen![])-1,1

            If &loop<Item&

                aux![&loop]=Zahlen![&loop]

            Elseif &loop>Item&

                aux![&loop-1]=Zahlen![&loop]

            EndIf

        EndWhile

        WhileLoop 0,SizeOf(Operatoren$[])-1,1

            If &loop<Item&

                aux$[&loop]=Operatoren$[&loop]

            Elseif &loop>Item&

                aux$[&loop-1]=Operatoren$[&loop]

            EndIf

        EndWhile

        Clear Operatoren$[], Zahlen![]
        SetSize Operatoren$[],SizeOf(aux$[])
        SetSize Zahlen![],SizeOf(aux![])
        Size%=SizeOf(Zahlen![])

        WhileLoop 0,SizeOf(aux$[])-1,1

            Operatoren$[&loop]=aux$[&loop]

        EndWhile

        WhileLoop 0,SizeOf(aux![])-1,1

            Zahlen![&loop]=aux![&loop]

        EndWhile

    ENDPROC

    Return Teilformeln$[0]

ENDPROC

End
 
04/22/13  
 




Andreas
Koch
Perhaps ought to I mean question once more explizit formulieren...
knows someone a Possibility to find out, in which slot and row itself the Editfeld with the lever Getvar(0) befindet?
 
04/24/13  
 



Regards!

look time whether you Getvar(4) The slot returns,

You can also userMessage $1405 define and then standing in &uwParam
The Spaltennummer and &ulParam The Zeilennummer.

then there too yet The function GetSelected( ...
 
04/24/13  
 




Thomas
Freier
Hmmm. The Ansatz is ok, but
$H LISTVIEW.ph
$H Messages.ph
$H windows.ph
$I LISTVIEW_Funktionen.Inc
sees to one mixed of uralt List view, List view.dll and GridBOX from.
in the principle reicht The List view.dll and the Item, in the one simply- semidetached- left- right Click instead of found, have (can) You with
CompileMarkSeparation
mkey&=Getcontrolparas(CP#)
Spalte&=Long(CP#,4)
Zeile&=Long(CP#,8)re>
already determined.

now Text(worth) or Formel to ENTER in that chosen Item in LV1&, or., LV2&, take, and ggf. Neuberechnung.
 
Gruß Thomas
Windows XP SP2, XProfan X2
04/24/13  
 




Andreas
Koch
this is everything correctly. and functions too tadellos. The problem is, that these values not updated go, if one with the Pfeiltasten or the tabulator the Item changes. I have even already a Keyhook ausprobiert and "mitgezählt", the funktionierte but neither reliably. Also have I attempts mithilfe the position the Edits relatively to that List and whom visible Split and Lines To works, the functions but only for slot reliably not for row.
 
04/24/13  
 




Thomas
Freier
i'd on The Pfeiltasten or TAB dispense. ItemEdit in the gewähltem Item produce and with ENTER whom Content in that Item take. with Esc or ItemEdit lose whom Focus EDIT delete and nothing take, except FormelEdit get whom Focus and should with Enter or one Button The Formel übenehmen. with Esc or IFormelEdit lose whom Focus again everything verwerfen.
for that ItemEdit use I z.B.:
CompileMarkSeparation
Clear bereich1#
a$=trim$(GetText$(FAHRTEN_FLLV&,Zeile&,Spalte&))'alter Inhalt
GetOwnControlParas(bereich1#,FAHRTEN_FLLV&,Spalte&,Zeile&)
op.x&=Long(bereich1#,12)'X Offset
op.y&=Long(bereich1#,16)'Y Offset
op.b&=Long(bereich1#,20)'Breite
op.h&=Long(bereich1#,24)'Höhe
Var Ede_del2&= @Create("Edit", FAHRTEN_FLLV& ,"",0,0,op.b&,op.h&)
SetWindowPos Ede_del2&=op.x&,op.y&
settext  Ede_del2&,a$
Var _del1& = @Create("Tooltip", %hWnd , FAHRTEN_FLLV& ,"Esc=Abbruch, Wert mit Enter übernehmen.")
SetFont _del1&,d_Font&
Setfocus(Ede_del2&)

While 1

    WaitInput
    case iskey(27):BREAK'Abbruch ESC

    Ifnot getfocus(Ede_del2&)

        ' hier würde ich ins FormelEdit springen
        BREAK

    EndIf

    If iskey(13)'Speichern Enter gedrückt

        SetText FAHRTEN_FLLV&,Zeile&,Spalte&,trim$(GetText$(Ede_del2&))       ................
 
Gruß Thomas
Windows XP SP2, XProfan X2
04/25/13  
 




Thomas
Freier
I have me The Examples in the list view-pkg respected. the example "Eigene_Eingaben.prf" should still your Wish correspond to.
One Itemwechsel goes but only over The TAB-Button. The Pfeiltasten, How generally validly in a Edit, steer only The Curserpos. in the Edit.
 
Gruß Thomas
Windows XP SP2, XProfan X2
04/25/13  
 




Andreas
Koch
I have already to this example sought, But not find can. can you me communicating, where I the find?

PS: Übrigens once more thanks for eure Hilfestellung, had I beinahe forget.
 
04/25/13  
 




Thomas
Freier
I put it once here.

11 kB
Hochgeladen:04/25/13
Downloadcounter93
Download
 
Gruß Thomas
Windows XP SP2, XProfan X2
04/25/13  
 




Thomas
Freier
A small example with AddHotKey, if IsKey not goes:
CompileMarkSeparation
Declare bereich#,lvdll&,text$,x&,y&,z&,listview&
Def GetSysColor(1) !"USER32","GetSysColor"
Dim bereich#,256
var Font& = @CREATE("FONT","NEW TIMES ROMAN",14,0,0,0,0)
 $I Listview_Funktionen.inc
lvdll&=usedll("Listview.dll")
SetTrueColor 1
Window 0,0-400,400
Cls GetSysColor(15)
listview&=CreateListView(%hwnd,%hinstance,0,GetSysColor(24),-1,$31)
text$="A,B,C"
SetColumnsFromMem(listview&,addr(text$),0)
SetFont listview&,Font&

Whileloop 5

    SetItem listview&,"","",""

EndWhile

SetColumnWidth(listview&,0,100)
SetColumnWidth(listview&,1,100)
SetColumnWidth(listview&,2,100)
ShowListView(listview&,10,48,354,270)
CreateText(%hwnd,"Formel",10,8,60,22)
var FormelEdit%=CreateEdit(%hwnd,"=4+6",80,10,120,22)
var Formel_zul%=CreateButton(%hwnd,"Übernehmen",240,10,100,22)
InitMessages(%hwnd)
usermessages $1407
AddHotKey 7001, 13, 0'Return
AddHotKey 7002, 9, 0'Links
AddHotKey 7003, 9, 2'Rechts

While 1

    waitinput
    Case %key=2:BREAK
    case %umessage=$1407: EDIT &uwParam, &ulParam'Spaltenindex ,'Zeilenindex (nullbasierend)

Wend

CloseMessages(%hwnd)
freedll lvdll&
End

Proc Edit

    Parameters spalte%,zeile%
    Declare Ede_del2&,op.x&,op.y&
    INHALT
    @Create("Tooltip", %hWnd , Listview& ,"Esc=Abbruch, Wert mit Enter übernehmen.")
    Setfocus(Ede_del2&)

    While 1

        WaitInput
        case iskey(27):BREAK'Abbruch ESC

        Ifnot getfocus(Ede_del2&)

            SetText Listview&,Zeile%,Spalte%,trim$(GetText$(Ede_del2&))

            If Getfocus(FormelEdit%)

                'aus 2. Listview vorhandene Formel ins FormelEdit% und Curser ans Ende
                'SetText FormelEdit%,trim$(GetText$(Listview2&,Zeile%,Spalte%))'alter Inhalt
                DestroyWindow(Ede_del2&)

                while 1

                    waitinput
                    case iskey(27):BREAK

                    If getfocus(Formel_zul%)

                        ' Formel ins 2. Listview
                        ' Wert berechnen und ins 1.Listview
                        SetText Listview&,Zeile%,Spalte%,"10,00"
                        BREAK

                    EndIf

                wend

                SetText FormelEdit%,""

            endif

            BREAK

        ElseIf MenuItem(7001)'Speichern Enter gedrückt

            SetText Listview&,Zeile%,Spalte%,trim$(GetText$(Ede_del2&))
            BREAK

        ElseIf MenuItem(7002)'TAB vor

            SetText Listview&,Zeile%,Spalte%,trim$(GetText$(Ede_del2&))
            case Spalte%<GetColumns(Listview&)-1: inc Spalte%
            INHALT

        ElseIf MenuItem(7003)'TAB rück

            SetText Listview&,Zeile%,Spalte%,trim$(GetText$(Ede_del2&))
            case Spalte%>0 : dec Spalte%
            INHALT

        EndIf

    wend

    DestroyWindow(Ede_del2&)
    setfocus(%hwnd)

EndProc

Proc Inhalt

    DestroyWindow(Ede_del2&)
    Clear bereich#
    Text$=trim$(GetText$(Listview&,Zeile%,Spalte%))'alter Inhalt
    GetOwnControlParas(bereich#,Listview&,Spalte%,Zeile%)
    op.x&=Long(bereich#,12)'X Offset
    op.y&=Long(bereich#,16)'Y Offset
    var op.b&=Long(bereich#,20)'Breite
    var op.h&=Long(bereich#,24)'Höhe
    Ede_del2&= @Create("Edit", Listview& ,Text$,op.x&,op.y&,op.b&,op.h&)
    SetFont Ede_del2&,Font&
    Setfocus(Ede_del2&)
    SendString(Ede_del2&,"+({END})")ss=s1>'Text Mark and Cursor ans end

Endproc


If in the chosen Item in list view2 already a Formel is, would I tappt im dunkeln same in the Proc CONTENT in that FormelEdit settle. Ändert the users whom Content in the Item of List view would I The Formel and the Content the suitable Item in list view2 delete.
 
Gruß Thomas
Windows XP SP2, XProfan X2
04/25/13  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

5.515 Views

Untitledvor 0 min.
H.Brill11/15/23
Michael Hettner08/27/21
rquindt05/10/16
Christof Neuß03/17/16
More...

Themeninformationen

this Topic has 3 subscriber:

Thomas Freier (5x)
Andreas Koch (4x)
iF (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie