shappbarmessage cont.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • danspam

    shappbarmessage cont.

    Thanks for the replies but they did not help me as I am
    trying to regiseter a form as an appbar and C sharp is no
    good to me!

    Anyway my code is as follows. If anyone can spot what I
    am doing wrong I would be very grateful as I am just
    about to eject my laptop through my front window.

    Private Declare Function SHAppBarMessage
    Lib "shell32.dl l" Alias "SHAppBarMessag e" (ByVal
    dwMessage As Integer, ByRef pData As APPBARDATA) As
    Integer
    Private Declare Function SetWindowPos Lib "user32"
    (ByVal hwnbd As IntPtr, 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
    Structure APPBARDATA
    Public cbSize As Long
    Public hwnd As IntPtr
    Public uCallbackMessag e As [Delegate]
    Public uEdge As Integer
    Public rc As RECT
    Public lParam As Integer
    End Structure
    Structure RECT
    Public left As Integer
    Public top As Integer
    Public right As Integer
    Public bottom As Integer
    End Structure

    Private BarData As APPBARDATA
    'constants
    'Private Const ABE_LEFT = 0
    'Private Const ABE_TOP = 1
    Private Const ABE_RIGHT = 2
    'Private Const ABE_BOTTOM = 3
    'Private Const ABM_GETAUTOHIDE BAR = &H7
    Private Const ABM_NEW = &H0
    Private Const ABM_REMOVE = &H1
    ' Private Const ABM_SETAUTOHIDE BAR = &H8
    Private Const ABM_SETPOS = &H3
    Private Const ABM_GETTASKBARP OS = &H5
    'Private Const HWND_TOP = 0
    Private Const HWND_TOPMOST = -1
    'Private Const SHOWNORMAL = 5
    Private Const SWP_NOACTIVATE = &H10
    'Private Const SWP_NOSIZE = &H1
    'Private Const SWP_NOMOVE = &H2
    'Private Const SWP_SHOWWINDOW = &H40
    Private Const MY_WINDOWFULLWI DTH = 170
    Private Const MY_WINDOWTHINWI DTH = 16

    Public Sub DockOnEdge(ByRe f myForm As Form, Optional
    ByVal Shrink As Boolean = False)
    Dim FormWidth As Integer
    Dim ScreenWidth, ScreenHeight As Integer
    Dim DesiredLeft, DesiredTop, DesiredWidth,
    DesiredHeight As Long
    'width to set when collapsing
    If Shrink = True Then
    FormWidth = 16
    Else
    FormWidth = 170
    End If

    'unregister if already registered
    If BarData.hwnd.To Int32 <> 0 Then
    Call SHAppBarMessage (ABM_REMOVE, BarData)
    Else

    End If

    ScreenWidth =
    SystemInformati on.PrimaryMonit orSize.Width
    ScreenHeight =
    SystemInformati on.PrimaryMonit orSize.Height

    DesiredLeft = ScreenWidth - FormWidth
    DesiredTop = 0
    DesiredWidth = ScreenWidth - (ScreenWidth -
    FormWidth)
    DesiredHeight = ScreenHeight

    SetWindowPos(my Form.Handle, HWND_TOPMOST,
    DesiredLeft, DesiredTop, DesiredWidth, DesiredHeight,
    SWP_NOACTIVATE)

    BarData.hwnd = myForm.Handle

    SHAppBarMessage (ABM_NEW, BarData) <------
    Error here

    'sets the bardata RECT to the screensize
    BarData.rc.left = 0
    BarData.rc.top = 0
    BarData.rc.righ t = ScreenWidth
    BarData.rc.bott om = ScreenHeight

    With BarData
    .uEdge = ABE_RIGHT
    .rc.top = 0
    .rc.left = ScreenWidth - FormWidth
    .rc.right = ScreenWidth
    .rc.bottom = ScreenHeight
    'reserve the area of the screen
    SHAppBarMessage (ABM_SETPOS, BarData)
    'set the window to the reserved area (which
    may be different from the requested)
    SetWindowPos(my Form.Handle,
    HWND_TOPMOST, .rc.left, .rc.top, .rc.right -
    .rc.left, .rc.bottom - .rc.top, SWP_NOACTIVATE)
    End With

    End Sub



    tia

    Dan
  • Ken Tucker [MVP]

    #2
    Re: shappbarmessage cont.

    Hi,

    Change all the longs to integer.

    Ken
    --------------------
    "danspam" <anonymous@disc ussions.microso ft.com> wrote in message
    news:e9c301c3bc d9$c2ba72f0$a60 1280a@phx.gbl.. .[color=blue]
    > Thanks for the replies but they did not help me as I am
    > trying to regiseter a form as an appbar and C sharp is no
    > good to me!
    >
    > Anyway my code is as follows. If anyone can spot what I
    > am doing wrong I would be very grateful as I am just
    > about to eject my laptop through my front window.
    >
    > Private Declare Function SHAppBarMessage
    > Lib "shell32.dl l" Alias "SHAppBarMessag e" (ByVal
    > dwMessage As Integer, ByRef pData As APPBARDATA) As
    > Integer
    > Private Declare Function SetWindowPos Lib "user32"
    > (ByVal hwnbd As IntPtr, 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
    > Structure APPBARDATA
    > Public cbSize As Long
    > Public hwnd As IntPtr
    > Public uCallbackMessag e As [Delegate]
    > Public uEdge As Integer
    > Public rc As RECT
    > Public lParam As Integer
    > End Structure
    > Structure RECT
    > Public left As Integer
    > Public top As Integer
    > Public right As Integer
    > Public bottom As Integer
    > End Structure
    >
    > Private BarData As APPBARDATA
    > 'constants
    > 'Private Const ABE_LEFT = 0
    > 'Private Const ABE_TOP = 1
    > Private Const ABE_RIGHT = 2
    > 'Private Const ABE_BOTTOM = 3
    > 'Private Const ABM_GETAUTOHIDE BAR = &H7
    > Private Const ABM_NEW = &H0
    > Private Const ABM_REMOVE = &H1
    > ' Private Const ABM_SETAUTOHIDE BAR = &H8
    > Private Const ABM_SETPOS = &H3
    > Private Const ABM_GETTASKBARP OS = &H5
    > 'Private Const HWND_TOP = 0
    > Private Const HWND_TOPMOST = -1
    > 'Private Const SHOWNORMAL = 5
    > Private Const SWP_NOACTIVATE = &H10
    > 'Private Const SWP_NOSIZE = &H1
    > 'Private Const SWP_NOMOVE = &H2
    > 'Private Const SWP_SHOWWINDOW = &H40
    > Private Const MY_WINDOWFULLWI DTH = 170
    > Private Const MY_WINDOWTHINWI DTH = 16
    >
    > Public Sub DockOnEdge(ByRe f myForm As Form, Optional
    > ByVal Shrink As Boolean = False)
    > Dim FormWidth As Integer
    > Dim ScreenWidth, ScreenHeight As Integer
    > Dim DesiredLeft, DesiredTop, DesiredWidth,
    > DesiredHeight As Long
    > 'width to set when collapsing
    > If Shrink = True Then
    > FormWidth = 16
    > Else
    > FormWidth = 170
    > End If
    >
    > 'unregister if already registered
    > If BarData.hwnd.To Int32 <> 0 Then
    > Call SHAppBarMessage (ABM_REMOVE, BarData)
    > Else
    >
    > End If
    >
    > ScreenWidth =
    > SystemInformati on.PrimaryMonit orSize.Width
    > ScreenHeight =
    > SystemInformati on.PrimaryMonit orSize.Height
    >
    > DesiredLeft = ScreenWidth - FormWidth
    > DesiredTop = 0
    > DesiredWidth = ScreenWidth - (ScreenWidth -
    > FormWidth)
    > DesiredHeight = ScreenHeight
    >
    > SetWindowPos(my Form.Handle, HWND_TOPMOST,
    > DesiredLeft, DesiredTop, DesiredWidth, DesiredHeight,
    > SWP_NOACTIVATE)
    >
    > BarData.hwnd = myForm.Handle
    >
    > SHAppBarMessage (ABM_NEW, BarData) <------
    > Error here
    >
    > 'sets the bardata RECT to the screensize
    > BarData.rc.left = 0
    > BarData.rc.top = 0
    > BarData.rc.righ t = ScreenWidth
    > BarData.rc.bott om = ScreenHeight
    >
    > With BarData
    > .uEdge = ABE_RIGHT
    > .rc.top = 0
    > .rc.left = ScreenWidth - FormWidth
    > .rc.right = ScreenWidth
    > .rc.bottom = ScreenHeight
    > 'reserve the area of the screen
    > SHAppBarMessage (ABM_SETPOS, BarData)
    > 'set the window to the reserved area (which
    > may be different from the requested)
    > SetWindowPos(my Form.Handle,
    > HWND_TOPMOST, .rc.left, .rc.top, .rc.right -
    > .rc.left, .rc.bottom - .rc.top, SWP_NOACTIVATE)
    > End With
    >
    > End Sub
    >
    >
    >
    > tia
    >
    > Dan[/color]


    Comment

    Working...