• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1485
  • Last Modified:

SetWindowPos & taskbar?


i'm using this api call to set my app on top of all others, but it is still not ontop of the taskbar.

Const HWND_TOPMOST = -1
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub SetWindowPos Lib "user32" (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)

SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE


how can i have my program above the windows taskbar?
0
Mark_FreeSoftware
Asked:
Mark_FreeSoftware
  • 3
  • 2
  • 2
  • +1
1 Solution
 
BrianGEFF719Commented:
Try this instead:

Private Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long


dim lngRet as long
lngRet = SetForegroundWindow(me.hwnd)




Let me know if that works for you.
Brian
0
 
BrianGEFF719Commented:
>>how can i have my program above the windows taskbar?

Dont think you can unless your program is full screen.


-Brian
0
 
bruintjeCommented:
Hi Mark_FreeSoftware,

this snippet worked for me
--------
Private Declare Function SetWindowPos Lib "user32" (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
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

Private Sub Form_DblClick()
Unload Me
End Sub

Private Sub Form_Load()
    SetWindowPos hwnd, HWND_TOPMOST, 0&, 0&, 0&, 0&, SWP_NOMOVE Or SWP_NOSIZE
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    SetWindowPos hwnd, HWND_NOTOPMOST, 0&, 0&, 0&, 0&, SWP_NOMOVE Or SWP_NOSIZE
End Sub
--------

i could move my form over all other forms and over the taskbar, then i tried your code and it worked too staying on top over all forms even when not activated not sure if this is windows version related as i'm working on windows 2003 server

where have you placed your code in the form load or not?

hope this helps a bit
bruintje
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bruintjeCommented:
missed that comment, sorry
0
 
Mark_FreeSoftwareAuthor Commented:
@ BrianGEFF719

that didnt work,

i discovered that the api i use actually works, as long as no other screen of my application has the focus

so whenever i open the options screen, my app suddenly disappears behind the taskbar!


what could be causing this?
0
 
nffvrxqgrcfqvvcCommented:
Thats because you have the option enabled in windows to keep the taskbar ontop of all windows.

Right click Start button on windows and you will see the option.
0
 
nffvrxqgrcfqvvcCommented:
Right click, choose properties.. my bad
0
 
BrianGEFF719Commented:
Or you could just use the same API again on the newly opened window in your application, just perform the same api call in every form load.
0
 
Mark_FreeSoftwareAuthor Commented:
>>Or you could just use the same API again on the newly opened window in your application, just perform the same api call in every form load.

that did it, thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now