Switch License Module, Move SnapToDesktopBorder to Window Module
This commit is contained in:
@@ -6,120 +6,25 @@ Imports System.Globalization
|
||||
Imports System.Threading
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Windows
|
||||
Imports DigitalData.Modules.License
|
||||
|
||||
Public Class frmStart
|
||||
Public _lizenzManager As ClassLicenseManager
|
||||
Dim loaded As Boolean = False
|
||||
Dim WithEvents HotKey As New clsHotkey(Me)
|
||||
|
||||
Private Const mSnapOffset As Integer = 35
|
||||
Public _lizenzManager As LicenseManagerLegacy
|
||||
Private Const WM_WINDOWPOSCHANGING As Integer = &H46
|
||||
|
||||
Private IndexForm As frmIndex
|
||||
|
||||
<StructLayout(LayoutKind.Sequential)>
|
||||
Public Structure WINDOWPOS
|
||||
Public hwnd As IntPtr
|
||||
Public hwndInsertAfter As IntPtr
|
||||
Public x As Integer
|
||||
Public y As Integer
|
||||
Public cx As Integer
|
||||
Public cy As Integer
|
||||
Public flags As Integer
|
||||
End Structure
|
||||
|
||||
Protected Overrides Sub WndProc(ByRef m As Message)
|
||||
' Listen for operating system messages
|
||||
Select Case m.Msg
|
||||
Case WM_WINDOWPOSCHANGING
|
||||
SnapToDesktopBorder(Me, m.LParam, 0)
|
||||
Window.SnapToDesktopBorder(Me, m.LParam)
|
||||
End Select
|
||||
|
||||
MyBase.WndProc(m)
|
||||
End Sub
|
||||
Public Shared Sub SnapToDesktopBorder(ByVal clientForm _
|
||||
As Form, ByVal LParam As IntPtr, ByVal widthAdjustment As Integer)
|
||||
If clientForm Is Nothing Then
|
||||
' Satisfies rule: Validate parameters
|
||||
Throw New ArgumentNullException("clientForm")
|
||||
End If
|
||||
|
||||
' Snap client to the top, left, bottom or right desktop border
|
||||
' as the form is moved near that border.
|
||||
|
||||
Try
|
||||
' Marshal the LPARAM value which is a WINDOWPOS struct
|
||||
Dim NewPosition As New WINDOWPOS
|
||||
NewPosition = CType(Runtime.InteropServices.Marshal.PtrToStructure(
|
||||
LParam, GetType(WINDOWPOS)), WINDOWPOS)
|
||||
|
||||
If NewPosition.y = 0 OrElse NewPosition.x = 0 Then
|
||||
Return ' Nothing to do!
|
||||
End If
|
||||
|
||||
' Adjust the client size for borders and caption bar
|
||||
Dim ClientRect As Rectangle =
|
||||
clientForm.RectangleToScreen(clientForm.ClientRectangle)
|
||||
ClientRect.Width +=
|
||||
SystemInformation.FrameBorderSize.Width - widthAdjustment
|
||||
ClientRect.Height += (SystemInformation.FrameBorderSize.Height +
|
||||
SystemInformation.CaptionHeight)
|
||||
|
||||
' Now get the screen working area (without taskbar)
|
||||
Dim WorkingRect As Rectangle =
|
||||
Screen.GetWorkingArea(clientForm.ClientRectangle)
|
||||
|
||||
' Left border
|
||||
If NewPosition.x >= WorkingRect.X - mSnapOffset AndAlso
|
||||
NewPosition.x <= WorkingRect.X + mSnapOffset Then
|
||||
NewPosition.x = WorkingRect.X
|
||||
End If
|
||||
|
||||
' Get screen bounds and taskbar height
|
||||
' (when taskbar is horizontal)
|
||||
Dim ScreenRect As Rectangle =
|
||||
Screen.GetBounds(Screen.PrimaryScreen.Bounds)
|
||||
Dim TaskbarHeight As Integer =
|
||||
ScreenRect.Height - WorkingRect.Height
|
||||
|
||||
' Top border (check if taskbar is on top
|
||||
' or bottom via WorkingRect.Y)
|
||||
If NewPosition.y >= -mSnapOffset AndAlso
|
||||
(WorkingRect.Y > 0 AndAlso NewPosition.y <=
|
||||
(TaskbarHeight + mSnapOffset)) OrElse
|
||||
(WorkingRect.Y <= 0 AndAlso NewPosition.y <=
|
||||
(mSnapOffset)) Then
|
||||
If TaskbarHeight > 0 Then
|
||||
NewPosition.y = WorkingRect.Y ' Horizontal Taskbar
|
||||
Else
|
||||
NewPosition.y = 0 ' Vertical Taskbar
|
||||
End If
|
||||
End If
|
||||
|
||||
' Right border
|
||||
If NewPosition.x + ClientRect.Width <=
|
||||
WorkingRect.Right + mSnapOffset AndAlso
|
||||
NewPosition.x + ClientRect.Width >=
|
||||
WorkingRect.Right - mSnapOffset Then
|
||||
NewPosition.x = WorkingRect.Right - (ClientRect.Width +
|
||||
SystemInformation.FrameBorderSize.Width)
|
||||
End If
|
||||
|
||||
' Bottom border
|
||||
If NewPosition.y + ClientRect.Height <=
|
||||
WorkingRect.Bottom + mSnapOffset AndAlso
|
||||
NewPosition.y + ClientRect.Height >=
|
||||
WorkingRect.Bottom - mSnapOffset Then
|
||||
NewPosition.y = WorkingRect.Bottom - (ClientRect.Height +
|
||||
SystemInformation.FrameBorderSize.Height)
|
||||
End If
|
||||
|
||||
' Marshal it back
|
||||
Runtime.InteropServices.Marshal.StructureToPtr(NewPosition,
|
||||
LParam, True)
|
||||
Catch ex As ArgumentException
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub frmMain_DragDrop(sender As Object, e As DragEventArgs) Handles MyBase.DragDrop
|
||||
DragDropForm(e)
|
||||
@@ -215,7 +120,7 @@ Public Class frmStart
|
||||
CURRENT_WORKFILE_HASH = Utils.NotNull(Filerow.Item("FILE_HASH"), "")
|
||||
|
||||
LOGGER.Info(">> CURRENT_WORKFILE: " & CURRENT_WORKFILE)
|
||||
If File.Exists(CURRENT_WORKFILE) = True And DTACTUAL_FILES.Rows.Count > 0 Then
|
||||
If IO.File.Exists(CURRENT_WORKFILE) = True And DTACTUAL_FILES.Rows.Count > 0 Then
|
||||
Open_IndexDialog()
|
||||
Else
|
||||
Throw New FileNotFoundException("Dropped file does not exist anymore!")
|
||||
@@ -560,7 +465,6 @@ Public Class frmStart
|
||||
Else
|
||||
TimerFolderWatch.Start()
|
||||
End If
|
||||
loaded = True
|
||||
Opacity = 0.7
|
||||
|
||||
ClassHelper.Refresh_RegexTable()
|
||||
|
||||
Reference in New Issue
Block a user