Solved

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

Posted on 2002-05-01
13
251 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 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

831 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