Chào mọi người.
Em xin các AC chỉnh code để khi double click vào caption của userform thì không thu nhỏ userform nữa. Vì em muốn Userform lúc nào cũng che hết màn hình.
Code trong File là em sưu tầm của Thầy Batman1 .
Mong mọi người giúp đỡ.
Em xin các AC chỉnh code để khi double click vào caption của userform thì không thu nhỏ userform nữa. Vì em muốn Userform lúc nào cũng che hết màn hình..
Rồi bạn nghĩ là khi không cần min, max thì chỉ xóa Or hichic Or Blala là được. Nhưng bạn không nghĩ tới là khi đó thì đọc, ghi style là vô dụng.
Bạn ghép nối không chuẩn mà lại nói đó là code của tôi thì người ta lại cười tôi.
-------------
Về chuyện trong chủ đề thì tôi làm cho bạn lần cuối. Muốn nhiều mầu mè thì nên tự học viết code.
Có 2 cách, bạn nên thử cả 2 rồi lựa chọn.
1. Trong Module1 sau #End If thêm
Mã:
Private Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Const LOGPIXELSX = 88
Private Const LOGPIXELSY As Long = 90
Private Const POINTS_PER_INCH As Long = 72
Private Const HORZRES As Long = 8
Private Const VERTRES As Long = 10
Public Sub ShowForm(form As Object)
Dim DC As Long, PixelsPerPointsX As Double, PixelsPerPointsY As Double, w As Long, h As Long
DC = GetDC(0)
PixelsPerPointsX = GetDeviceCaps(DC, LOGPIXELSX) / POINTS_PER_INCH
PixelsPerPointsY = GetDeviceCaps(DC, LOGPIXELSY) / POINTS_PER_INCH
w = GetDeviceCaps(DC, HORZRES)
h = GetDeviceCaps(DC, VERTRES)
ReleaseDC 0, DC
With form
.Left = 0
.Top = 0
.Width = w / PixelsPerPointsX
.Height = h / PixelsPerPointsY
End With
End Sub
Code mới cho UserForm_Activate
Mã:
Private Sub UserForm_Activate()
ShowForm Me
End Sub
2. Trong Module1 thêm
Mã:
Private Const SW_RESTORE As Long = 9
Sub ShowFormNormal(ByVal hWnd As Long)
ShowWindow hWnd, SW_RESTORE
End Sub
Code mới cho UserForm_Activate
Mã:
Private Sub UserForm_Activate()
Dim w As Long, h As Long
ShowFormMax hWnd
w = Me.Width
h = Me.Height
ShowFormNormal hWnd
With Me
.Left = 0
.Top = 0
.Width = w
.Height = h
End With
End Sub