Eliminate white cross in red field in Userform

Hans810

Board Regular
Joined
Dec 1, 2005
Messages
63
Can somebody tell me how I can eliminate the white cross in the little red box (in the right hand upper corner) of a user form (and possible other dialogue boxes)?

Thanks in advance.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Are you referring to the Close button?

If you are then the only way I think you can eliminate it would be using the Windows API.

You can however stop it working using the form's QueryColse event.
 
Upvote 0
Well like I said as far as I know you can only remove it using the Windows API.

What do you actually want to do?
 
Upvote 0
Thanks for your reply Norie.
In fact I do not want the user to close the form.
They have to answer either this or that.
If I disable the button, I better take it away!
An inactivated button makes no sense.
 
Upvote 0
Again like I said the only way to actually remove it would be with the Windows API.
 
Upvote 0
Thanks Norie,

I will put my nose in the (Windows) books.... .

Best regards from The Netherlands.
 
Upvote 0
From Hans Herber, this goes in the userform module and will produce the userform without that "X" Close button on the title bar:


Option Explicit

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

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 Sub UserForm_Initialize()

Dim xl_hwnd, lStyle
xl_hwnd = FindWindow(vbNullString, Me.Caption)
If xl_hwnd <> 0 Then
lStyle = GetWindowLong(xl_hwnd, GWL_STYLE)
lStyle = SetWindowLong(xl_hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU)
DrawMenuBar xl_hwnd
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,207,095
Messages
6,076,551
Members
446,213
Latest member
bettigb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top