Restored from previous forum. Originally posted by Danilo.
RichEdit uses its own class with its own
Window procedure.
You have to change that with SetWindowLong(),
BUT you have to call the original System Callback !!
See this:
Code: Select all
Global hRich, OldCallback
Procedure Callback(WindowID, Message, wParam, lParam)
result = #PB_ProcessPureBasicEvents
If WindowID = hRich
Select Message
Case #WM_RBUTTONDOWN
MessageRequester("","RIGHT Mouse Button Down",0)
;result = 0
Case #WM_CHAR
BEEP_(800,30)
;result = CallWindowProc_(OldCallback, WindowID, Message, wParam, lParam)
Default
;result = CallWindowProc_(OldCallback, WindowID, Message, wParam, lParam)
EndSelect
result = CallWindowProc_(OldCallback, WindowID, Message, wParam, lParam)
EndIf
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, #PB_Window_SystemMenu, "")
hRich = OpenRichEdit(WindowID(), 0, 0, 0, 540, 380, "Some Text") ; simple Richedit using Library Version 1.6
;RichEditBackgroundColor($0)
RichEditTextColor($FFFF00)
RichEditOptions(GetRichEditStyle(),0)
SetWindowCallback(@Callback())
If SendMessage_(hRich, #EM_SETEVENTMASK, 0, #ENM_MOUSEEVENTS) = 0 ; Should tell the Control to send MouseEvents
MessageRequester("ERROR",Str(GetLastError_()), 0) ; returns no Error, but also has no effect.
EndIf
;
; Change the Callback for RichEdit
;
OldCallback = GetWindowLong_(hRich,#GWL_WNDPROC)
SetWindowLong_(hRich,#GWL_WNDPROC,GetWindowLong_(WindowID(),#GWL_WNDPROC))
Repeat
Event = WaitWindowEvent()
If EventType() = #PB_EventType_RightClick ; doesn't work either (i didn't expect it to)
MessageRequester("", "Click", 0)
EndIf
Until Event = #PB_EventCloseWindow
EndIf
End
Its very important to make the Callback like shown.
You have to call the original RichEdit Callback,
so it can process the message.
You can make it like it is now, or like the 3 commented lines.
So you can FORWARD some messages to RichEdit: result = CallWindowProc_(...
or BLOCK some Messages from it: result = 0 ; without calling original Callback
Start my modified version, right click on the RichEdit window
and start to type something in the Edit field (#WM_CHAR).
Hope it helps...
cya,
...Danilo
(registered PureBasic user)