locked
SetParent()

    Question

  • Any idea how to correctly use of SetParent() to make a window of my process a child window of another process?

    What I am trying to achieve is make a HUD application for poker. So my app has to display user stats on top of the poker app window.

    What I do is:

    fhWnd = FindWindow(_T("Notepad"), NULL);
    
     hWnd = CreateWindowEx(WS_EX_TOPMOST , _T("test"), _T("test"),
            WS_POPUP,
            20, 20, 400, 400, NULL, NULL, hInst, NULL);
    
     SetParent(hWnd, fhWnd);
    
     DWORD style = GetWindowLong(hWnd, GWL_STYLE);
     style = style & ~(WS_POPUP);
     style = style | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
     SetWindowLong(hWnd, GWL_STYLE, style);
     SetWindowLong(fhWnd, GWL_STYLE, GetWindowLong(fhWnd, GWL_STYLE) | WS_CLIPCHILDREN);

    However in order to see what I drawn in my window I have to move the parent window out of the screen and back in again.

    Any ideas how to do this right?


    • Edited by Stav_9 Wednesday, December 26, 2012 6:20 AM
    Wednesday, December 26, 2012 6:10 AM

Answers