shappbarmessage

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Has anyone managed to get this shell api call to work in
vb.net? I keep getting a system.nullreference exception
when trying to use it. My code works fine in vb6 but when
I translate it to vb.net it chokes.


tia


dan
 
Hi,

When upgrading api calls look at the msdn documentation. If a
parameter is in use byval, out use byref. The new integer is the same as
the old long. Callback functions are now delegate. The old integer is the
same as the new short. Window handles hwnd are now given as intptr.
Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" _

(ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As Integer

Structure APPBARDATA

Dim cbSize As Integer

Dim hwnd As IntPtr

Dim uCallbackMessage As [Delegate]

Dim uEdge As Integer

Dim rc As Rect

Dim lParam As Integer ' message specific

End Structure

Structure RECT

Dim Left As Integer

Dim Top As Integer

Dim Right As Integer

Dim Bottom As Integer

End Structure

Const ABS_AUTOHIDE = &H1

Const ABS_ONTOP = &H2

Const ABM_GETSTATE = &H4

Const ABM_GETTASKBARPOS = &H5



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim abd As APPBARDATA

Dim ret As Integer

abd.hwnd = Me.Handle

SHAppBarMessage(ABM_GETTASKBARPOS, abd)

ret = SHAppBarMessage(ABM_GETSTATE, abd)

If (ret And ABS_AUTOHIDE) Then Debug.WriteLine("Autohide option is on")

If (ret And ABS_ONTOP) Then Debug.WriteLine("Always on top option is on")

Dim strOut As String

strOut = String.Format("Coordinates are ({0}, {1}) - ({2}, {3})", _

abd.rc.Left, abd.rc.Top, abd.rc.Right, abd.rc.Bottom)

Debug.WriteLine(strOut)

End Sub

Ken
 
Back
Top