StringGadget
Verfasst: 25.03.2006 02:16
wie kann ich das machen das ich in einem stringgadget scrollen kann ( eingabe feld (sowas wie ein editor solls werden))
Das geht nur mit dem Editor-Gadget.Mathias-Kwiatkowski hat geschrieben:cool, kann ich auch bestimmte felder einfärben??
z.b. das wort hallo
Code: Alles auswählen
If OpenWindow(0,0,0,322,150,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"EditorGadget") And CreateGadgetList(WindowID(0))
EditorGadget(0,8,8,306,133)
For a=0 To 5
AddGadgetItem(0,a,"Line "+Str(a))
Next
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Noe . Es geht auch mit dem Stringgadget, nur nicht so toll ...ts-soft hat geschrieben:Das geht nur mit dem Editor-Gadget.Mathias-Kwiatkowski hat geschrieben:cool, kann ich auch bestimmte felder einfärben??
z.b. das wort hallo
Code: Alles auswählen
;///////////////////////////
;/ Declare variables
Define WindowTitle.s = "Test"
Define CX.l = 500
Define CY.l = 500
Define *hWindow.long = 0
Define *hEditor.long = 0
Define WindowEvent.l = 0
Global *hFont.long = 0
Structure char
c.c
EndStructure
;/
Procedure SetCallbackEx(hWnd.l,Proc.l)
Protected OldProc = SetWindowLong_(hWnd,#GWL_WNDPROC,Proc)
If OldProc
SetWindowLong_(hWnd,#GWL_USERDATA,OldProc)
EndIf
ProcedureReturn OldProc
EndProcedure
;/
Procedure EditorCallback(hWnd,uMsg,wParam,lParam)
Protected OldProc = GetWindowLong_(hWnd,#GWL_USERDATA)
Protected rect.rect , txtr.TEXTRANGE , FontSize.size
Protected iLen.l , nLine.l , hdc.l , hRgn.l , hOldRgn.l
Protected KeyWord.s, KeyWLen.l , *Char.char , start
Protected FirstChar.l
if #WM_PAINT = uMsg
HideCaret_(hWnd)
CallFunctionFast(OldProc,hwnd,uMsg,wparam,lparam)
hdc = GetDC_(hWnd)
SendMessage_(hWnd,#EM_GETRECT,0,@rect)
SetBkMode_(hdc,#TRANSPARENT)
hRgn = CreateRectRgn_(rect\left,rect\top,rect\right,rect\bottom)
hOldRgn = SelectObject_(hdc,hRgn)
nLine = SendMessage_(hWnd,#EM_CHARFROMPOS,0,@rect)
nLine = SendMessage_(hWnd,#EM_LINEFROMCHAR,nLine,0)
nLine = SendMessage_(hWnd,#EM_LINEINDEX,nLine,0)
SelectObject_(hDC,*hFont\l)
txtr\chrg\cpMin = nLine
txtr\chrg\cpMax = SendMessage_(hwnd,#EM_CHARFROMPOS,0,@rect\right)
*buffer = AllocateMemory(10240)
txtr\lpstrText = *buffer
iLen = SendMessage_(hWnd,#EM_GETTEXTRANGE,0,@txtr)
*Char = *buffer
While *Char\c
if *Char\c = 32 or *Char\c = 13 or *Char\c = 9
*Char\c = 0
endif
*Char + 1
Wend
Keyword.s = ""
*Char = *buffer
While iLen > 0
KeyWord = peeks(*char)
KeyWLen = len(Keyword)
select LCase(KeyWord)
case "hallo"
SetTextColor_(hdc,$0000FF)
draw = #true
case "du"
SetTextColor_(hdc,$FF0000)
draw = #true
case "da"
SetTextColor_(hdc,$0080FF)
draw = #true
EndSelect
if draw
start = *Char - *buffer + nLine
SendMessage_(hWnd,#EM_POSFROMCHAR,rect,start)
DrawText_(hdc,@Keyword,KeyWLen,@rect,0)
draw = #false
endif
*Char + KeyWLen + 1
iLen - KeyWLen - 1
if iLen <= 0
break
endif
if *Char\c = 0
while *Char\c = 0
*Char + 1
iLen - 1
if iLen <= 0
break
endif
wend
endif
Wend
FreeMemory(*buffer)
DeleteObject_(hRgn)
SelectObject_(hdc,hOldRgn)
ReleaseDC_(hWnd,hdc)
ShowCaret_(hWnd)
else
ProcedureReturn CallFunctionFast(OldProc,hWnd,uMsg,wParam,lParam)
endif
ProcedureReturn CallFunctionFast(OldProc,hwnd,umsg,wparam,lparam)
EndProcedure
;///////////////////////////
;/ Open window
*hWindow = OpenWindow(#PB_Any,#PB_Ignore,#PB_Ignore,CX,CY,WindowTitle)
;///////////////////////////
;/ Gadgets
CreateGadgetList(*hWindow\l)
*hEditor = EditorGadget(#pb_any,0,0,cx,cy)
SetCallbackEx(*hEditor\l,@EditorCallback())
*hFont = LoadFont(#pb_any,"system",12)
SendMessage_(*hEditor\l,#WM_SETFONT,*hFont\l,1)
SendMessage_(*hEditor\l,#EM_SETLIMITTEXT,-1,0)
for n = 0 to 60
string.s + " Hallo du da ! Hallo du da ! Hallo du da ! Hallo du da ! Hallo du da ! " + #LF$
next
SetGadgetText(*hEditor,string)
;///////////////////////////
;/ Window eventloop
Repeat
WindowEvent = WaitWindowEvent()
Until WindowEvent = #WM_CLOSE
;///////////////////////////
;/ Exit application
End
Achja, das Anfaengerforum . ich ueberlese das jedesmalts-soft hat geschrieben:>> Noe . Es geht auch mit dem Stringgadget, nur nicht so toll ...
Okay, wußte ich nicht, ist aber auch nicht so Einsteigerfreundlich