Im Augenblick werden (fast) alle Tastatureingaben direkt auf den Bildschirm (Listgadget) geleitet. Das Pgm füllt zunächst das Gadget mit Zeilen. Wird nun eine Taste gedrückt erscheint das Zeichen in der untersten Zeile. Soweit so gut. Wird nun Return gedrückt fängt das Gadget an zu spinnen. Nach wie vor sind Eingaben möglich, sie werden auch in der nächsten (unsichtbaren) Zeile angezeigt. Wird nun nochmals Return gedrückt kriegt sich alles wieder ein und das Ganze funktioniert als wäre nichts gewesen.
Hab schon alles mögliche probiert um den Fehler zu lokalisieren/zu umgehen, aber, ist irgendwie nicht. Daher ist meine Meinung, dass ein Fehler im Listgadget vorliegt und zwar genau im Übergang wenn die rechte Scrollbar erzeugt werden muss. Ich denke, da gibt's ein Counter-Problem

Code: Alles auswählen
version$="Fehler ?"
;Festlegung der Position + Größe des Hauptfensters
main_xpos.w =100
main_ypos.w =100
main_xwidth.w =600
main_ywidth.w =600
;Festlegung der Position + Größe der COM-Window
com_xpos.w =20
com_ypos.w =40
com_xwidth.w =main_xwidth-2*com_xpos
com_ywidth.w =main_ywidth-com_ypos-40
mainwin.w =0
Global comwin.w=10
Line$ =""
Line.l =1
#lib_user =1
Global GAKS.l =0
carretcntr.w =0
carretpos.w =0
key.c =0
shiftstatus.l =0
len.w =0
;Openlibrary[...]
;GetFunktion[...]
;Callfunctionfast[...] (oder prototyp)
;VB: GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
;Library "user32" öffnen:
If OpenLibrary(#lib_user, "user32")
GAKS = GetFunction(#lib_user, "GetAsyncKeyState")
EndIf
If OpenWindow(mainwin, main_xpos, main_ypos, main_xwidth, main_ywidth, version$)And CreateGadgetList(WindowID(mainwin))And InitKeyboard()
;Font festlegen:
If LoadFont(100,"Courier new",10)
SetGadgetFont(#PB_Default, FontID(100)) ; geladenen Courier 10 Zeichensatz als neuen Standard festlegen
EndIf
;List-Gadget öffnen:
ListViewGadget(comwin, com_xpos, com_ypos, com_xwidth, com_ywidth) ;<--------------------
SetGadgetColor(comwin, #PB_Gadget_BackColor,RGB(230,230,255))
SetGadgetColor(comwin, #PB_Gadget_FrontColor,RGB(0,0,255))
;...und 32 Zeilen anlegen + ausfüllen
For Line=1 To 32
AddGadgetItem(comwin, Line-1, "Line "+Str(Line-1))
Next
Line=32
SetGadgetState(comwin, CountGadgetItems(comwin)-1) ;<------------------------------------
SetGadgetState(comwin, -1) ;<------------------------------------------------------------
; The event loop. A ToolBar event is like a Menu event (as tools are shortcut for menu the most
; of the time). This is handy, as if the ToolBar buttons and the MenuItem have the same ID, then
; the same operation can be done on both action without any adds..
;
Repeat
Delay(20)
EventID = WindowEvent()
If EventID
Select EventID
;-----------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------
Case #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
;-----------------------------------------------------------------------------------------
Case 256
; Keyboard -------------------------------------------------------------------
key=EventwParam() ;Value of the key in ascii/scancode
;SHIFT-Taste ermitteln
If GAKS
shiftstatus=CallFunctionFast(GAKS, 16):;16=SHIFT-Taste
;SetGadgetItemText(mainwin, 1,RSet(Bin(shiftstatus),32,"0")+" $"+Hex(shiftstatus))
EndIf
Select key
Case $0d : ;------------------------------------------ CR --------------------
;Finde _ und entferne es
If FindString(s$,"_",0) > 0
len=Len(s$)
s$=Left(s$,len-1)
EndIf
SetGadgetItemText(comwin, Line-1, s$)
Line=Line+1
AddGadgetItem(comwin, Line-1, "Line "+Str(Line-1))
SetGadgetState(comwin, Line-1) ;<------------------------------------
SetGadgetState(comwin, -1) ;<------------------------------------
carretcntr=0
key=0
Case $30 To $39 : ;----------------------------------- 0..9 ------------------
If (shiftstatus&$8000)>0 : ;SHIFT ist gedrückt
key=0
EndIf
Case $41 To $5A : ;----------------------------------- A..Z a..z -------------
If (shiftstatus&$8000)=0 : ;SHIFT ist nicht gedrückt
key=key+$20
EndIf
Default
key=0
EndSelect
If key>0
s$=GetGadgetItemText(comwin, Line-1)
;Finde _ und entferne es
If FindString(s$,"_",0) > 0
len=Len(s$)
s$=Left(s$,len-1)
EndIf
SetGadgetItemText(comwin, Line-1, s$+Chr(key))
EndIf
;-----------------------------------------------------------------------------------------
EndSelect
EndIf
;Stelle fest ob vor einem Buchstaben ein _ ist:
s$=GetGadgetItemText(comwin, Line-1)
len=Len(GetGadgetItemText(comwin, Line-1))
p.w=FindString(s$,"_",0)
If (p>0)And(l>p)
s$=Mid(s$,0,p-1)+Right(s$,1)
SetGadgetItemText(comwin, Line-1, s$+" ")
SetGadgetItemText(comwin, Line-1, s$)
carretcntr=0
EndIf
; Bei carretcntr=0 ein _ anhängen
If carretcntr=0
s$=GetGadgetItemText(comwin, Line-1)
p=FindString(s$,"_",0)
If p=0
SetGadgetItemText(comwin, Line-1, s$+"_")
EndIf
EndIf
; Ein vorhandenes _ löschen
If carretcntr=15
s$=GetGadgetItemText(comwin, Line-1)
p.w=FindString(s$,"_",0)
If p>0
s$=Mid(s$,0,p-1)
SetGadgetItemText(comwin, Line-1, s$+" ")
SetGadgetItemText(comwin, Line-1, s$)
EndIf
EndIf
; Zähler inkrementieren
carretcntr=carretcntr+1
; ...und begrenzen
If carretcntr>29
carretcntr=0
EndIf
Until Quit = 1
EndIf