حذف دکمه ضربدر یا close درفرم

Collapse
X
 
  • زمان
  • نمایش
حذف همه
new posts
  • سهیل نصرت آبادی1

    • 2011/01/22
    • 64

    حذف دکمه ضربدر یا close درفرم

    سلام میخواستم دکمه close بالای فرم برداشته بشه
    ممنون
    اگه فایلی هست لطفا ضمیمه کنید
  • ordouei

    • 2013/05/01
    • 68
    • 45.00

    #2
    'Form
    Private Sub UserForm_Initialize()
    HideCloseButton Me
    End Sub

    Private Sub cmdExit_Payees_Click()
    Unload Me
    End Sub




    'module
    'Find the Dialog's Window
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"


    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    'Get the current window style
    Private Declare Function GetWindowLong Lib "user32" Alias


    "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

    'Set the new window style
    Private Declare Function SetWindowLong Lib "user32" Alias


    "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal


    dwNewLong As Long) As Long

    Const WS_SYSMENU = &H80000
    Const GWL_STYLE = (-16)

    'Routine to hide the close button on a userform or dialogsheet
    ' oDialog is either the Userform or Dialog object

    Sub HideCloseButton(oDialog As Object)

    Dim hWnd As Long, lStyle As Long

    'Were we given a userform or a dialog sheet
    If TypeName(oDialog) = "DialogSheet" Then

    'We had a dialog sheet. Note that pressing Escape still closes


    the dialog

    Select Case Int(Val(Application.Version))
    Case 5 'Doesn't work in Excel 5 - we only have 32-bit DLL calls


    here
    Case 7 'Excel 95
    hWnd = FindWindow("bosa_sdm_XL",


    oDialog.DialogFrame.Caption) 'DialogSheet
    Case 8 'Excel 97
    hWnd = FindWindow("bosa_sdm_XL8",


    oDialog.DialogFrame.Caption) 'DialogSheet
    Case Else 'Excel 2000 and newer
    hWnd = FindWindow("bosa_sdm_XL9",


    oDialog.DialogFrame.Caption) 'DialogSheet
    End Select
    Else
    'We had a userform
    Select Case Int(Val(Application.Version))
    Case 8 'Excel 97
    hWnd = FindWindow("ThunderXFrame", oDialog.Caption)


    'UserForm
    Case Else 'Excel 2000 and newer
    hWnd = FindWindow("ThunderDFrame", oDialog.Caption)


    'UserForm
    End Select
    End If

    'Get the current window style
    lStyle = GetWindowLong(hWnd, GWL_STYLE)

    'Turn off the System Menu bit
    SetWindowLong hWnd, GWL_STYLE, lStyle And Not WS_SYSMENU

    End Sub

    کامنت

    چند لحظه..