SetWindowPos - Topmost form won't stay topmost?

Author Message
puf_the_majic_dragon

  • Total Posts : 7
  • Scores: 0
  • Reward points : 0
  • Joined: 5/24/2007
  • Status: offline
SetWindowPos - Topmost form won't stay topmost? Thursday, August 06, 2009 6:32 AM (permalink)
0
I have a VB application, notably Freebar, which has a setting to keep it "always on top". The code for this setting is as follows:
 
 SetWindowPos Me.hWnd, IIf(GetValueFromINI(SETTINGS_INI_SECTION, "OnTop", SettingsINI, DEFAULT_ONTOP) = "1", HWND_TOPMOST, HWND_NOTOPMOST), 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
 

 
The setting seems to work for the most part. However, it stops working periodically throughout the day - specifically, when I receive an incoming call on Apropos (I HATE that program).
 
So my question is - why doesn't Freebar stay on top? Apropos is NOT configured to be "always on top", but it does steal focus when a call comes in (even with TweakUI installed and registry tweaked). I'm wondering if one application is "topmost" and another application comes along and sets itself as "topmost", what happens to the first application? My theory is that the Apropos developers used the topmost option as a way to steal focus while circumventing Windows' settings. I have tested with Windows Task Manager set to "always on top" and when Apropos rings, task manager loses its topmost position.
 
Does anybody have any ideas on how I could work around this? I can modify the source code for Freebar if there's a change I can make that will get it to stay always on top.
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    RE: SetWindowPos - Topmost form won't stay topmost? Thursday, August 06, 2009 7:46 AM (permalink)
    0
    I think that you probably have it right and there won't be much that you can do. I would suggest complaining to Apropos. I suppose it is possible that you could have a service running that listens for an event to fire that represents a change in the windows z-order. I'm not positive that there is such an event but therer may be.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      puf_the_majic_dragon

      • Total Posts : 7
      • Scores: 0
      • Reward points : 0
      • Joined: 5/24/2007
      • Status: offline
      RE: SetWindowPos - Topmost form won't stay topmost? Friday, August 07, 2009 2:59 AM (permalink)
      0
      I've been considering modifying the source code of Freebar to periodically reset itself as topmost. I'd need to implement a loop or some sort of listener that is guaranteed to go off every 60 (or 300?) seconds and I'm not sure how to go about doing that. A listener would be preferable for performance but what event would I listen for?
       
      #3
        ebgreen

        • Total Posts : 8227
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        RE: SetWindowPos - Topmost form won't stay topmost? Friday, August 07, 2009 3:14 AM (permalink)
        0
        Like I said, I'm not even positive that there is one.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          puf_the_majic_dragon

          • Total Posts : 7
          • Scores: 0
          • Reward points : 0
          • Joined: 5/24/2007
          • Status: offline
          RE: SetWindowPos - Topmost form won't stay topmost? Friday, August 07, 2009 3:43 AM (permalink)
          0
          I was thinking of an event listener notified by the system clock every few minutes. I'm searching for how to implement a clock listener in vb but so far haven't found anything.
           
          :edit:
          I found this page (FINALLY) http://support.microsoft.com/kb/231298 which explains how to use a waitable timer in VB. Now the question is will that timer make the applicaton unresponsive when it's running - should I put that in a separate thread in the application?
           
          ... I can already see it coming - I'm going to have to teach myself threading in VB while teaching myself VB... with no IDE.
          <message edited by puf_the_majic_dragon on Friday, August 07, 2009 4:19 AM>
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9