Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Add additional events polling  (Read 282 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 2
    • View Profile
Add additional events polling
« on: March 10, 2020, 04:21:01 pm »
I'm writing an application to debug another process, so I want to send debug data to draw from that process to sfml renderer. As both applications are windows only, I wanted to use WM_COPYDATA events to send data.
But I can't just add such event handler: the only way, that I see to do such thing is to create OS Window by myself, writing event handler for myself including all the events sfml can handle, and then pass a window to a sf::Window.
IMO this is very unconvinient, so I ask to do a way, that I could (may be os specific) add additional events polling.

I see 2 ways of doing that:
1) (probably preferred) add some os-specific handler in sf::Window and call it whenever your inner event handler works
LRESULT sf::WindowImpl32::pollEvent(UINT msg, WPARAM wParam, LPARAM lParam) {
  if (customHandler)
    customHandler(msg, wParam, lParam);
  // do usual stuff
2) Add ability to call your event handler from the outside, so even if I'm creating OS Window by myself, I could write something like
LRESULT CALLBACK HandleWindowEvents(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  // do my stuff
  sf::Window::DefaultHandler(hwnd, msg, wParam, lParam);

May be there is another good way

« Last Edit: March 10, 2020, 04:22:56 pm by masafi »


  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Add additional events polling
« Reply #1 on: March 11, 2020, 03:42:49 pm »
Ok, I figured out that I could just create new window, hide it and use only for WM_COPYDATA event handling.
It's not as convinient as just adding event handler, but works.
Nevertheless I think you should consider adding ability to handle additional events


  • Administrator
  • Hero Member
  • *****
  • Posts: 32434
    • View Profile
    • SFML's website
    • Email
Re: Add additional events polling
« Reply #2 on: March 11, 2020, 04:15:56 pm »
Windows event handlers are made for easy chaining, so it should be doable to define your own event handler and call the SFML one inside it. No need for SFML to provide an API for this, you can retrieve it with standard Win32 calls.

Note that for inter-process communication, there are other techniques available (shared memory, local socket, ...).
Laurent Gomila - SFML developer