PDA

View Full Version : create_new_window question



kyelin
04-27-2015, 07:50 AM
I bind a exists wnd to clanlib, but the default message process function stumped me.

in win32_window.cpp func create_new_window
why not remove these code

old_wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) Win32Window::static_window_proc);

curcode:
void Win32Window::create_new_window(const DisplayWindowDescription &desc)
{
allow_screensaver = desc.get_allow_screensaver();

if (desc.get_handle())
{
hwnd = desc.get_handle();
destroy_hwnd = false;
// old_wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
// SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) OpenGLWindowProvider_WGL::message_handler);
}
else
{
register_window_class();
...

rombust
04-28-2015, 09:08 AM
Usually when you provide an existing hwnd to the DisplayWindow is because a different API to ClanLib is being used, that has its own message loop.

In your message you say "why not remove these code". This code is not there? Maybe it was on an old version of ClanLib.

https://github.com/sphair/ClanLib/blob/master/Sources/Display/Platform/Win32/win32_window.cpp#L671

I haven't used ClanLib with an existing hwnd for a long time. (I used to use a MFC based window)