SFML community forums

Help => Window => Topic started by: Conny14156 on March 03, 2015, 08:10:35 am

Title: [Solved]Gain focus on a RenderWindow created with a HWND parameter
Post by: Conny14156 on March 03, 2015, 08:10:35 am
Edit:
the HWND was of WM_CHILD and thus could't be focused on. (Atleast that what I understood it as)
End of Edit





Hi, I was wondering if it was possible to get SFML focus when I press on the rendering region when the RenderWindow has been created with a HWND parameter.
Screenshot to demostrate
(http://i.imgur.com/1hLqI82.png)
HWND viewport = CreateWindowEx(0,windowDefinedName,"GameWindow",WS_CHILDWINDOW,viewPosition.x,viewPosition.y,800,600,hWnd,NULL,hInstance,NULL);
View.create(viewport);
 
What I want to do is to disable keyboard input if I do not have the "viewport" selected
if(Engine::Window.View.hasFocus())
{//inputs}
 

This is the registered class that the viewport is using
        wc.lpszClassName = windowDefinedName;
        wc.lpfnWndProc = WndProcEditorFocus;                                           
        wc.style = CS_HREDRAW | CS_VREDRAW;;                                                   
        wc.cbSize = sizeof(WNDCLASSEX);
        wc.hIcon = LoadIcon(NULL,IDI_WINLOGO);
        wc.hIconSm = 0;
        wc.hCursor = LoadCursor(NULL,IDC_ARROW);
        wc.lpszMenuName = NULL;
        wc.cbClsExtra = 0;                                                                                                             
        wc.cbWndExtra = 0;                                                                                                     
        wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);;
 
SFML 2.2
Visual C++ 12 (2013) - 32-bit
Visual Studio Express 2013 (v120)
Windows 8.1 64-bit (6.3, Build 9600)
Title: Re: Gain focus on a RenderWindow created with a HWND parameter
Post by: Mario on March 04, 2015, 12:11:51 pm
Did you try sending the proper window messages to the HWND?
Title: Re: Gain focus on a RenderWindow created with a HWND parameter
Post by: Conny14156 on March 04, 2015, 07:55:54 pm
I have subclassed? (Not sure if that the correct term)
But I have a custom WndProc for my "view"
case WM_MOUSEACTIVATE:
{
        Engine::Window.View.requestFocus();//Doesnt work
        SetFocus(Engine::Window.viewport);//The same HWND that was used for the viewport
        SetFocus(hWnd);//From the WndProc parameter hWnd
        break;
}
 
the WM_MOUSEACTIVATE does get called, but am not sure how to give sfml renderwindow the "focus"