PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Always on top  (Read 341 times)

Bumblebee

  • Junior Member
  • **
  • Posts: 84
Always on top
« on: November 26, 2021, 04:24:30 PM »

How would I go about creating a window or form that remains always on top?
Logged

David Kenny

  • Senior Member
  • ***
  • Posts: 464
  • Windows 7 & 10
Re: Always on top
« Reply #1 on: November 26, 2021, 07:26:16 PM »

Take a look at SetWindowPos, the second parameter should be HWND_TOPMOST.
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9411
  • Windows 10
    • PlanetSquires Software
Re: Always on top
« Reply #2 on: November 26, 2021, 07:32:06 PM »

David beat me to it as I was testing code to post! First time I've coded in WinFBE in a while and I lost out on providing the answer. LOL

Code: [Select]
''
''
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT

   SetWindowPos( sender.hWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE )
   
   Function = 0
End Function
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

David Kenny

  • Senior Member
  • ***
  • Posts: 464
  • Windows 7 & 10
Re: Always on top
« Reply #3 on: November 26, 2021, 07:44:21 PM »

Well, since I didn't provide a tested example, your post is more useful.  :)
Logged

Bumblebee

  • Junior Member
  • **
  • Posts: 84
Re: Always on top
« Reply #4 on: November 26, 2021, 11:12:39 PM »

Excellent, this does the trick. Thanks again!
Logged

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 487
Re: Always on top
« Reply #5 on: December 01, 2021, 11:41:19 AM »

Out of pure curiosity, the TOPMOST setting in a SetwindowsPOS, will it keep your form on top no matter what?

I was wondering what happens if you call other programs or forms with that setting, or will it keep the last called one on top?
Just curious if you have more than one of these what happens?

Regards, Peter
Logged

Bumblebee

  • Junior Member
  • **
  • Posts: 84
Re: Always on top
« Reply #6 on: December 02, 2021, 11:45:36 AM »

Calling another program where it is set to always be on top, does place it on top.
Logged