Solved

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

Posted on 2002-05-01
13
245 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 50

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 50

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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 50

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 50

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

813 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

12 Experts available now in Live!

Get 1:1 Help Now