how to make a window to always on top of all the other window

Discussion in 'Win32' started by vidhya, May 17, 2007.

  1. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    hi

    i created one window and i put some text which will scroll in the window.
    what i want is this window should always be on top of every other windows which are opened.the user should be able to see the scrolling text in the window ,watever the user may be doing.please help me , how to do this.
    its very urgent.

    regards
    vidhya
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    Use the API SetWindowPos to do the same.
     
  3. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    thanks shabbir
     
  4. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    i tried with SetWindowPos() , i am not clear about what value should pass to uflags argument,i tried with SWP_NOMOVE option. but then also if i open different window like IE or different winow of different application,it is not remaining on top.

    the window which i created is like banner , i want the user should always able to see this banner window regardless of whichever window he may open.

    please help me out to do this.

    regards
    vidhya
     
  5. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    You need to have something like SWP_NOREDRAW | SWP_SHOWWINDOW

    As a sample you can have it like
    Code:
    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, width, height, SWP_NOREDRAW | SWP_SHOWWINDOW);
     
  6. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    i tried with the same sample function.but it is not working.whenever i open new window like Internet Explorer or any other window it will not remain on top.the code is executing fine , but it is not working as i want.
    do u know any solutions for this,please help me out.
     
  7. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    The thing should be done with the SetWindowPos and if its not working something somewhere else is wrong.
     
  8. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    thanks for reply. i will try once again with setwindowpos.
    i want to know is this is the only way to do.
     
  9. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    To make it topmost its the only possible way as far as I know.
     
  10. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    ok . thank you.
     
  11. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    hi . thanks a lot it is working properly now.

    regards
    vidhya
     
  12. tiger12506

    tiger12506 New Member

    Joined:
    Jun 6, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Umm - I'm guessing that you haven't tried the style
    WS_EX_TOPMOST

    Especially considered that SetWindowPos will only set it when you call it
    Any window that opens up will open on top of it and you will need to call it again. Very inefficient it would be to constantly be calling SetWindowPos...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice