Results 1 to 6 of 6

Thread: force window to stay on top

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    how can I force a window in my app to stay on top of all other windows in the same app, sort of like a floating toolbox kinda thing??

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To Stay On Top On Top put this when your app loads.
    Code:
    SetWindowPos hwndofthewindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_FRAMECHANGED Or SWP_NOMOVE
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Guest
    And of course, to do this, you will need the api function and flags as well.

    Code:
    Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos"_
      (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
      ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
      ByVal cy As Long, ByVal wFlags As Long) As Long
    
    Global Const SWP_NOMOVE = 2 
    Global Const SWP_NOSIZE = 1 
    Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE 
    Global Const HWND_TOPMOST = -1 
    Global Const HWND_NOTOPMOST = -2

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Sorry for not including the API declaration and the constants but i haven't written code in VB for a month.I am using VC++ right now and in VC++ these things don't have to be declared.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5
    Guest
    If the Constants are small numbers like 1, 2, -1 etc. I usually do not bother including them.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Why not? What if you don't remeber what the constants actually mean?
    Actually i usally skip the constant declarations myself, but that doesn't mean small flags and large flags differ, flags are flags.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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