Solved

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

Posted on 2002-05-01
13
235 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
  • 4
  • 4
  • 3
  • +1
13 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
 
LVL 3

Expert Comment

by:n_narayanan
Comment Utility
Here is the code for you

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

Narayanan
0
 
LVL 3

Expert Comment

by:n_narayanan
Comment Utility
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
i do not know what to say. Your answer is not what i want but I still can accept it.
thank you
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
zubairi,

C is a bad grading!
0
 

Author Comment

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now