-
Ok, this is sorta hard to explain, but I'll do my best:
An Appbar - Like the taskbar, they stop any other apps going in front of them. They make all the windows smaller so that they take always take up space on your screen (eg AllAdvantage)
Is there any way to stop an application from being an appbar?
(Guess what its for! (read to make other apps go over alladvantage)
Anyway, any help would be appreciated
Mark
-
Appbars, use api's to do this, like
Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
I am not sure how you would stop an exe from making api calls.
-
Use the SetForegroundWindow to set which window will be in the Foreground.
Code:
Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
-
Here's my appbar stuff, still under research, if anyone can improove it, let me know ;) Also, i haven't tested it for a while so i don't know if i left it bugfree or not
Code:
' // AppBar stuff
Public Const ABM_NEW = &H0
Public Const ABM_REMOVE = &H1
Public Const ABM_QUERYPOS = &H2
Public Const ABM_SETPOS = &H3
Public Const ABM_GETSTATE = &H4
Public Const ABM_GETTASKBARPOS = &H5
Public Const ABM_ACTIVATE = &H6 ' lParam == TRUE/FALSE means activate/deactivate
Public Const ABM_GETAUTOHIDEBAR = &H7
Public Const ABM_SETAUTOHIDEBAR = &H8 ' this can fail at any time. MUST check the result
' lParam = TRUE/FALSE Set/Unset
' uEdge = what edge
Public Const ABM_WINDOWPOSCHANGED = &H9
' these are put in the wparam of callback messages
Public Const ABN_STATECHANGE = &H0
Public Const ABN_POSCHANGED = &H1
Public Const ABN_FULLSCREENAPP = &H2
Public Const ABN_WINDOWARRANGE = &H3 ' lParam == TRUE means hide
' flags for get state
Public Const ABS_AUTOHIDE = &H1
Public Const ABS_ALWAYSONTOP = &H2
Public Const ABE_LEFT = 0
Public Const ABE_TOP = 1
Public Const ABE_RIGHT = 2
Public Const ABE_BOTTOM = 3
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long ' message specific
End Type
Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
' // EndAppBar
Sub Newbar(hwnd&)
Dim abd As APPBARDATA, rt As RECT, rc As RECT
GetWindowRect hwnd, rt
With rc
.Left = 0
.Top = 0
.Bottom = 1200
.Right = 1600
End With
With abd
If (rt.Right - rt.Left) > (rt.Bottom - rt.Top) Then
If (rt.Bottom + rt.Top) > Screen.Height / Screen.TwipsPerPixelY Then
.uEdge = ABE_BOTTOM
Else
.uEdge = ABE_TOP
End If
Else
If (rt.Right + rt.Left) > Screen.Width / Screen.TwipsPerPixelX Then
.uEdge = ABE_RIGHT
Else
.uEdge = ABE_LEFT
End If
End If
.hwnd = hwnd
.uCallbackMessage = 123
.cbSize = Len(abd)
SHAppBarMessage ABM_NEW, abd
'.uEdge = ABE_BOTTOM
.rc = rc
.cbSize = Len(abd)
'SHAppBarMessage ABN_WINDOWARRANGE, abd
SHAppBarMessage ABM_QUERYPOS, abd
If (rt.Right - rt.Left) > (rt.Bottom - rt.Top) Then
If (rt.Bottom + rt.Top) > Screen.Height / Screen.TwipsPerPixelY Then
.uEdge = ABE_BOTTOM
.rc.Top = .rc.Bottom - rt.Bottom + rt.Top
Else
.uEdge = ABE_TOP
.rc.Bottom = .rc.Top - rt.Top + rt.Bottom
End If
Else
If (rt.Right + rt.Left) > Screen.Width / Screen.TwipsPerPixelX Then
.uEdge = ABE_RIGHT
.rc.Left = .rc.Right - rt.Right + rt.Left
Else
.uEdge = ABE_LEFT
.rc.Right = .rc.Left - rt.Left + rt.Right
End If
End If
.cbSize = Len(abd)
SHAppBarMessage ABM_SETPOS, abd
MoveWindow hwnd, .rc.Left, .rc.Top, .rc.Right - .rc.Left, .rc.Bottom - .rc.Top, 1
DoEvents
SHAppBarMessage ABM_ACTIVATE, abd
End With
SHAppBarMessage ABM_REMOVE, abd
End Sub
-
With this code, knowing another windows HWND, how would I stop the other program being an appbar?
Sorry to be thick
Mark
-
Check out MSDN, search for SHAppBarMessage, and then click the link to the ABM_REMOVE message, I guess that's where you have to look for,. Need to fill a strucuture, one of it's members is the hWnd of the taskbar... see if you can do it with that.
-
Thanks, but I cant get it to work! This is the code I am using:
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long ' message specific
End Type
Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Sub Newbar(hwnd)
Dim abd As APPBARDATA, rt As RECT, rc As RECT
GetWindowRect hwnd, rt
With abd
.hwnd = hwnd
.cbSize = Len(abd)
End With
SHAppBarMessage ABM_REMOVE, abd
End Sub
Any Ideas why?
[Edited by markwestcott on 06-08-2000 at 08:51 AM]
-
Yes, use ABM_NEW instead of ABM_REMOVE. Use ABM_SETPOS to set the position, you can use my sample, it should work.
-
Surely that is going to make something into an appbar, not stop it being one?
-
Yes, remove that line "SHAppBarMessage ABM_REMOVE, abd" and put it in another method