利用SetWindowPos讓視窗永遠置於最上方

首先請在程式裡加入timer元件

並啟用timer(名稱timer1)

秒數部分設100

然後輸入以下代碼(直接貼上並蓋掉原本的程式碼)

Option Strict Off

Option Explicit On

Public Class Form1

Inherits System.Windows.Forms.Form

Private Declare Function SetWindowPos Lib "user32" (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

Dim IntR As Object

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.Top = 0

Me.Left = 0

Me.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width

Me.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

IntR = SetWindowPos(Me.Handle.ToInt32, -1, 0, 0, 0, 0, 3)

End Sub

End Class

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料