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

Author Topic: [Solved]Gain focus on a RenderWindow created with a HWND parameter  (Read 2497 times)

0 Members and 1 Guest are viewing this topic.

Conny14156

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
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

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)
« Last Edit: March 23, 2015, 06:41:15 pm by Conny14156 »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Gain focus on a RenderWindow created with a HWND parameter
« Reply #1 on: March 04, 2015, 12:11:51 pm »
Did you try sending the proper window messages to the HWND?

Conny14156

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Gain focus on a RenderWindow created with a HWND parameter
« Reply #2 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"