St_W wrote:spartacus13012 wrote:[..] I ended up making that I wanted: one which opens as ' encodes snipplets ' and which shows every ' TODO: contained in a file.
Now I would like to see the functioning of an addin which would intercept evenements keyboard and mouse in editeur of text of fbedit.
A generous ame would have it deja had resoudre has this probleme.
Your approach does not work because of multiple reasons:
1. there is no single edit control - a new edit control is created for each new file opened. lpHANDLES->hred is zero at plugin initialization
2. the RAEdit control consists of multiple child-windows, which receive and handle most window messages. the probably most important one is RAEditChild, which contains the editor window. For some reason there are 2 such RAEditChild windows - you could look into the RAEdit source code to find out why and what it does.
You can do it like this:
1. specify HOOK_CREATEEDIT to receive notifications on RAEdit control creation
2. handle AIM_CREATEEDIT:
2.a: Retrieve RAEditChild window handles from RAEdit window handle (passed as wParam)
2.b: Subclass the child window
2.c: Save the old wndProc
3. Call the old wndProc in the new wndProc
Some concept code:Code: Select all
#Include Once "windows.bi"
#include once "win/richedit.bi"
#include once "win/commctrl.bi"
#Include Once "fbedit/raedit.bi"
#Include Once "fbedit/addins.bi"
Dim Shared As Integer lpOldWndProcEdit
'FBedit Addin Variables
Dim Shared hooks as ADDINHOOKS
Dim Shared lpHandles as ADDINHANDLES ptr
Dim Shared lpFunctions as ADDINFUNCTIONS ptr
Dim Shared lpData as ADDINDATA Ptr
Function InstallDll CDECL alias "InstallDll" (byval hWin as HWND,byval hInst as HINSTANCE) as ADDINHOOKS ptr EXPORT
lpHandles = Cast(ADDINHANDLES ptr, SendMessage(hWin, AIM_GETHANDLES, 0, 0))
lpData = Cast(ADDINDATA ptr, SendMessage(hWin, AIM_GETDATA, 0, 0))
lpFunctions = Cast(ADDINFUNCTIONS ptr, SendMessage(hWin,AIM_GETFUNCTIONS, 0, 0))
OutputDebugString("TEST: Install")
'DebugBreak()
Dim tmp As String
tmp = Str(lpHandles->hred)
OutputDebugString(StrPtr(tmp))
hooks.hook1 = HOOK_CREATEEDIT
hooks.hook2 = 0
hooks.hook3 = 0
hooks.hook4 = 0
return @hooks
End Function
Function WndProcEdit(ByVal hWin_ As HWND, _
ByVal uMsg_ As UINT, _
ByVal wParam_ As WPARAM, _
ByVal lParam_ As LPARAM) As Integer
'Dim As String wmName
'wmName = "TEST: edit ctl wndProc "+getWMName(uMsg_)
'OutputDebugString(StrPtr(wmname))
Select Case uMsg_
Case WM_LBUTTONDOWN
OutputDebugString("TEST: 2 bouton souris dans edit")
End Select
Return CallWindowProc(lpOldWndProcEdit, hWin_, uMsg_, wParam_, lParam_)
End Function
Function DllFunction CDECL alias "DllFunction" (byval hWin as HWND,byval uMsg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as bool EXPORT
Select Case uMsg
Case AIM_CREATEEDIT
OutputDebugString("TEST: EditCreated")
Dim As String tmp
tmp = "TEST: Edit Ctl hWnd " + hex(wParam, 8)
OutputDebugString(StrPtr(tmp))
Dim As HWND editChildhWnd, editChildhWnd2
editChildhWnd = FindWindowEx(wParam, 0, @"RAEditChild", 0)
editChildhWnd2 = FindWindowEx(wParam, editChildhWnd, @"RAEditChild", 0)
tmp = "TEST: Edit Child 1 Ctl hWnd " + Hex(editChildhWnd, 8)
OutputDebugString(StrPtr(tmp))
tmp = "TEST: Edit Child 2 Ctl hWnd " + Hex(editChildhWnd2, 8)
OutputDebugString(StrPtr(tmp))
lpOldWndProcEdit = SetWindowLong(editChildhWnd2, GWL_WNDPROC, @WndProcEdit)
end select
return FALSE
End Function
Thank you for the answer I am going to try in succession