Seite 1 von 1

StringGadget

Verfasst: 25.03.2006 02:16
von Mathias-Kwiatkowski
wie kann ich das machen das ich in einem stringgadget scrollen kann ( eingabe feld (sowas wie ein editor solls werden))

Verfasst: 25.03.2006 02:17
von Deeem2031
Beim Erstellen als Flag #WS_VSCROLL für vertikales Scrollen oder #WS_HSCROLL für horizontales Scrollen angeben.

Verfasst: 25.03.2006 02:24
von Mathias-Kwiatkowski
cool, kann ich auch bestimmte felder einfärben??

z.b. das wort hallo

Verfasst: 25.03.2006 02:31
von ts-soft
Mathias-Kwiatkowski hat geschrieben:cool, kann ich auch bestimmte felder einfärben??

z.b. das wort hallo
Das geht nur mit dem Editor-Gadget.

Verfasst: 25.03.2006 02:35
von Mathias-Kwiatkowski
jo des editor gadget habe ich nur wie kann ich nun wörtr einfärben=?


das habe ich gefunden

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 


Verfasst: 25.03.2006 03:51
von ts-soft
Suchste mal im CodeArchiv nach EditorGadget_Color+Styles.pb

Diese möglichkeiten sind leider nicht sehr Einsteigerfreundlich
(pure Windows API) aber vielleicht hilft Dir diese Lib von DarkDragon:

http://www.purearea.net/pb/showcase/show.php?id=113

Verfasst: 25.03.2006 04:50
von edel
ts-soft hat geschrieben:
Mathias-Kwiatkowski hat geschrieben:cool, kann ich auch bestimmte felder einfärben??

z.b. das wort hallo
Das geht nur mit dem Editor-Gadget.
Noe . Es geht auch mit dem Stringgadget, nur nicht so toll ...

Hier mal eine ganz andere Version :-)

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
  
  

Verfasst: 25.03.2006 04:53
von ts-soft
>> Noe . Es geht auch mit dem Stringgadget, nur nicht so toll ...
Okay, wußte ich nicht, ist aber auch nicht so Einsteigerfreundlich :wink:

Verfasst: 25.03.2006 04:59
von edel
ts-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 :wink:
Achja, das Anfaengerforum . ich ueberlese das jedesmal :-(.