Userformdaki X butonunu yok etme

Katılım
6 Temmuz 2006
Mesajlar
51
Herkese merhabalar
Ben userform1deki X kapatma butonunu görükmemesini istiyorum.Nasıl yapabilrim?
 
Katılım
7 Temmuz 2004
Mesajlar
327
Excel Vers. ve Dili
office xp pro türkçe
Bu işlem için api gerekli
aşağıdaki kodları userforma kopyalayıp deneyin
****userformun x düğmesini pasif yapmak için Api ********
[vb:1:72eaa55108]Option Explicit

Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long

Private Declare Function GetSystemMenu Lib "user32" (ByVal _
hwnd As Long, ByVal bRevert As Long) As Long

Private Declare Function DeleteMenu Lib "user32" (ByVal _
hMenu As Long, ByVal nPosition As Long, ByVal wFlags _
As Long) As Long

Private Declare Function DrawMenuBar Lib "user32" (ByVal _
hwnd As Long) As Long

Private Const SC_CLOSE As Long = &HF060

Private hWndForm As Long
Private bCloseBtn As Boolean

Private Sub UserForm_Initialize()
If Val(Application.Version) >= 9 Then
hWndForm = FindWindow("ThunderDFrame", Me.Caption)
Else
hWndForm = FindWindow("ThunderXFrame", Me.Caption)
End If

bCloseBtn = False
SetUserFormStyle
End Sub

Private Sub SetUserFormStyle()
Dim frmStyle As Long
Dim hSysMenu As Long

If hWndForm = 0 Then Exit Sub

If bCloseBtn Then
hSysMenu = GetSystemMenu(hWndForm, 1)
Else
hSysMenu = GetSystemMenu(hWndForm, 0)
DeleteMenu hSysMenu, SC_CLOSE, 0&
End If

DrawMenuBar hWndForm
End Sub

Private Sub optCloseOn_Click()
bCloseBtn = True
cmdBeenden.Cancel = True
SetUserFormStyle
End Sub

Private Sub optCloseOff_Click()
bCloseBtn = False
cmdBeenden.Cancel = False
SetUserFormStyle
End Sub
[/vb:1:72eaa55108]
Bir diğer Api bu api de userformun x işarteti hiç gözükmemektedir.
[vb:1:72eaa55108]Option Explicit

Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long

Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex _
As Long) 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 Declare Function DrawMenuBar Lib "user32" (ByVal _
hwnd As Long) As Long

Private Const GWL_STYLE As Long = -16
Private Const WS_SYSMENU As Long = &H80000

Private hWndForm As Long
Private bCloseBtn As Boolean

Private Sub UserForm_Initialize()
If Val(Application.Version) >= 9 Then
hWndForm = FindWindow("ThunderDFrame", Me.Caption)
Else
hWndForm = FindWindow("ThunderXFrame", Me.Caption)
End If

bCloseBtn = False
SetUserFormStyle
End Sub

Private Sub SetUserFormStyle()
Dim frmStyle As Long

If hWndForm = 0 Then Exit Sub

frmStyle = GetWindowLong(hWndForm, GWL_STYLE)

If bCloseBtn Then
frmStyle = frmStyle Or WS_SYSMENU
Else
frmStyle = frmStyle And Not WS_SYSMENU
End If

SetWindowLong hWndForm, GWL_STYLE, frmStyle

DrawMenuBar hWndForm
End Sub

Private Sub optCloseOn_Click()
bCloseBtn = True
cmdBeenden.Cancel = True
SetUserFormStyle
End Sub

Private Sub optCloseOff_Click()
bCloseBtn = False
cmdBeenden.Cancel = False
SetUserFormStyle
End Sub
[/vb:1:72eaa55108]
 
Üst