473,396 Members | 2,129 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,396 software developers and data experts.

Close Button

Ali Rizwan
925 512MB
Hi all,
We all have seen a close button on right side of title bar on any form in vb6.0
I want that if i click on that button form doesn't terminate a timer control will enabled.
Suppose if i click on close button a msgwill appear or a timer control will enabled true.
But form will not terminated.
Thanx
Oct 11 '07 #1
11 13496
Dan2kx
365 100+
in excel there is a pice of code known as the Query_close procedure, i have no idea if it works in ur situation but i would do a search for that!
Oct 11 '07 #2
Tig201
103 100+
you can set Cancel to 1 in the form_unload and the form will not close.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Unload(Cancel As Integer)
  2.   Cancel = 1
  3. End Sub
  4.  
Just be sure to put it in an If Satement so that you can close the form.
Oct 11 '07 #3
Killer42
8,435 Expert 8TB
Generally it's better to use the Form_QueryUnload procedure, because this includes a parameter that tells you why the form is trying to unload (code, Windows shutting down, user clicked "close" button", etc.)
Oct 11 '07 #4
Ali Rizwan
925 512MB
Generally it's better to use the Form_QueryUnload procedure, because this includes a parameter that tells you why the form is trying to unload (code, Windows shutting down, user clicked "close" button", etc.)
Thanks Killer.
But how to use it? I have never used this command.
Thanks
Oct 12 '07 #5
Killer42
8,435 Expert 8TB
But how to use it? I have never used this command.
You should be able to create the procedure easily enough, just by selecting Form in the left-hand drop-down box (top of the code window), then choosing QueryUnload in the right-hand one.

Then try posting in this code to demonstrate what's going on.

Expand|Select|Wrap|Line Numbers
  1. Select Case UnloadMode
  2.   Case vbFormControlMenu
  3.     ' User attempting to close the window.
  4.     MsgBox "Hah! You can't get me that way."
  5.     Cancel = True
  6.   Case vbFormCode
  7.     ' Unload was invoked from my code. Probably should allow it.
  8.   Case vbAppWindows
  9.     ' Windows is ending. Probably should allow it. You
  10.     ' might want to ask "save before exiting?" or something.
  11.   Case vbAppTaskManager
  12.     ' Task Manager is closing me. Probably that pesky user again!
  13.     MsgBox "Nope! Give up, I'm not going anywhere."
  14.     Cancel = True
  15.   Case vbFormMDIForm
  16.     ' Um... this only applies to MDI child forms.
  17.   Case vbFormOwner
  18.     ' Form is closing because its owner is closing.
  19.     ' Whatever that means...
  20. End Select
Oct 12 '07 #6
jamesd0142
469 256MB
There is a form closed method which you can use for this.

Double-click your form, and change the form load to form closed in the combo box on the top right of your code.

Thanks
Oct 12 '07 #7
vdraceil
236 100+
If you don't want the form to unload on clicking the close button, it is same as having no close button at the top. Try setting ClipControls and Controlbox properties of the form to false and set form's caption=""
Oct 12 '07 #8
ThaDu
1
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Unload(Cancel As Integer)
  2.     MsgBox "A"
  3.     Timer1.Enabled = True
  4.     Cancel = 1
  5. End Sub
  6. Private Sub Timer1_Timer()
  7.     End
  8. End Sub
[email removed]
Oct 13 '07 #9
Killer42
8,435 Expert 8TB
There is a form closed method which you can use for this.
Not in VB6, there isn't.
Oct 14 '07 #10
jamesd0142
469 256MB
Not in VB6, there isn't.
Once again im not using that version sorry.
visual basic 2005 express edition 'forClosed' and im sure its the same in vb.net, or very simular anyways.

Is there any other way of running code when the user closes the form ??

Thanks

in vb.net and vb 2005 express edition this works...
Expand|Select|Wrap|Line Numbers
  1.    Private Sub Form1Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
  2.  
  3.         If MessageBox.Show("Are you sure to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
  4.             e.Cancel = False
  5.         Else
  6.             e.Cancel = True
  7.         End If
  8.  
  9.     End Sub
  10.  
Oct 15 '07 #11
Killer42
8,435 Expert 8TB
In VB6 (which Ali did mention) I believe you're limited to the Form_QueryUnload and Form_Unload event procedures.
Oct 15 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: moose | last post by:
OK Popup window? No problem PDF in popup? No problem But what about a couple of Close Window buttons? Imagine a "Close Window" button at the top of the popup page. Then the PDF which can...
5
by: Nick250 | last post by:
I have a simple app that I created for our Real Estate office using Access 2000 and it is working fine except for on thing. I need to keep the close button hidden from the users. No problem...
5
by: Reggie | last post by:
Hi and TIA! I have a form and have set the Close Button to false so that users must exit using my close button. However when I open a Report from this form I want the close button to be available...
2
by: David | last post by:
Is there anyway to get a different DialogResult or detect that the user clicked the close button on a MessageBox? I have a message box that pops up when my program first starts that only has an ok...
4
by: mhifd009 | last post by:
I have disabled a close button in the property section of a form (FRM1), as i open the form the close button has gone (i have programmed close button), but as i close the form, the form that opened...
1
by: somtabu | last post by:
hello, i have a problem in vb.net windows application, verson is 2005 and framework is 2.0 I want to close a form by using the close button which is right hand top side of the window. i want,...
2
by: Bruce | last post by:
Hello, I have a form in an Access 2003 application which opens maximized. Its CloseButton property is set to false. On this form I have a command button that opens a report in preview mode. ...
0
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.