|
-
Jun 10th, 2007, 08:46 AM
#1
Thread Starter
Hyperactive Member
[2005] Disable X button
is there a way to disable the X button on a form?
Hello, Im a complete beginner so I if I ask obvious questions don't laugh. I have had no special training and I thought I'd learn and I thought this is the best place to start.
I started off using VB 6.0 but when I bought a new computer I decided to upgrade to VB 2005, so its a little bit different to what i'm used to
-
Jun 10th, 2007, 08:53 AM
#2
Re: [2005] Disable X button
In the Form_Closing routine of the Form you can add this in to disable the X button:
vb Code:
If e.CloseReason = CloseReason.UserClosing Then
e.Cancel = True
End If
-
Jun 10th, 2007, 09:16 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Disable X button
this code disables all ways of closing the form all I want to disable is the X button and Alt+F4
Hello, Im a complete beginner so I if I ask obvious questions don't laugh. I have had no special training and I thought I'd learn and I thought this is the best place to start.
I started off using VB 6.0 but when I bought a new computer I decided to upgrade to VB 2005, so its a little bit different to what i'm used to
-
Jun 10th, 2007, 09:21 AM
#4
Re: [2005] Disable X button
If I add a button to the form and in its button click event for example I put:
Application.Exit
it closes just fine.
-
Jun 10th, 2007, 09:29 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] Disable X button
i dont want to add exit the application. I want to close a dialog form. so i use Me.Close() and this doesnt close
Hello, Im a complete beginner so I if I ask obvious questions don't laugh. I have had no special training and I thought I'd learn and I thought this is the best place to start.
I started off using VB 6.0 but when I bought a new computer I decided to upgrade to VB 2005, so its a little bit different to what i'm used to
-
Jun 10th, 2007, 10:04 AM
#6
Re: [2005] Disable X button
You might just have to set its visible property to false then instead of calling me.close.
Then call Application.Exit at the very end to close everything when done.
-
Jun 10th, 2007, 04:14 PM
#7
Re: [2005] Disable X button
You can use an API or two to disable the 'x' close button which also removes the system menu item of Close.
http://www.vbforums.com/showpost.php...20&postcount=2
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 5th, 2008, 05:04 AM
#8
Frenzied Member
Re: [2005] Disable X button
trust me to break it
-
Apr 5th, 2008, 05:07 AM
#9
Re: [2005] Disable X button
It's not broken, it's just warning that you haven't returned a value from it on expected paths.
Are you having trouble getting it to work or something?
Last edited by stimbo; Apr 5th, 2008 at 05:48 AM.
-
Apr 5th, 2008, 05:44 AM
#10
Hyperactive Member
Re: [2005] Disable X button
You could just set the control box property to false......but then there would be no maximize or minimize buttons.
-
Apr 5th, 2008, 02:19 PM
#11
Re: [2005] Disable X button
You could do that but then the rest of the controls/buttons will be removed too. If you only want the 'x' close button disabled then that wont work.
You can have the sub a Sub instead of a Function and that will remove the warning.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|