Board logo

標題: UserForm 的使用問題 [打印本頁]

作者: hugh0620    時間: 2011-5-11 09:22     標題: UserForm 的使用問題

Dear 大大

       我在設計一個登入時一定要挑選listbox中的選項~ 才能夠登入使用~
          但現在我在測試時發現一個問題~ 就是點選userform上的"X"~ 就可以避過我設計的原意~
          想請問各位大大~ 如何關掉userform上的"X"~ 或是有其它方式處理??
          如下圖所示唷~
          [attach]6118[/attach]
作者: GBKEE    時間: 2011-5-11 09:35

回復 1# hugh0620
請詳看 VBA [QueryClose 事件] 的說明
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then Cancel = True
End Sub
作者: hugh0620    時間: 2011-5-11 11:48

回復 2# GBKEE


    感謝大大的教導~ 小弟會再依大大的提供的再去了解~
作者: Hsieh    時間: 2011-5-11 13:20

http://cat14051.mysinablog.com/i ... amp;articleId=48120
作者: Min    時間: 2011-5-11 23:32

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

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




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)