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 area and work perfectly when restart app
Please help!!
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code "
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(8, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(74, 36)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Button1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Declare Function SHAppBarMessage Lib "shell32.dll" Alias
"SHAppBarMessage" (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As
Integer
Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Integer,
ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer,
ByVal cX As Integer, ByVal cY As Integer, ByVal wFlags As Integer) As Integer
Structure APPBARDATA
Dim cbSize As Integer
Dim hwnd As Integer
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 ABE_LEFT As Integer = 0
Const ABE_TOP As Integer = &H1
Const ABE_RIGHT As Integer = 2
Const ABE_BOTTOM As Integer = 3
Const ABM_NEW As Integer = 0
Const ABM_REMOVE As Integer = 1
Const ABM_QUERYPOS As Integer = 2
Const ABM_SETPOS As Integer = &H3
Const ABM_GETSTATE As Integer = 4
Const ABM_GETTASKBARPOS As Integer = 5
Const ABM_ACTIVATE As Integer = 6
Const ABM_GETAUTOHIDEBAR As Integer = 7
Const ABM_SETAUTOHIDEBAR As Integer = 8
Const ABM_WINDOWPOSCHANGED As Integer = 9
Const ABS_AUTOHIDE As Integer = 1
Const ABS_ALWAYSONTOP As Integer = 2
Const HWND_NOTTOPMOST As Integer = -2
Const HWND_TOPMOST As Integer = -1
Const HWND_TOP As Integer = 0
Const SHOWNORMAL As Integer = 5
Const SWP_NOMOVE As Integer = 2
Const SWP_NOSIZE As Integer = 1
Const SWP_NOZORDER As Integer = 4
Const SWP_NOACTIVATE As Integer = &H10
Const SWP_DRAWFRAME As Integer = &H20
Const SWP_SHOWWINDOW As Integer = &H40
Dim abd As APPBARDATA
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
abd.hwnd = Me.Handle.ToInt32
abd.cbSize = Len(abd)
With abd
.uEdge = ABE_RIGHT
.rc.Top = 0
.rc.Left = Screen.PrimaryScreen.Bounds.Width - 100
.rc.Right = Screen.PrimaryScreen.Bounds.Width
.rc.Bottom = Screen.PrimaryScreen.Bounds.Height
SHAppBarMessage(ABM_NEW, abd)
SetWindowPos(abd.hwnd, HWND_TOP, .rc.Left, .rc.Top, .rc.Right -
..rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE)
SHAppBarMessage(ABM_SETPOS, abd)
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SHAppBarMessage(ABM_REMOVE, abd)
End
End Sub
End Class 4 2479
Hi,
If the problem is that the appbar doesn't move to a desired location,
try this:
~
SHAppBarMessage(ABM_SETPOS, abd)
Me.SetBounds(.rc.Left, .rc.Top, .rc.Right - .rc.Left,
..rc.Bottom)
~
instead of
~
SetWindowPos(abd.hwnd, HWND_TOP, .rc.Left, .rc.Top,
..rc.Right - .rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE)
SHAppBarMessage(ABM_SETPOS, abd)
~
Also, in APPBARDATA definition, change uCallbackMessage to be Integer
and hwnd to be IntPtr.
HTH,
Roman
Thx for your answer.
Exactly, the appbar doesn't move to the desired position outside of my
desktop workarea and remains inside the workarea
Your code does the same thing than mine.
Daavi
"Dragon" escribió: Hi,
If the problem is that the appbar doesn't move to a desired location, try this:
~ SHAppBarMessage(ABM_SETPOS, abd) Me.SetBounds(.rc.Left, .rc.Top, .rc.Right - .rc.Left, ..rc.Bottom) ~
instead of
~ SetWindowPos(abd.hwnd, HWND_TOP, .rc.Left, .rc.Top, ..rc.Right - .rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE) SHAppBarMessage(ABM_SETPOS, abd) ~
Also, in APPBARDATA definition, change uCallbackMessage to be Integer and hwnd to be IntPtr.
HTH, Roman
Thx for your answer.
Exactly, the appbar doesn't move to the desired position outside of my
desktop workarea and remains inside the workarea.
Your code does the same thing that mine.
Regards,
Daavi
"Dragon" wrote: Hi,
If the problem is that the appbar doesn't move to a desired location, try this:
~ SHAppBarMessage(ABM_SETPOS, abd) Me.SetBounds(.rc.Left, .rc.Top, .rc.Right - .rc.Left, ..rc.Bottom) ~
instead of
~ SetWindowPos(abd.hwnd, HWND_TOP, .rc.Left, .rc.Top, ..rc.Right - .rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE) SHAppBarMessage(ABM_SETPOS, abd) ~
Also, in APPBARDATA definition, change uCallbackMessage to be Integer and hwnd to be IntPtr.
HTH, Roman
I have the solution:
I have had to change this line. The FormBorderStyle must be FixedToolWindow
Me.FormBorderStyle =
system.Windows.Forms.FormBorderStyle.FixedToolWind ow
"Daavi" wrote: 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 area and work perfectly when restart app Please help!!
Imports System.Runtime.InteropServices Public Class Form1 Inherits System.Windows.Forms.Form
#Region " Code "
Public Sub New() MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub
Private components As System.ComponentModel.IContainer
Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(8, 8) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(74, 36) Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.Button1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False)
End Sub
#End Region
Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As Integer Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cX As Integer, ByVal cY As Integer, ByVal wFlags As Integer) As Integer Structure APPBARDATA Dim cbSize As Integer Dim hwnd As Integer 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 ABE_LEFT As Integer = 0 Const ABE_TOP As Integer = &H1 Const ABE_RIGHT As Integer = 2 Const ABE_BOTTOM As Integer = 3
Const ABM_NEW As Integer = 0 Const ABM_REMOVE As Integer = 1 Const ABM_QUERYPOS As Integer = 2 Const ABM_SETPOS As Integer = &H3 Const ABM_GETSTATE As Integer = 4 Const ABM_GETTASKBARPOS As Integer = 5 Const ABM_ACTIVATE As Integer = 6 Const ABM_GETAUTOHIDEBAR As Integer = 7 Const ABM_SETAUTOHIDEBAR As Integer = 8 Const ABM_WINDOWPOSCHANGED As Integer = 9
Const ABS_AUTOHIDE As Integer = 1 Const ABS_ALWAYSONTOP As Integer = 2
Const HWND_NOTTOPMOST As Integer = -2 Const HWND_TOPMOST As Integer = -1 Const HWND_TOP As Integer = 0 Const SHOWNORMAL As Integer = 5
Const SWP_NOMOVE As Integer = 2 Const SWP_NOSIZE As Integer = 1 Const SWP_NOZORDER As Integer = 4 Const SWP_NOACTIVATE As Integer = &H10 Const SWP_DRAWFRAME As Integer = &H20 Const SWP_SHOWWINDOW As Integer = &H40
Dim abd As APPBARDATA Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load abd.hwnd = Me.Handle.ToInt32 abd.cbSize = Len(abd) With abd .uEdge = ABE_RIGHT .rc.Top = 0 .rc.Left = Screen.PrimaryScreen.Bounds.Width - 100 .rc.Right = Screen.PrimaryScreen.Bounds.Width .rc.Bottom = Screen.PrimaryScreen.Bounds.Height SHAppBarMessage(ABM_NEW, abd) SetWindowPos(abd.hwnd, HWND_TOP, .rc.Left, .rc.Top, .rc.Right - .rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE) SHAppBarMessage(ABM_SETPOS, abd) End With End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SHAppBarMessage(ABM_REMOVE, abd) End End Sub End Class
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter Olcott |
last post by:
www.halting-problem.com
|
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...
|
by: danspam |
last post by:
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |