CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2007
    Posts
    68

    Placing a window on top of another window

    I have a window to be positioned on top pf another window.

    I have the following code:
    if (pWnd == NULL)
    {
    pWnd = FindWindow(NULL, L"Menu");
    }

    if (pWnd )
    {
    CRect lpR;
    pWnd->GetWindowRect(&lpR);
    SetWindowPos(&CWnd::wndTopMost,lpR.left,lpR.top+20,0,0,SWP_NOSIZE);
    }

    But it makes the window on top always(of all windows).

    I just need to make it on top of a particular window(if it is visible/on foreground).

    please help me regarding this

  2. #2
    Join Date
    Aug 2009
    Posts
    219

    Re: Placing a window on top of another window

    So check if that Window is Visible on the foreground?

  3. #3
    Join Date
    Apr 2007
    Posts
    68

    Re: Placing a window on top of another window

    Thanks for the reply

    I tried checking IsWindowVisible() function for the Main window. It always return true even if it is not seen on the screen.

    i tried using getForegroundWindow() also. It returns hadle to the topmost window. So it is not possible to determine if the Main window is visble in the screen.

    Is there any way to set the Z-Order of the new window one above the ZOrder of the main window?

  4. #4
    Join Date
    Aug 2009
    Posts
    219

    Re: Placing a window on top of another window

    IsWindowVisible() returns true when it is showed somewhere on the screen, no matter on top.

    Is that no what you want? GetForeGroundWindow() -> Draw your window-> Set the hwnd retrieved again on top of that?

    Off course if there are more then window on top of you, it will fail.

  5. #5
    Join Date
    Apr 2007
    Posts
    68

    Re: Placing a window on top of another window

    Is there any way to find if the window is visible in the screen. Or else how can I find out the Z-Order of a window.

    Please some one help me.
    Thanks in advance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured