EnableExplicit Procedure RichEditCallback(hWnd, uMsg, wParam, lParam) Protected Range.CHARRANGE Protected PrevLine.l Protected PrevLineContent.s Protected Indent.s Protected *Pointer.Character If uMsg = #WM_CHAR And wParam = #CR SendMessage_(hWnd, #EM_EXGETSEL, 0, @Range) PrevLine = SendMessage_(hWnd, #EM_EXLINEFROMCHAR, 0, Range\cpMin) - 1 PrevLineContent = GetGadgetItemText(2, PrevLine) *Pointer = @PrevLineContent Indent = "" While *Pointer\c And (*Pointer\c = 9 Or *Pointer\c = 32) Indent + Chr(*Pointer\c) *Pointer + SizeOf(Character) Wend SendMessage_(hWnd, #EM_REPLACESEL, 0, @Indent) ProcedureReturn 0 EndIf ProcedureReturn CallWindowProc_(GetWindowLongPtr_(hWnd, #GWLP_USERDATA), hWnd, uMsg, wParam, lParam) EndProcedure If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) TextGadget(1,10,10,400,20,"Drücken Sie die Tabulator- oder Leertaste und anschließend die Enter-Taste.",0) EditorGadget(2,10,30,480,210,0) SetWindowLongPtr_(GadgetID(2), #GWLP_USERDATA, SetWindowLongPtr_(GadgetID(2), #GWLP_WNDPROC, @RichEditCallback())) Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf