473,320 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.dll" Alias "SHAppBarMessage" (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 uCallbackMessage 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_GETAUTOHIDEBAR = &H7
Private Const ABM_NEW = &H0
Private Const ABM_REMOVE = &H1
' Private Const ABM_SETAUTOHIDEBAR = &H8
Private Const ABM_SETPOS = &H3
Private Const ABM_GETTASKBARPOS = &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_WINDOWFULLWIDTH = 170
Private Const MY_WINDOWTHINWIDTH = 16

Public Sub DockOnEdge(ByRef 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.ToInt32 <> 0 Then
Call SHAppBarMessage(ABM_REMOVE, BarData)
Else

End If

ScreenWidth =
SystemInformation.PrimaryMonitorSize.Width
ScreenHeight =
SystemInformation.PrimaryMonitorSize.Height

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

SetWindowPos(myForm.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.right = ScreenWidth
BarData.rc.bottom = 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(myForm.Handle,
HWND_TOPMOST, .rc.left, .rc.top, .rc.right -
.rc.left, .rc.bottom - .rc.top, SWP_NOACTIVATE)
End With

End Sub

tia

Dan
Nov 20 '05 #1
1 2683
Hi,

Change all the longs to integer.

Ken
--------------------
"danspam" <an*******@discussions.microsoft.com> wrote in message
news:e9****************************@phx.gbl...
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.dll" Alias "SHAppBarMessage" (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 uCallbackMessage 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_GETAUTOHIDEBAR = &H7
Private Const ABM_NEW = &H0
Private Const ABM_REMOVE = &H1
' Private Const ABM_SETAUTOHIDEBAR = &H8
Private Const ABM_SETPOS = &H3
Private Const ABM_GETTASKBARPOS = &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_WINDOWFULLWIDTH = 170
Private Const MY_WINDOWTHINWIDTH = 16

Public Sub DockOnEdge(ByRef 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.ToInt32 <> 0 Then
Call SHAppBarMessage(ABM_REMOVE, BarData)
Else

End If

ScreenWidth =
SystemInformation.PrimaryMonitorSize.Width
ScreenHeight =
SystemInformation.PrimaryMonitorSize.Height

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

SetWindowPos(myForm.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.right = ScreenWidth
BarData.rc.bottom = 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(myForm.Handle,
HWND_TOPMOST, .rc.left, .rc.top, .rc.right -
.rc.left, .rc.bottom - .rc.top, SWP_NOACTIVATE)
End With

End Sub

tia

Dan

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Paul | last post by:
Hello, I've been reading up on security in Java Applets and whilst I understand the concept, I can't successfully get my applet to read a file on my local machine. I discovered from...
4
by: Tran Tuan Anh | last post by:
Dear all, I am new in C++, and now get confused about a lot of things. I wrote this simple code to test the vector. class Temp { public: int x; }; int main() { vector<Temp> v;
3
by: ram | last post by:
I have a user control uc (with a dropdownlist uc_dd) that I dynamically add to a pane on a button_click. this pane is hosted on the winform. now when I add two instances of the user control...
5
by: gelbeiche | last post by:
Is ( cont.begin() == cont.end() ) essentially equivalent to writing ( cont.empty() ) for a STL container ?
30
by: somebody | last post by:
I'm posting a new message regarding this subject, since the one posted previously is getting rather large. I just received the June 2005 issue of Dr. Dobb's Journal, and it contains an article...
2
by: Doug | last post by:
I hope someone can help me. I'm trying to create as part of my application an ApplicationBar (similar to Yahoo and trillian). I've done the research and found that all the examples are for C++...
2
by: danspam | last post by:
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...
0
by: Daavi | last post by:
Hi group, I have this code for create a appbar like windows taskbar, but don't work :( If remove the next line from Button1_Click SHAppBarMessage(ABM_REMOVE, abd) when finish app keep desktop...
5
Atli
by: Atli | last post by:
Hi everybody. After years of C# and PHP, I'm finally returning to Java. My goal is to create a Java program capable of sending images to a PHP Photo Album on my web server. Right now, however,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.