473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

VB Form: Controlbox = False

I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose on
the form.

Form1.canclose = False or something like that.

Im looking thru msdn and all i found so far is the Controlbox Y/N
May 10 '06 #1
7 6757
in the form closing event just type, e.cancel()

"Miro" <mi******@golden.net> wrote in message
news:u$**************@TK2MSFTNGP05.phx.gbl...
I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose
on the form.

Form1.canclose = False or something like that.

Im looking thru msdn and all i found so far is the Controlbox Y/N

May 10 '06 #2
On Mon, 8 May 2006 22:47:06 -0400, "Miro" <mi******@golden.net> wrote:
I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose on
the form.

Form1.canclose = False or something like that.

Im looking thru msdn and all i found so far is the Controlbox Y/N


I think without exception, a user would fully expect the "X" button to
close the form, otherwise, consider it a bug.

What is the logic of a non-functioning "X" button?

Gene
May 10 '06 #3
On Mon, 8 May 2006 21:01:11 -0700, "Jason" <js******@comcast.net>
wrote:
in the form closing event just type, e.cancel()

e.Cancel () by itself would prohibit the form from closing under any
circumstance - would it not?

Gene
"Miro" <mi******@golden.net> wrote in message
news:u$**************@TK2MSFTNGP05.phx.gbl...
I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose
on the form.

Form1.canclose = False or something like that.

Im looking thru msdn and all i found so far is the Controlbox Y/N

May 10 '06 #4
"Miro" <mi******@golden.net> schrieb:
I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose
on the form.

Form1.canclose = False or something like that.

Check out the form's '*Closing*' (and '*Closed*') events. Inside the event
handler, set 'e.Cancel' to 'True'

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 10 '06 #5
Miro,

In addition to Gene, without a message box telling that it is not closing
and telling the reason why, this is considered as a bug in your program.

Cor

"Miro" <mi******@golden.net> schreef in bericht
news:u$**************@TK2MSFTNGP05.phx.gbl...
I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose
on the form.

Form1.canclose = False or something like that.

Im looking thru msdn and all i found so far is the Controlbox Y/N

May 10 '06 #6
Add this to your Form's Code and you can do whatever you want then the user
clicks the "X":
<System.Security.Permissions.PermissionSetAttribut e(System.Security.Permissions.SecurityAction.Deman d, Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As Message)
Dim SC_Close As Integer = &HF060
Dim WM_SysCommand As Integer = &H112
Select Case (m.Msg)
' The WM_ACTIVATEAPP message occurs when the application
' becomes the active application or becomes inactive.
Case &H112 'WM_SYSCOMMAND
Select Case m.WParam.ToInt32
Case &HF060 'SC_Close 'User clicked on "X"
'DO WHATEVER YOU WANT HERE
Exit Sub
End Select
End Select
MyBase.WndProc(m)
End Sub

--
Dennis in Houston
"Cor Ligthert [MVP]" wrote:
Miro,

In addition to Gene, without a message box telling that it is not closing
and telling the reason why, this is considered as a bug in your program.

Cor

"Miro" <mi******@golden.net> schreef in bericht
news:u$**************@TK2MSFTNGP05.phx.gbl...
I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose
on the form.

Form1.canclose = False or something like that.

Im looking thru msdn and all i found so far is the Controlbox Y/N


May 10 '06 #7
Thank you,

I just couldnt figure out where vb.net is hiding all these events.

You are correct, if there is a "X" box a user would expect it to close. I
agree,

I am trying to play with events and disable and enable things to find out
where "everything is" in vb.net

I just found out now how to access all the events on a form. I could never
find them.

I kept pulling up my "form" in my "CLASS NAME" drop down and looked for the
events in the "METHODS" drop down there.
I just now found the Base Class Events ... so i can now see all the events
for the form.
- I couldnt figure out how to access all the other events for the form.

But going back to the original question, I was thinking of a form where the
"X" is showing, but i only allow someone to close
it if an event or something else isnt partially being worked on - that
cannot be stopped 1/2 way thru.

Thank you again,

My basic questions - as basic as they seem, this one turned on a light with
actually being able to find how to access all the events.

Im slowely teaching myself vb.net and having a hard time adjusting to some
things. Im use to using a pure "coder" where everything is written in text.

Miro
"Miro" <mi******@golden.net> wrote in message
news:u$**************@TK2MSFTNGP05.phx.gbl...
I can use the property of the Form to remove the "x" from the top of the
form.

Is there a way in VB to leave the X there but program something so you
cannot close the form?

Or like an ONCLOSE event that you can just put "cancel" ?

If i remember correctly...back in vb 1.0 days or so there was a canclose
on the form.

Form1.canclose = False or something like that.

Im looking thru msdn and all i found so far is the Controlbox Y/N

May 10 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yasutaka Ito | last post by:
Hi, I have an MDI application, in which I want to embed one form (System.Windows.Forms.Form) into a specified area of my MDI application. This is, wihtout affecting the capability of other child...
0
by: Ron James | last post by:
I have a Dialog type form that starts a worker thread, allows the thread to update its progess and provides a Cancel button. Following advice from Chad Meyers in a recent posting, the worker...
1
by: Uchiha Jax | last post by:
Standard Framework documentation goes into great detail " A top-level form is a window that has no parent form, or whose parent form is the desktop window. Top-level windows are typically used as...
3
by: Dan M | last post by:
Hi, Upgraded a 1.0 project to 1.1. Had a form that I opened with ShowDialog. ControlBox set to false at designtime and I set caption in the form load (me.text="my title"). This worked fine in...
1
by: Saso Zagoranski | last post by:
Hi, In .NET 2.0 I have a MDI (parent) form with a menu and a toolbar. I also have a MDI child form displayed in the mdi parent form. The problem is, that when I maximize the child form it's...
9
by: mohit.akl | last post by:
Hey guys & gals I am havng trouble modifying the control box. I want to make the maximise button invisible and have minimisise button instead of it. Like this _ X (not like _ o X ) How...
0
by: Script Houston | last post by:
I have first application opent a form Form1 nothing else. I have second application which will find the first application process and close it. bellow is the second application: static...
2
by: ziycon | last post by:
This function is in a class file, can't get the frmLogin form to hide when a user logins in, the frmMain will open fine though!??? public void login(string username,string password) { ...
2
by: lenniekuah | last post by:
Hullo Good Friends, I need your help. Please Help me. I am trying to pass the name of the Calling FORM FRMSALES to the Loaded FORM FRMPOPUPCustomers so that FRMPOPUPCustomer will set the FRMSALES...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.