Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
How to override Render's wndProc
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
Have you tried adding an Application.OnMessage event to the subprocess where GlobalCEFApp.ProcessType is ptRenderer ?
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
I'm sorry.
I totally forgot that subprocesses don't execute "Application.Run" and you can't use the Application.OnMessage to intercept all the messages sent to that process.

I totally forgot that subprocesses don't execute "Application.Run" and you can't use the Application.OnMessage to intercept all the messages sent to that process.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
The easiest way to intercept all those messages is to use the OSR mode.
In normal mode you can create a hook with SetWindowsHookEx to intercept mouse or keyboard messages :
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
I don't know the Blink implementation details and I don't know why your WndProc relacement has some problems.
In normal mode you can create a hook with SetWindowsHookEx to intercept mouse or keyboard messages :
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
I don't know the Blink implementation details and I don't know why your WndProc relacement has some problems.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
I've never replaced a WndProc before but remember that you are replacing a WndProc from a different process.
Perhaps the reason why it has problems with events is that the old WndProc points to a function in a different process address space.
https://gopherproxy.meulie.net/sdf.org/ ... /ch22b.htm
Perhaps the reason why it has problems with events is that the old WndProc points to a function in a different process address space.
https://gopherproxy.meulie.net/sdf.org/ ... /ch22b.htm
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
I use one in BriskBard to handle the web browser zoom when the user clicks control and moves the wheel mouse button.Winexcel wrote: Tue Mar 13, 2018 2:21 pmThanks for the advice but the hook isn't a good solution because it required a very high perfomance.In normal mode you can create a hook with SetWindowsHookEx to intercept mouse or keyboard messages :
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
There's no problem if you just send a custom message with all the information to your form and return immediately after that.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
It's a low level mouse hook (WH_MOUSE_LL) and it needs to be global to receive the mouse messages for different processes.
This solution has been suggested several times in the official CEF forum to receive the missing mouse and keyboard events.
This solution has been suggested several times in the official CEF forum to receive the missing mouse and keyboard events.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
If I understood it correctly, SetWindowLongPtr returns the old WndProc address but that address is meaningless if it comes from a different process address space.Winexcel wrote: Tue Mar 13, 2018 4:31 pm I think It may call unexpected erros. But if I only send a message there, maybe, it will work well. Honestly, I don't know, but all these functions can be debugged, i mean wndProcBrowser, wndProcWidget, wndProcRender. But why? I don't understand it completely, if it's a different process i can't debug it from delphi debugger, isn't it?
All these functions is called by CrBrowserMain thread.
The author in the last link states that it's still possible to do this by "injecting" a DLL into a process's address space but I wouldn't be surprised if this is seen as a threat by antivirus software.
I think it's much easier to use a simple hook.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
You were right!
Reading your posts more carefully I realized I was talking about the render process when you were talking about the message loops in some components created by the CEF libraries.
I'll see if I can add your code to TChromium and TFMXChromium. This could be used to expose "OnMessage" events!
Reading your posts more carefully I realized I was talking about the render process when you were talking about the message loops in some components created by the CEF libraries.
I'll see if I can add your code to TChromium and TFMXChromium. This could be used to expose "OnMessage" events!

- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
Hi,
There are many code examples in Internet. Just search "delphi setwindowshookex example" and you will find examples like these :
http://lazplanet.blogspot.com/2016/06/h ... -your.html
http://www.delphipages.com/forum/showthread.php?t=32700
When you detect a mouse wheel event you can send a custom message to your app to call TChromium.IncZoomStep or TChromium.DecZoomStep
There are many code examples in Internet. Just search "delphi setwindowshookex example" and you will find examples like these :
http://lazplanet.blogspot.com/2016/06/h ... -your.html
http://www.delphipages.com/forum/showthread.php?t=32700
When you detect a mouse wheel event you can send a custom message to your app to call TChromium.IncZoomStep or TChromium.DecZoomStep
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to override Render's wndProc
I use it from a thread and I try to process the messages as fast as I can to call CallNextHookEx before the OS thinks that my app is not responding fast enough and removes my hook from the chain.
Read this :
https://docs.microsoft.com/en-us/window ... nmsg/hooks
https://docs.microsoft.com/en-us/window ... owshookexw
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Read this :
https://docs.microsoft.com/en-us/window ... nmsg/hooks
https://docs.microsoft.com/en-us/window ... owshookexw
https://msdn.microsoft.com/en-us/librar ... s.85).aspx