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

    Getting the handle of the top most window

    How can I get the topmost window handle.

    i have set the window position as follows:
    pWnd->SetWindowPos(&wndTopMost , 0,0, 0, 0, SWP_NOSIZE);

    I need to check if pWnd is topmost many times in the program. If it is not on top, I will set the window position as above.

    How can I check that?

    Thanks in advance.

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Getting the handle of the top most window

    A topmost window has WS_EX_TOPMOST extended style set.
    Code:
       DWORD dwExStyle = pWnd->GetExStyle();
       if(WS_EX_TOPMOST & dwExStyle)
       {
          // topmost window
          // ...
       }
    Note: you may want to add SWP_NOMOVE flag in SetWindowPos, as well.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Getting the handle of the top most window

    Quote Originally Posted by zuhrs View Post
    I need to check if pWnd is topmost many times in the program. If it is not on top, I will set the window position as above.
    Don't do it! It is VERY annoying!
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

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