Skip to content

Commit 02c972a

Browse files
committed
优化强制顶置逻辑 - 20250224
1 parent 8225a57 commit 02c972a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Src/TimeControl.suo

0 Bytes
Binary file not shown.

Src/TimeControl/Form1.vb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Public Class Form1
9494
Public UnSaveData As Integer '不保存设置
9595
Public UnReadData As Integer '不读取设置
9696
Public ShowModeTips As Integer '不显示横幅
97+
Public NeedStillTopMost As Integer '是否强制顶置
9798

9899
'在Alt+Tab中隐藏
99100
Const WS_EX_COMPOSITED = &H2000000 '0x02000000
@@ -132,7 +133,9 @@ Public Class Form1
132133
End If
133134
If Me.TopMost = True Then
134135
If Me.Visible = True Then
135-
SetWindowPos(Me.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS)
136+
If NeedStillTopMost = 1 Then
137+
SetWindowPos(Me.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS)
138+
End If
136139
End If
137140
End If
138141
End Sub
@@ -371,6 +374,7 @@ Public Class Form1
371374
Form2.TrackBar1.Value = CustOpacity
372375
End Sub
373376
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
377+
NeedStillTopMost = 1
374378
TimeF = "HH:mm:ss"
375379
'(在Alt+Tab隐藏窗体:启动时设置为Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None,但切换其他模式再切换回来又会显示)
376380
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
@@ -1446,7 +1450,9 @@ Public Class Form1
14461450
'If MessageBox.Show("确定要关闭时钟吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = MsgBoxResult.Yes Then
14471451
'End
14481452
'End If
1453+
NeedStillTopMost = 0
14491454
Form2.ShowDialog()
1455+
NeedStillTopMost = 1
14501456
End Sub
14511457

14521458
Private Sub Me_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing

Src/TimeControl/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' 方法是按如下所示使用“*”:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("1.1.24.25021")>
35-
<Assembly: AssemblyFileVersion("1.1.24.25021")>
34+
<Assembly: AssemblyVersion("1.1.25.25022")>
35+
<Assembly: AssemblyFileVersion("1.1.25.25022")>

0 commit comments

Comments
 (0)