Ah, a happy coincidence!netmaestro wrote: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.btw : I've never seen #WM_KEYFIRST used in that way before
Editorgadget: Notification about caretmovement
Re: Editorgadget: Notification about cursormovement
I may look like a mule, but I'm not a complete ass.
						Re: Editorgadget: Notification about cursormovement
Okay, thanks for confirmationsrod wrote:PostMessage_() should be fine.
I want to keep the Callback as "tansparent" as possible to the main code.srod wrote:A strange way of structuring the program for sure. Rather than post a message I would just call a separate function in your code.
In the final Version the old GadgetProc adress should pass via SetProp_() and GetProp_() or something similar to the callback. Then the callback procedure is independent from global variables. And I can use it in different projects.
Sending messages... a small taste of OOP
srod wrote:btw : I've never seen #WM_KEYFIRST used in that way before! I though it was for use with GetMessage_() or PeekMessage_() etc.
The truth is, #WM_KEYDOWN together with #VK_RETURN genareted two messages instead one message like #WM_KEYDOWN and #VK_UP... VK_DOWN and so on.
So I tried some other message constance at random.
PB 6.12 x64, OS: Win 11 24H2 x64, Desktopscaling: 150%, CPU: I7 12700 H, RAM: 32 GB, GPU: Intel(R) Iris(R) Xe Graphics | NVIDIA GeForce RTX 3070, User age in 2025: 57y
"Happiness is a pet." | "Never run a changing system!"
						"Happiness is a pet." | "Never run a changing system!"
Re: Editorgadget: Notification about cursormovement
Ah, Netmaestro... thank you. Another secret is disclosed.netmaestro wrote: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.btw : I've never seen #WM_KEYFIRST used in that way before
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
EndIfEDIT3: Ah, it's VK_PRIOR and VK_NEXT... I completed the code above.
A big Thank you to all who gave me hints!
PB 6.12 x64, OS: Win 11 24H2 x64, Desktopscaling: 150%, CPU: I7 12700 H, RAM: 32 GB, GPU: Intel(R) Iris(R) Xe Graphics | NVIDIA GeForce RTX 3070, User age in 2025: 57y
"Happiness is a pet." | "Never run a changing system!"
						"Happiness is a pet." | "Never run a changing system!"
Re: Editorgadget: Notification about cursormovement
Uh! Netmaestro, only at this moment I realize that I used the wrong term.netmaestro wrote:You can subclass the editorgadget and look for #wm_mousemove,..
Cursor = Mousecursor
Caret = "Textmarker" within the editorgadget.
Its the caret, what I meant. I will correct the subject of this topic now.
(There is another german saying: "Alt wie eine Kuh und man lernt immer noch dazu" - sorry I don't know the english translation. Hmm, maybe this: "Old as a cow, but you always learn something new". Okay, but in english it does not rhyme.
PB 6.12 x64, OS: Win 11 24H2 x64, Desktopscaling: 150%, CPU: I7 12700 H, RAM: 32 GB, GPU: Intel(R) Iris(R) Xe Graphics | NVIDIA GeForce RTX 3070, User age in 2025: 57y
"Happiness is a pet." | "Never run a changing system!"
						"Happiness is a pet." | "Never run a changing system!"

