netmaestro wrote:btw : I've never seen #WM_KEYFIRST used in that way before
hehe. It's incorrect but it works fine because WM_KEYDOWN is the first key message and therefore has the same value (256) as WM_KEYFIRST.
 
Ah, Netmaestro... thank you. Another secret is disclosed.
At my first tests I used WM_KEYUP together with VK_RETURN... but I got two messsges each time I pressed RETURN.
With WM_KEYFIRST I got only one message. But now I tried WM_KEYDOWN and lo... RETURN gives me only one message. Heureka...
So if you change WM_KEYFIRST with WM_KEYDOWN in my code all went okay and looks okay (I hope).  
There is a german saying: "Muehsam ernaehrt sich das Eichhoernchen."
I don't know the english pendant. Maybe "slowly but surely"  
EDIT: Here is the final version with SetProp_() and GetProp_()
Code: Select all
EnableExplicit
Global Event
#CURSORCHANGE = #WM_USER + 1
Procedure.i EditGadgetProc(hWnd, uMsg, wParam, lParam)
	Protected hParentWindow.i = GetParent_(hWnd)
	
	Select uMsg
		Case #WM_KEYDOWN
			If wParam = #VK_UP
       	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
			ElseIf wParam = #VK_DOWN
       	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
			ElseIf wParam = #VK_LEFT
       	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
			ElseIf wParam = #VK_RIGHT
       	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
			ElseIf wParam = #VK_PRIOR
       	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
			ElseIf wParam = #VK_NEXT
       	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
			ElseIf wParam = #VK_RETURN
       	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
			EndIf
		Case #WM_LBUTTONUP
     	PostMessage_(hParentWindow, #CURSORCHANGE, 0, 0)
		Default
	EndSelect
	
	ProcedureReturn CallWindowProc_(GetProp_(hWnd, "OLDPROC"), hWnd, uMsg, wParam, lParam)
	
EndProcedure
If OpenWindow(0, 100, 200, 300, 100, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	EditorGadget(0, 10, 10, 280, 80)
	SetProp_(GadgetID(0), "OLDPROC", SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @EditGadgetProc()))
	
	Repeat 
		Event = WaitWindowEvent()
		If Event = #CURSORCHANGE
			SetWindowTitle(0, "Caret in Line: " + Str(SendMessage_(GadgetID(0), #EM_LINEFROMCHAR, SendMessage_(GadgetID(0), #EM_LINEINDEX,-1,0), 0)))
		EndIf
		
	Until Event = #PB_Event_CloseWindow
EndIf
 
EDIT2: Damn, PAGE UP/DOWN does not work.  
EDIT3: Ah, it's VK_PRIOR and VK_NEXT... I completed the code above.
A big 
Thank you to all who gave me hints! 
