on each form is the "X" at the top right of Form. how ya how to disable or remove "x" is it?

Recommended Answers

All 4 Replies

Go to Properties and select From BorderStyle 0-None.

see if this help :

Declaration

Option Explicit

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

Private Declare Function RemoveMenu Lib "user32" _
    (ByVal hMenu As Long, _
     ByVal nPosition As Long, _
     ByVal wFlags As Long) As Long
     
Private Const MF_BYPOSITION = &H400&

Function to disable

Public Function DisableCloseButton(frm As Form) As Boolean
    Dim lHndSysMenu As Long
    Dim lAns1 As Long, lAns2 As Long
   
    lHndSysMenu = GetSystemMenu(frm.hwnd, 0)
    lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION)
    lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION)
    DisableCloseButton = (lAns1 <> 0 And lAns2 <> 0)
End Function

Call When form load

Private Sub Form_Load()
Call DisableCloseButton(Me)
End Sub

If your question already answered then please mark thread as solved.
Mark thread as solved really helping another member when they read your thread too (no doubt for them to learn from your thread).

commented: really great answer, as always. +8
commented: owesome :) +4

thank you for your help and it was very useful to me. thank you JXman

You're Welcome...
Please Mark this thread as solved.
We've helps you several times but you never mark your thread as solved.
Mark thread as solved helping another member to learn from your threads.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.