Posted: Tue Dec 12, 2006 2:29 pm
Haven't tested the following very much and you might need to adjust which events are being trapped etc.
Your code for calculating the column wasn't quite right.
Your code for calculating the column wasn't quite right.
Code: Select all
Procedure Callback(hWnd, uMsg, wParam, lParam)
Protected result, *msgf.MSGFILTER
Result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
*msgf=lParam
Select *msgf\NMHDR\code
Case #EN_MSGFILTER
Select *msgf\msg
Case #WM_LBUTTONUP, #WM_KEYUP
GetCaretPos_(@pos.POINT)
char=SendMessage_(GadgetID(0), #EM_CHARFROMPOS, 0, @pos)
lineindex=SendMessage_(GadgetID(0), #EM_LINEFROMCHAR, char, 0)
colindex=SendMessage_(GadgetID(0), #EM_LINEINDEX, lineindex,0)
col = char-colindex
row = lineindex + 1
Debug "("+Str(col)+", "+Str(row)+")"
EndSelect
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
EditorGadget(0, 8, 8, 306, 133)
For a = 0 To 5
AddGadgetItem(0, a, "Line "+Str(a))
Next
evMask = SendMessage_(GadgetID(0), #EM_GETEVENTMASK, 0, 0)
SendMessage_(GadgetID(0), #EM_SETEVENTMASK, 0, evMask|#ENM_KEYEVENTS|#ENM_MOUSEEVENTS )
SetWindowCallback(@Callback())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf