CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    3

    changing window properties ?

    I would like to disable the 'X' (close window in upper right corner) on a main window of an application. Can I do this ? All I have is the window handle passed in from another application. Thanks in advance.

  2. #2
    Join Date
    Jul 2003
    Location
    I'm Here!
    Posts
    31
    Set the ControlBox property to False, but that's going to disable your Minimize and Maximize as well.

  3. #3
    Join Date
    Nov 2002
    Posts
    278
    The code assumes one Form and a command button named Command1. The code below will suppress clicking on the X on the top right corner as well as <Alt><F4> key presses. The only way to unload the form is clicking Command1 button or from the Task Manger I reckon.

    Code:
    Option Explicit
    Dim bUnload As Boolean
    
    
    Private Sub Command1_Click()
        bUnload = True
        Unload Me
    End Sub
    
    Private Sub Form_Load()
    
        bUnload = False
    
    End Sub
    
    
    Private Sub Form_Unload(Cancel As Integer)
        If bUnload Then
        Else
            Cancel = 1
        End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured