Ok so I made some changes and now when i call ABM_NEW it returns false and I can't figure out why. I still am unable to get the form window to stay within the designated appbar area.
VB.NET:
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Location = New Point(((Screen.PrimaryScreen.Bounds.Width - Me.Width) / 2), 0)
Dim Result As Boolean
'Dim Ret As Integer
Dim uCallBack As Long
abd.hwnd = Me.Handle
abd.cbSize = Len(abd)
'abd.uEdge = ABE_TOP
'abd.rc.Top = 0
'abd.rc.Left = 0
'abd.rc.Right = 656
'abd.rc.Bottom = 30
'abd.lParam = ABS_ALWAYSONTOP
uCallBack = RegisterWindowMessage("APPBARMESSAGE")
abd.uCallbackMessage = uCallBack
'Result = SHAppBarMessage(ABM_REMOVE, abd)
Result = SHAppBarMessage(ABM_NEW, abd)
If Result = True Then
abd.hwnd = Me.Handle
abd.cbSize = Len(abd)
abd.uEdge = ABE_TOP
Result = SetRect(abd.rc, abd.rc.Left, abd.rc.Top, abd.rc.Right, abd.rc.Bottom)
If Result = True Then
Result = SHAppBarMessage(ABM_QUERYPOS, abd)
If Result = True Then
Select Case abd.uEdge
Case ABE_LEFT
abd.rc.Right = abd.rc.Left + 656
Case ABE_TOP
abd.rc.Bottom = abd.rc.Top + 30
Case ABE_RIGHT
abd.rc.Left = abd.rc.Right - 656
Case ABE_BOTTOM
abd.rc.Top = abd.rc.Bottom - 30
End Select
abd.hwnd = Me.Handle
abd.cbSize = Len(abd)
abd.uEdge = ABE_TOP
Result = SHAppBarMessage(ABM_SETPOS, abd)
If Result = True Then
Result = SetWindowPos(abd.hwnd, Nothing, abd.rc.Left, abd.rc.Top, abd.rc.Right - abd.rc.Left, abd.rc.Bottom - abd.rc.Top, SWP_NOZORDER Or SWP_NOACTIVATE)
If Result = True Then
MsgBox("Evereything Went OK!", MsgBoxStyle.OkOnly)
'Ret = MoveWindow(abd.hwnd, abd.rc.Left, abd.rc.Top, abd.rc.Right, abd.rc.Bottom, True)
Else
MsgBox("Something Went Wrong At SETWINDOWPOS", MsgBoxStyle.OkOnly)
End If
Else
MsgBox("Something Went Wrong At ABM_SETPOS", MsgBoxStyle.OkOnly)
End If
Else
MsgBox("Something Went Wrong At ABM_QUERYPOS", MsgBoxStyle.OkOnly)
End If
Else
MsgBox("Something Went Wrong At SETRECT", MsgBoxStyle.OkOnly)
End If
Else
'MsgBox("Something Went Wrong At ABM_NEW", MsgBoxStyle.OkOnly)
End If
End Sub
Last edited: