Compile Error
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Compile Error

  1. #1
    Join Date
    Sep 2004
    Posts
    61

    Compile Error

    Hi I got the following sample code from the Internet.
    The purpose to disable the close [X] option on the form
    But when I compile, I encountered the following error:
    Compile Error :
    Only comments may appear after End Sub, End Function or End Property

    Please advise.
    Thanks, Sally


    Code:
    Option Explicit
    
    Public Declare Function GetSystemMenu Lib "user32" _
        (ByVal hwnd As Long, _
         ByVal bRevert As Long) As Long
    
    Public Declare Function RemoveMenu Lib "user32" _
        (ByVal hMenu As Long, _
         ByVal nPosition As Long, _
         ByVal wFlags As Long) As Long
    
    Public Const MF_BYPOSITION = &H400&
    
    
    Public Sub DisableCloseWindowButton(frm As Form)
    
        Dim hSysMenu As Long
    
        'Get the handle to this windows
        'system menu
        hSysMenu = GetSystemMenu(frm.hwnd, 0)
    
        'Remove the Close menu item
        'This will also disable the close button
        RemoveMenu hSysMenu, 6, MF_BYPOSITION
    
        'Lastly, we remove the seperator bar
        RemoveMenu hSysMenu, 5, MF_BYPOSITION
    
    End Sub
    '--end code block
    Now call the DisableCloseWindowButton from your forms load event.
    
    Private Sub Form_Load()
        DisableCloseWindowButton Me
    End Sub
    Last edited by Cimperiali; October 8th, 2004 at 09:40 AM. Reason: Adding Code tags

  2. #2
    Join Date
    Sep 2004
    Posts
    61

    Re: Compile Error

    Ok, I manage to solve it.
    FYI, put the declarations above the coding.
    Sally

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center