Solved

How to uncheck the "Always on top"  at taskbar using VB 6.0

Posted on 2002-05-01
13
255 Views
Last Modified: 2008-01-09
I would like to know on how to uncheck and check the "Always on top"  at taskbar using VB 6.0?

Thank you
0
Comment
Question by:zubairi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
13 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6985289
Hi zubairi,

Try this:

'! Stay On Top
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public 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
'! Stay On Top

Public Sub StayOnTop(frmForm As Form, fOnTop As Boolean)
    Dim lState As Long
    Dim iLeft As Integer, iTop As Integer, iWidth As Integer, iHeight As Integer
    With frmForm
        iLeft = .Left / Screen.TwipsPerPixelX
        iTop = .Top / Screen.TwipsPerPixelY
        iWidth = .Width / Screen.TwipsPerPixelX
        iHeight = .Height / Screen.TwipsPerPixelY
    End With
    If fOnTop Then
        lState = HWND_TOPMOST
    Else
        lState = HWND_NOTOPMOST
    End If
    Call SetWindowPos(frmForm.hWnd, lState, iLeft, iTop, iWidth, iHeight, 0)
End Sub

Cheers
0
 

Author Comment

by:zubairi
ID: 6985355
Hi ryancys ,

I am appreciated with your answer but unfortunately that was not answer my question.

i would like to know on how to uncheck/Check "Always on top" at window TASKBAR?

Hope this will clear to everybody

Thank you
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6985413
Found a code to check the TaskBar status:

Const ABS_AUTOHIDE = &H1
Const ABS_ONTOP = &H2
Const ABM_GETSTATE = &H4
Const ABM_GETTASKBARPOS = &H5
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private Type APPBARDATA
    cbSize As Long
    hwnd As Long
    uCallbackMessage As Long
    uEdge As Long
    rc As RECT
    lParam As Long '  message specific
End Type
Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Private Sub Form_Paint()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim ABD As APPBARDATA, Ret As Long
    'Get the taskbar's position
    SHAppBarMessage ABM_GETTASKBARPOS, ABD
    'Get the taskbar's state
    Ret = SHAppBarMessage(ABM_GETSTATE, ABD)
    If (Ret And ABS_AUTOHIDE) Then Me.Print "Autohide option is on"
    If (Ret And ABS_ONTOP) Then Me.Print "Always on top option is on"
    Me.Print "Taskbar coordinates: (" + Trim(Str(ABD.rc.Left)) + "," + Trim(Str(ABD.rc.Top)) + ")-(" + Trim(Str(ABD.rc.Right)) + "," + Trim(Str(ABD.rc.Bottom)) + ")"
End Sub

<Still looking for solution, listening..>
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!

 
LVL 3

Expert Comment

by:n_narayanan
ID: 6985509
Here is the code for you

http://www.a1vbcode.com/app.asp?ID=1193

Narayanan
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6985514
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6985517
ryancys, I think you may be a long while looking. I remember looking at this problem a while back and found that it is actually immensely complicated. Setting either the autohide or ontop properties requires a complete redraw of the window for which you will probably find that you do not have enough information available to do properly.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6985525
In the end we decided to go with the simple hide/unhide of the taskbar which is quite easy to achieve. If you do find a solution I would be interested in seeing it though.
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6985621
Thanks for the comments, Tim. So how do you do that > simply hide/unhide the taskbar?

Currently not find a solution here.. and Curious to ask how M$ Software Engineers achieve this function (Set the 'Always on top' property in Taskbar)? It must be a way to go..

And i think the links provided by n_narayanan, as well as first comments posted by me is not useful for this question.

regards
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6985641
Here is one method:

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal

lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_NORMAL = 1
Dim ret As Long

Private Sub Form_Click()
If ret <> 0 Then
  ShowWindow ret, SW_NORMAL
End If
End Sub

Private Sub Form_Load()

ret = FindWindow("Shell_TrayWnd", vbNullString)
If ret <> 0 Then
  ShowWindow ret, SW_HIDE
End If
End Sub
0
 

Author Comment

by:zubairi
ID: 6987628
Hello there,

I am agree with TimCottee , I have been searching for this code unfortunately i could not find those api to uncheck/check "always on top" at windows taskbar.
but i just found hide/show taskbar and get the taskbar "auto-hide" status.  as given by TimCottee and ryancys.

Now i just thinking about registry key?
Can i know the taskbar information from registry key?

Anybody please help
0
 

Author Comment

by:zubairi
ID: 6990881
i do not know what to say. Your answer is not what i want but I still can accept it.
thank you
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6995610
zubairi,

C is a bad grading!
0
 

Author Comment

by:zubairi
ID: 7507326
anybody know which registry key involved when we uncheck and check the "Always on top"  at taskbar?
0

Featured Post

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question