From 6c5f8c6381166edf0824aed78a1c3f05b0c562d1 Mon Sep 17 00:00:00 2001 From: TheUltimateHacker Date: Wed, 27 May 2015 20:39:48 -0400 Subject: Draggable Windows in the BWM We're one step closer to the full Basic Window Manager implementation. I've created a UserControl called "TitleBar" for the BWM. This UserControl contains the window handling code for draggable windows, as well as a design-time settable AppName property that allows you to change the application display name (what text is shown on the titlebar). Shiftorium upgrades to unlock Draggable Windows will be added soon, but I have to clean the beast. --- .../BWM User Controls/Titlebar.Designer.vb | 66 ++++++++++++ shiftos_next/BWM User Controls/Titlebar.resx | 120 +++++++++++++++++++++ shiftos_next/BWM User Controls/Titlebar.vb | 44 ++++++++ 3 files changed, 230 insertions(+) create mode 100644 shiftos_next/BWM User Controls/Titlebar.Designer.vb create mode 100644 shiftos_next/BWM User Controls/Titlebar.resx create mode 100644 shiftos_next/BWM User Controls/Titlebar.vb (limited to 'shiftos_next/BWM User Controls') diff --git a/shiftos_next/BWM User Controls/Titlebar.Designer.vb b/shiftos_next/BWM User Controls/Titlebar.Designer.vb new file mode 100644 index 0000000..980ad87 --- /dev/null +++ b/shiftos_next/BWM User Controls/Titlebar.Designer.vb @@ -0,0 +1,66 @@ + _ +Partial Class Titlebar + Inherits System.Windows.Forms.UserControl + + 'UserControl overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.pnltop = New System.Windows.Forms.Panel() + Me.lbtitle = New System.Windows.Forms.Label() + Me.pnltop.SuspendLayout() + Me.SuspendLayout() + ' + 'pnltop + ' + Me.pnltop.BackColor = System.Drawing.Color.Gray + Me.pnltop.Controls.Add(Me.lbtitle) + Me.pnltop.Dock = System.Windows.Forms.DockStyle.Top + Me.pnltop.Location = New System.Drawing.Point(0, 0) + Me.pnltop.Name = "pnltop" + Me.pnltop.Size = New System.Drawing.Size(678, 32) + Me.pnltop.TabIndex = 1 + ' + 'lbtitle + ' + Me.lbtitle.Dock = System.Windows.Forms.DockStyle.Fill + Me.lbtitle.Location = New System.Drawing.Point(0, 0) + Me.lbtitle.Name = "lbtitle" + Me.lbtitle.Size = New System.Drawing.Size(678, 32) + Me.lbtitle.TabIndex = 0 + Me.lbtitle.Text = "Color Picker" + Me.lbtitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft + ' + 'Titlebar + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 14.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.pnltop) + Me.Font = New System.Drawing.Font("Courier New", 8.25!) + Me.ForeColor = System.Drawing.Color.White + Me.Name = "Titlebar" + Me.Size = New System.Drawing.Size(678, 32) + Me.pnltop.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + Friend WithEvents pnltop As System.Windows.Forms.Panel + Friend WithEvents lbtitle As System.Windows.Forms.Label + +End Class diff --git a/shiftos_next/BWM User Controls/Titlebar.resx b/shiftos_next/BWM User Controls/Titlebar.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/shiftos_next/BWM User Controls/Titlebar.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/shiftos_next/BWM User Controls/Titlebar.vb b/shiftos_next/BWM User Controls/Titlebar.vb new file mode 100644 index 0000000..7e380d5 --- /dev/null +++ b/shiftos_next/BWM User Controls/Titlebar.vb @@ -0,0 +1,44 @@ +Public Class Titlebar + + Public Property AppName As String + Set(value As String) + lbtitle.Text = value + End Set + Get + Return lbtitle.Text + End Get + End Property + + Friend WithEvents prnt As Form = ParentForm + + Private Sub titlebar_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown, lbtitle.MouseDown + ' Handle Draggable Windows + If boughtdraggablewindows = True Then + If e.Button = MouseButtons.Left Then + Me.Capture = False + lbtitle.Capture = False + Const WM_NCLBUTTONDOWN As Integer = &HA1S + Const HTCAPTION As Integer = 2 + Dim msg As Message = _ + Message.Create(ParentForm.Handle, WM_NCLBUTTONDOWN, _ + New IntPtr(HTCAPTION), IntPtr.Zero) + Me.DefWndProc(msg) + End If + End If + End Sub + + Public Sub DetermineMyVisibility() + If boughtbasicwm = True Then + Me.Show() + ParentForm.WindowState = FormWindowState.Normal + ParentForm.Left = (Screen.PrimaryScreen.Bounds.Width - Me.Width) / 2 + ParentForm.Top = (Screen.PrimaryScreen.Bounds.Height - Me.Height) / 2 + ParentForm.TopMost = True + Else + Me.Hide() + ParentForm.WindowState = FormWindowState.Maximized + ParentForm.TopMost = False + End If + End Sub + +End Class -- cgit v1.2.3