ZooFlow: Add Working Sidebar code, inital WIP Config for Sidebar
This commit is contained in:
@@ -13,149 +13,60 @@ Imports DigitalData.Modules.Messaging
|
||||
Imports DigitalData.Modules.Windows
|
||||
|
||||
Public Class frmFlowForm
|
||||
#Region "Sidebar Variablen und Konstanten"
|
||||
Public AppDeskData As AppDeskBar
|
||||
Public fBarRegistered As Boolean = False
|
||||
Public ret, i, uCallBack As Integer
|
||||
#Region "Sidebar Declarations"
|
||||
Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As IntPtr, 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
|
||||
Public Declare Auto Function MoveWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal X As Int32, ByVal Y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean
|
||||
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
|
||||
Public left As Integer
|
||||
Public top As Integer
|
||||
Public right As Integer
|
||||
Public bottom As Integer
|
||||
Dim Left As Integer
|
||||
Dim Top As Integer
|
||||
Dim Right As Integer
|
||||
Dim Bottom As Integer
|
||||
End Structure
|
||||
Structure AppDeskBar
|
||||
Public cbSize As Integer
|
||||
Public hWnd As IntPtr
|
||||
Public uCallbackMessage As Integer
|
||||
Public uEdge As Integer
|
||||
Public rc As RECT
|
||||
Public lParam As IntPtr
|
||||
End Structure
|
||||
Enum ABMsg
|
||||
ABM_NEW = 0
|
||||
ABM_REMOVE = 1
|
||||
ABM_QUERYPOS = 2
|
||||
ABM_SETPOS = 3
|
||||
ABM_GETSTATE = 4
|
||||
ABM_GETTASKBARPOS = 5
|
||||
ABM_ACTIVATE = 6
|
||||
ABM_GETAUTOHIDEBAR = 7
|
||||
ABM_SETAUTOHIDEBAR = 8
|
||||
ABM_WINDOWPOSCHANGED = 9
|
||||
ABM_SETSTATE = 10
|
||||
End Enum
|
||||
Enum ABEdge
|
||||
ABE_LEFT = 0
|
||||
ABE_TOP
|
||||
ABE_RIGHT
|
||||
ABE_BOTTOM
|
||||
End Enum
|
||||
Enum ABNotify
|
||||
ABN_STATECHANGE = 0
|
||||
ABN_POSCHANGED
|
||||
ABN_FULLSCREENAPP
|
||||
ABN_WINDOWARRANGE
|
||||
End Enum
|
||||
|
||||
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_NOSIZE As Integer = &H1
|
||||
Const SWP_NOMOVE As Short = &H2
|
||||
Const SWP_NOZORDER As Integer = 4
|
||||
Const SWP_NOACTIVATE As Integer = &H10
|
||||
Const SWP_DRAWFRAME As Integer = &H20
|
||||
Const SWP_SHOWWINDOW As Integer = &H40
|
||||
#End Region
|
||||
#Region "Sidebar DllImport"
|
||||
<DllImport("SHELL32", CallingConvention:=CallingConvention.StdCall)>
|
||||
Private Shared Function SHAppBarMessage(ByVal dwMessage As Integer, ByRef BarrData As AppDeskBar) As Integer
|
||||
End Function
|
||||
<DllImport("User32.dll", CharSet:=CharSet.Auto)>
|
||||
Public Shared Function RegisterWindowMessage(ByVal msg As String) As Integer
|
||||
End Function
|
||||
#End Region
|
||||
#Region "Sidebar Enum Properties Register"
|
||||
Private Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal repaint As Boolean) As Boolean
|
||||
|
||||
End Function
|
||||
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
|
||||
If m.Msg = uCallBack Then
|
||||
Select Case m.WParam.ToInt32()
|
||||
Case CInt(ABNotify.ABN_POSCHANGED)
|
||||
ABSetPos(ABEdge.ABE_RIGHT)
|
||||
End Select
|
||||
End If
|
||||
MyBase.WndProc(m)
|
||||
End Sub 'WndProc
|
||||
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
|
||||
Get
|
||||
Dim cp As CreateParams = MyBase.CreateParams
|
||||
cp.Style = cp.Style And Not &HC00000 ' WS_CAPTION
|
||||
cp.Style = cp.Style And Not &H800000 ' WS_BORDER
|
||||
cp.ExStyle = &H80 Or &H8 ' WS_EX_TOOLWINDOW | WS_EX_TOPMOST
|
||||
Return cp
|
||||
End Get
|
||||
End Property
|
||||
Public Sub RegisterBar(ByVal dockEdge As ABEdge)
|
||||
Dim abd As New AppDeskBar()
|
||||
abd.cbSize = Marshal.SizeOf(abd)
|
||||
abd.hWnd = Me.Handle
|
||||
If Not fBarRegistered Then
|
||||
uCallBack = RegisterWindowMessage("AppBarMessage")
|
||||
abd.uCallbackMessage = uCallBack
|
||||
Dim ret As System.UInt32 = SHAppBarMessage(CInt(ABMsg.ABM_NEW), abd) 'ToDo: Unsigned Integers not supported
|
||||
fBarRegistered = True
|
||||
ABSetPos(ABEdge.ABE_RIGHT)
|
||||
Else
|
||||
SHAppBarMessage(CInt(ABMsg.ABM_REMOVE), abd)
|
||||
fBarRegistered = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ABSetPos(ByVal dockEdge As ABEdge)
|
||||
Dim abd As New AppDeskBar()
|
||||
abd.cbSize = Marshal.SizeOf(abd)
|
||||
abd.hWnd = Me.Handle
|
||||
abd.uEdge = CInt(dockEdge)
|
||||
If abd.uEdge = CInt(ABEdge.ABE_LEFT) Or abd.uEdge = CInt(ABEdge.ABE_RIGHT) Then
|
||||
abd.rc.top = 0
|
||||
abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height
|
||||
If abd.uEdge = CInt(ABEdge.ABE_LEFT) Then
|
||||
abd.rc.left = 0
|
||||
abd.rc.right = Size.Width
|
||||
Else
|
||||
abd.rc.right = SystemInformation.PrimaryMonitorSize.Width
|
||||
abd.rc.left = abd.rc.right - Size.Width
|
||||
End If
|
||||
Else
|
||||
abd.rc.left = 0
|
||||
abd.rc.right = SystemInformation.PrimaryMonitorSize.Width
|
||||
If abd.uEdge = CInt(ABEdge.ABE_TOP) Then
|
||||
abd.rc.top = 0
|
||||
abd.rc.bottom = Size.Height
|
||||
Else
|
||||
abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height
|
||||
abd.rc.top = abd.rc.bottom - Size.Height
|
||||
End If
|
||||
End If
|
||||
' Query the system for an approved size and position.
|
||||
SHAppBarMessage(CInt(ABMsg.ABM_QUERYPOS), abd)
|
||||
' Adjust the rectangle, depending on the edge to which the
|
||||
' appbar is anchored.
|
||||
Select Case abd.uEdge
|
||||
Case CInt(ABEdge.ABE_LEFT)
|
||||
abd.rc.right = abd.rc.left + Size.Width
|
||||
Case CInt(ABEdge.ABE_RIGHT)
|
||||
abd.rc.left = abd.rc.right - Size.Width
|
||||
Case CInt(ABEdge.ABE_TOP)
|
||||
abd.rc.bottom = abd.rc.top + Size.Height
|
||||
Case CInt(ABEdge.ABE_BOTTOM)
|
||||
abd.rc.top = abd.rc.bottom - Size.Height
|
||||
End Select
|
||||
' Pass the final bounding rectangle to the system.
|
||||
SHAppBarMessage(CInt(ABMsg.ABM_SETPOS), abd)
|
||||
' Move and size the appbar so that it conforms to the
|
||||
' bounding rectangle passed to the system.
|
||||
|
||||
Me.Location = New Point(abd.rc.left, abd.rc.top)
|
||||
Dim PSBH = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
|
||||
Dim TaskBarHeight = PSBH - System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height
|
||||
Me.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - TaskBarHeight
|
||||
|
||||
' MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, True)
|
||||
End Sub
|
||||
#End Region
|
||||
' Constants
|
||||
Private Const OPACITY_INITIAL = 0
|
||||
Private Const OPACITY_HIDDEN = 0.65
|
||||
@@ -190,7 +101,7 @@ Public Class frmFlowForm
|
||||
Private ESCHitCount As Integer = 0
|
||||
Private IndexForm As frmGlobix_Index
|
||||
Private AdminForm As frmAdmin_Start
|
||||
Private Const mSnapOffset As Integer = 35
|
||||
Private Sidebar As APPBARDATA
|
||||
|
||||
' Events
|
||||
Public Event ClipboardChanged As EventHandler(Of IDataObject)
|
||||
@@ -215,7 +126,10 @@ Public Class frmFlowForm
|
||||
Init = New ClassInit(My.LogConfig, Me)
|
||||
AddHandler Init.Completed, AddressOf Init_Completed
|
||||
Init.InitializeApplication()
|
||||
'RegisterBar(ABEdge.ABE_RIGHT)
|
||||
|
||||
' Register Form as Sidebar
|
||||
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
|
||||
RegisterSidebar(My.UIConfig.SidebarScreen)
|
||||
End Sub
|
||||
|
||||
Private Sub Init_Completed(sender As Object, e As EventArgs)
|
||||
@@ -235,18 +149,13 @@ Public Class frmFlowForm
|
||||
TopMost = True
|
||||
AllowDrop = True
|
||||
ShowInTaskbar = False
|
||||
Opacity = OPACITY_HIDDEN
|
||||
Opacity = OPACITY_SHOWN
|
||||
Location = My.UIConfig.FlowForm.Location
|
||||
|
||||
' === Setup Event Handlers ===
|
||||
AddHandler KeyDown, AddressOf frmFlowForm_KeyDown
|
||||
AddHandler KeyUp, AddressOf frmFlowForm_KeyDown
|
||||
|
||||
For Each oControl As Control In Controls
|
||||
AddHandler oControl.MouseEnter, AddressOf frmFlowForm_MouseEnter
|
||||
AddHandler oControl.MouseLeave, AddressOf frmFlowForm_MouseLeave
|
||||
Next
|
||||
|
||||
AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged
|
||||
|
||||
Dim oSQL = My.Queries.Common.FNIDB_GET_SEARCH_PROFILES(My.Application.User.UserId, My.Application.User.Language)
|
||||
@@ -399,20 +308,20 @@ Public Class frmFlowForm
|
||||
'TODO: Refresh Data
|
||||
End Sub
|
||||
|
||||
Private Sub frmFlowForm_MouseLeave(sender As Object, e As EventArgs) Handles MyBase.MouseLeave
|
||||
Opacity = OPACITY_HIDDEN
|
||||
End Sub
|
||||
'Private Sub frmFlowForm_MouseLeave(sender As Object, e As EventArgs) Handles MyBase.MouseLeave
|
||||
' Opacity = OPACITY_HIDDEN
|
||||
'End Sub
|
||||
|
||||
Private Sub frmFlowForm_MouseEnter(sender As Object, e As EventArgs) Handles Me.MouseEnter
|
||||
Opacity = OPACITY_SHOWN
|
||||
End Sub
|
||||
'Private Sub frmFlowForm_MouseEnter(sender As Object, e As EventArgs) Handles Me.MouseEnter
|
||||
' Opacity = OPACITY_SHOWN
|
||||
'End Sub
|
||||
|
||||
Private Sub frmFlowForm_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseMove, PictureBoxDragDrop.MouseMove
|
||||
If e.Button = MouseButtons.Left Then
|
||||
NativeMethods.ReleaseCapture()
|
||||
NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTCAPTION, 0)
|
||||
End If
|
||||
End Sub
|
||||
'Private Sub frmFlowForm_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseMove, PictureBoxDragDrop.MouseMove
|
||||
' If e.Button = MouseButtons.Left Then
|
||||
' NativeMethods.ReleaseCapture()
|
||||
' NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTCAPTION, 0)
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
Private Sub frmFlowForm_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
|
||||
If e.KeyCode = Keys.Escape Then
|
||||
@@ -431,7 +340,7 @@ Public Class frmFlowForm
|
||||
Sub ExitZooflow()
|
||||
Dim oResult As DialogResult = MessageBox.Show("Exit Zooflow", "Are you sure you want to close ZooFlow?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
If oResult = DialogResult.Yes Then
|
||||
Application.Exit()
|
||||
Close()
|
||||
Else
|
||||
ESCHitCount = 0
|
||||
End If
|
||||
@@ -542,7 +451,7 @@ Public Class frmFlowForm
|
||||
End If
|
||||
Next
|
||||
|
||||
TimerCheckActiveForms.Enabled = False
|
||||
'TimerCheckActiveForms.Enabled = False
|
||||
Return True
|
||||
End Function
|
||||
|
||||
@@ -550,35 +459,40 @@ Public Class frmFlowForm
|
||||
frmConfigDatabase.ShowDialog()
|
||||
End Sub
|
||||
|
||||
Private Sub TimerCheckActiveForms_Tick(sender As Object, e As EventArgs) Handles TimerCheckActiveForms.Tick
|
||||
Visible = FormLoaded_Visible()
|
||||
If Visible = False Then Exit Sub
|
||||
End Sub
|
||||
|
||||
|
||||
'Private Sub TimerCheckActiveForms_Tick(sender As Object, e As EventArgs) Handles TimerCheckActiveForms.Tick
|
||||
' Visible = FormLoaded_Visible()
|
||||
' If Visible = False Then Exit Sub
|
||||
'End Sub
|
||||
|
||||
Private Sub NotifyIcon_DoubleClick(sender As Object, e As EventArgs) Handles NotifyIcon.DoubleClick
|
||||
If Visible = False Then
|
||||
Visible = True
|
||||
TimerCheckActiveForms.Enabled = False
|
||||
Else
|
||||
Visible = False
|
||||
'TimerCheckActiveForms.Enabled = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub PictureBox1_DragEnter(sender As Object, e As DragEventArgs) Handles PictureBoxDragDrop.DragEnter
|
||||
Drag_Enter(sender, e)
|
||||
End Sub
|
||||
|
||||
Sub Drag_Enter(sender As Object, e As DragEventArgs)
|
||||
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
||||
e.Effect = DragDropEffects.All
|
||||
' Console.WriteLine("DragEnter ...DragDrop")
|
||||
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then
|
||||
'handle a message dragged from Outlook
|
||||
|
||||
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then 'handle a message dragged from Outlook
|
||||
e.Effect = DragDropEffects.Copy
|
||||
' Console.WriteLine("DragEnter ...OutlookMessage")
|
||||
|
||||
ElseIf e.Data.GetDataPresent("aryFileGroupDescriptor") AndAlso (e.Data.GetDataPresent("FileContents")) Then
|
||||
e.Effect = DragDropEffects.Copy
|
||||
' Console.WriteLine("DragEnter ...Attachment from Outlook")
|
||||
|
||||
Else
|
||||
'otherwise, do not handle
|
||||
e.Effect = DragDropEffects.None
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Sub DragDropForm(e As DragEventArgs)
|
||||
@@ -678,9 +592,10 @@ Public Class frmFlowForm
|
||||
AddHandler IndexForm.FormClosed, AddressOf GlobixClosed
|
||||
IndexForm.Show()
|
||||
Cursor = Cursors.Default
|
||||
If TimerCheckActiveForms.Enabled = False Then
|
||||
TimerCheckActiveForms.Enabled = True
|
||||
End If
|
||||
|
||||
'If TimerCheckActiveForms.Enabled = False Then
|
||||
' TimerCheckActiveForms.Enabled = True
|
||||
'End If
|
||||
Catch ex As Exception
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
@@ -1039,16 +954,43 @@ Public Class frmFlowForm
|
||||
End Sub
|
||||
|
||||
Private Sub frmFlowForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
'If fBarRegistered Then
|
||||
' fBarRegistered = False
|
||||
UnregisterSidebar()
|
||||
End Sub
|
||||
|
||||
' '----NEW
|
||||
' Dim abd As New AppDeskBar()
|
||||
' abd.cbSize = Marshal.SizeOf(abd)
|
||||
' abd.hWnd = Me.Handle
|
||||
Private Sub RegisterSidebar(pScreenName As String)
|
||||
Sidebar.hwnd = Me.Handle.ToInt32
|
||||
Sidebar.cbSize = Len(Sidebar)
|
||||
|
||||
' ret = SHAppBarMessage(ABMsg.ABM_REMOVE, abd)
|
||||
Dim oSelectedScreen = System.Windows.Forms.Screen.PrimaryScreen
|
||||
|
||||
' TODO: Make Sidebar Screen configurable
|
||||
'If pScreenName <> "" Then
|
||||
' Dim oScreens = System.Windows.Forms.Screen.AllScreens
|
||||
' For Each oScreen In oScreens
|
||||
' If oScreen.DeviceName = pScreenName Then
|
||||
' oSelectedScreen = oScreen
|
||||
' End If
|
||||
' Next
|
||||
'End If
|
||||
|
||||
With Sidebar
|
||||
.uEdge = ABE_RIGHT
|
||||
.rc.Top = oSelectedScreen.WorkingArea.Top '0
|
||||
.rc.Right = oSelectedScreen.WorkingArea.Right ' right
|
||||
.rc.Left = oSelectedScreen.WorkingArea.Right - 200 ' width of our appbar
|
||||
.rc.Bottom = oSelectedScreen.WorkingArea.Height ' bottom
|
||||
SHAppBarMessage(ABM_NEW, Sidebar)
|
||||
SetWindowPos(Sidebar.hwnd, HWND_TOP, .rc.Left, .rc.Top, .rc.Right - .rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE)
|
||||
SHAppBarMessage(ABM_SETPOS, Sidebar)
|
||||
End With
|
||||
End Sub
|
||||
|
||||
Private Sub UnregisterSidebar()
|
||||
SHAppBarMessage(ABM_REMOVE, Sidebar)
|
||||
End Sub
|
||||
|
||||
Private Sub BasisKonfigurationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BasisKonfigurationToolStripMenuItem.Click
|
||||
frmConfigBasic.ShowDialog()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user