;Autor: srod ;http://www.purebasic.fr/english/viewtopic.php?p=173872#p173872 EnableExplicit Define a Define evMask Procedure Callback(hWnd, uMsg, wParam, lParam) Protected result Protected *msgf.MSGFILTER Protected POINT.POINT Protected char Protected lineindex Protected colindex Protected col Protected row 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_(@POINT) char = SendMessage_(GadgetID(1), #EM_CHARFROMPOS, 0, @POINT) lineindex = SendMessage_(GadgetID(1), #EM_LINEFROMCHAR, char, 0) colindex = SendMessage_(GadgetID(1), #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, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) EditorGadget(1, 0, 0, WindowWidth(0), WindowHeight(0), 0) For a=1 To 5 AddGadgetItem(1, -1, "Line " + Str(a)) Next evMask = SendMessage_(GadgetID(1), #EM_GETEVENTMASK, 0, 0) SendMessage_(GadgetID(1), #EM_SETEVENTMASK, 0, evMask | #ENM_KEYEVENTS | #ENM_MOUSEEVENTS ) SetWindowCallback(@Callback()) Repeat Select WaitWindowEvent() Case #PB_Event_CloseWindow End EndSelect ForEver EndIf