返回列表 上一主題 發帖

UserForm 的使用問題

UserForm 的使用問題

Dear 大大

       我在設計一個登入時一定要挑選listbox中的選項~ 才能夠登入使用~
          但現在我在測試時發現一個問題~ 就是點選userform上的"X"~ 就可以避過我設計的原意~
          想請問各位大大~ 如何關掉userform上的"X"~ 或是有其它方式處理??
          如下圖所示唷~
          UserForm 的應用.JPG
學習才能提升自己

回復 1# hugh0620
請詳看 VBA [QueryClose 事件] 的說明
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then Cancel = True
End Sub

TOP

回復 2# GBKEE


    感謝大大的教導~ 小弟會再依大大的提供的再去了解~
學習才能提升自己

TOP

學海無涯_不恥下問

TOP

呵呵呵~ 剛好有寫過! 試試看吧!

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_style = (-16)
Private Const CLOSEBOX As Long = &H80000

Private Sub UserForm_Initialize()
    Dim hWndform As Long
    Dim Istyle As Long
   
    hWndform = FindWindow("Test", Me.Caption)
    Istyle = Istyle And Not CLOSEBOX
    SetWindowLong hWndform, GWL_style, Istyle
End Sub
若是我回答,使您滿意,請您讓我知道!                  
若是我的回覆,您仍有其他見解,也請您不嗇指教!

TOP

        靜思自在 : 願要大、志要堅、氣要柔、心要細。
返回列表 上一主題