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

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
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.
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.
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
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
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,..