Solved

visual basic x out of application

Posted on 2006-06-28
5
278 Views
Last Modified: 2013-11-25
I have an application that communicates with another machine.
I don't want people to be able to x out of the application.

I have code in the form unload that exits the sub, but the form still unloads.

How do I prevent this?
0
Comment
Question by:jackjohnson44
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17002941
You can disable the 'X' button in the upper right by setting the form's Control Box property to False.
As far as making it invisible, I am not sure if this is possible.

>I have code in the form unload that exits the sub, but the form still unloads.
This assumes that you have an means of causing the unload event to happen, such as your own Close button.

Hope this helps.
-Jim
0
 

Author Comment

by:jackjohnson44
ID: 17003204
I tried that, and I got an error.
"Function or interface marked as restricted, ..."

Are you sure controlbox should be set to false?
There is no intellitype for true or false here.
0
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 500 total points
ID: 17003345
that cannot be set on runtime


try this code:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   If UnloadMode = 0 Then
   'unload mode = 0 when the user presses x or presses alt+f4
      Cancel = 1
   End If
End Sub


0
 
LVL 20

Expert Comment

by:hes
ID: 17003686
If you want to disable the x button at runtime see here:

http://www.freevbcode.com/ShowCode.Asp?ID=2448
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17015696
Disabling the control box will prevent minimize or maximize from being shown but it is easy to exit the application.

Adding the cancel=1 will prevent the program from closing unless terminate process is used.

Are you also trying to prevent ALT + F4?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now