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

Author Topic: Get win32 window handle (HWND) *SOLVED*  (Read 21394 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get win32 window handle (HWND) *SOLVED*
« Reply #15 on: July 15, 2010, 11:10:28 pm »
I finally implemented sf::Window::GetSystemHandle() in SFML 2
Laurent Gomila - SFML developer

hadesfury

  • Newbie
  • *
  • Posts: 1
    • View Profile
Get win32 window handle (HWND) *SOLVED*
« Reply #16 on: September 15, 2010, 04:09:47 pm »
Quote from: "iiingo"


Well.. now it's possible to access the window handle from a sf::Window, but probably you'll want to be able to do sf::RenderWindow->GetWindowHandle() so lets do our last hack:
( sf::RenderWindow uses private inheritance from sf::Window so it will not be possible to just call GetWindowHandle() from the base class ).

FILE: src\SFML\Graphics\RenderWindow.hpp
Code: [Select]

public:
WindowHandle GetWindowHandle(void);


FILE: \src\SFML\Graphics\RenderWindow.cpp
Code: [Select]

WindowHandle RenderWindow::GetWindowHandle( void ) const {
return Window::GetWindowHandle();
}


That's it! now recompile sfml, if you're on Linux or Mac you must add the GetWindowHandle() method to the other window creation methods to get this code to work.

/ iiingo


Just because this code help me a lot to make the port to SFML ... I think it's quite obvious but you need to add the const keyword to the function in RenderWindow.hpp


FILE: src\SFML\Graphics\RenderWindow.hpp
Code: [Select]

public:
WindowHandle GetWindowHandle(void) const;