Skip to content

Commit

Permalink
fixed issue with snapping windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Nelson committed Feb 24, 2021
1 parent bea362b commit 85acf0d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
18 changes: 15 additions & 3 deletions TANWindowMgr/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Public Class Form1
Private Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As Boolean
End Function

Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As IntPtr, ByRef lpRect As RECT) As Boolean

'<DllImport("user32.dll", SetLastError:=True)>
'Private Shared Function FindWindow(idThread As Integer, lpWindowName As String) As IntPtr
'End Function
Expand All @@ -40,6 +42,9 @@ Public Class Form1
End Structure

Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
btnSave.Enabled = False
btnSaveAll.Enabled = False
btnCancel.Enabled = False

GetWindowList()

Expand All @@ -65,18 +70,25 @@ Public Class Form1

Dim hWnd As IntPtr = WindowList(item.Text).MainWindowHandle ' FindWindow(WindowList(item.Text).Id, Nothing)
Dim wpTemp As WINDOWPLACEMENT
GetWindowPlacement(hWnd, wpTemp)
Dim rectTemp As RECT

lines.Add(item.Text & "," & wpTemp.rcNormalPosition.Left & "," & wpTemp.rcNormalPosition.Top & "," & wpTemp.rcNormalPosition.Bottom & "," & wpTemp.rcNormalPosition.Right & "," & wpTemp.showCmd & "," & cboProfiles.SelectedItem)
GetWindowPlacement(hWnd, wpTemp)
GetWindowRect(hWnd, rectTemp) 'this function reliably get position for snapped windows

'lines.Add(item.Text & "," & wpTemp.rcNormalPosition.Left & "," & wpTemp.rcNormalPosition.Top & "," & wpTemp.rcNormalPosition.Bottom & "," & wpTemp.rcNormalPosition.Right & "," & wpTemp.showCmd & "," & cboProfiles.SelectedItem)
lines.Add(item.Text & "," & rectTemp.Left & "," & rectTemp.Top & "," & rectTemp.Bottom & "," & rectTemp.Right & "," & wpTemp.showCmd & "," & cboProfiles.SelectedItem)
'Debug.WriteLine("gwp:" & wpTemp.rcNormalPosition.Left & "," & wpTemp.rcNormalPosition.Top & "," & wpTemp.rcNormalPosition.Bottom & "," & wpTemp.rcNormalPosition.Right)
'Debug.WriteLine("gwr:" & rectTemp.Left & "," & rectTemp.Top & "," & rectTemp.Bottom & "," & rectTemp.Right)
End If
Next

'save list to settings file
File.WriteAllLines("Settings.ini", lines)

'Me.Close()

btnSave.Enabled = True
btnSaveAll.Enabled = True
btnCancel.Enabled = True
End Sub

Sub GetWindowList()
Expand Down
4 changes: 2 additions & 2 deletions TANWindowMgr/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.3.1.0")>
<Assembly: AssemblyFileVersion("1.3.1.0")>
<Assembly: AssemblyVersion("1.4.0.0")>
<Assembly: AssemblyFileVersion("1.4.0.0")>
6 changes: 3 additions & 3 deletions TANWindowMgr/frmAbout.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 85acf0d

Please sign in to comment.