1. 程式人生 > >VB視窗全屏與置頂

VB視窗全屏與置頂

全屏
Private Sub Form_Load()
    Me.Width = Screen.Width
    Me.Height = Screen.Height
    Me.WindowState = 2
End Sub

置頂
1.在VB的通用程式碼裡寫入API宣告

Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, _
    ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
    ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

2.因為我們要讓視窗置頂

那麼就在Form_Load()事件裡寫入如下程式碼

Dim myval
myval = SetWindowPos(form1.hwnd, -1, 0, 0, 0, 0, 3)