Apply code to 'x' button on form

Thread Solved

Join Date: Apr 2005
Posts: 16,147
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 530
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Apply code to 'x' button on form

 
-7
  #11
Mar 29th, 2009
http://www.vb6.us/files/Image/Hello-...al-screen5.jpg

Look at this image

You see where the two drop down boxes say Command1 and Click?

Change that to say form1, and the second one to say (i think its either Terminate or onClose, will have a lightning bolt symbol next to it)

That will create a code block. In there you can type whatever you want to happen when they try to close the form
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 35
Reputation: koolsid is an unknown quantity at this point 
Solved Threads: 6
koolsid's Avatar
koolsid koolsid is offline Offline
Light Poster

Re: Apply code to 'x' button on form

 
0
  #12
Mar 29th, 2009
Originally Posted by rabbithaveit View Post
@koolsid

Does this code just disable the 'x' button?

Thats the conclusion im drawing from your image there.
It not only disable's the close button but also removes the 'close' option from the form's shortcut menu

The API is very simple... All you need to do is copy and paste the code in the general declaration of the area....

Edit: Attaching a project sample for you
Last edited by koolsid; Mar 29th, 2009 at 3:04 pm.
Attached Files
File Type: zip rabbithaveit.zip (2.1 KB, 2 views)
A good excercise for the Heart is to bend down and help another up...

Please Mark your Thread "Solved", if the query is solved...

==>If a post has helped you then Please Rate it!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Apply code to 'x' button on form

 
0
  #13
Mar 29th, 2009
Nah, unfortunately that didnt work hkdani. But thanks for the post
That's funny: it works on my vb6 program. Actually, that's the method that I learned from a Microsoft CD on VB6 programming fundamentals. I've been using that method for years. It's odd that it doesn't work for you.

What I like about the method that Microsoft recommends is it's simplicity. That's why they made Visual Basic, because they knew that programs could be written faster and programmers could be more productive, if they were provided a simple way to perform a task such as the task you describe.

From what I've read and studied from the established authors and programmers, they always recommend the KISS method: Keep it Simple Stupid.

Yes, it's true that you can use API's. And it looks quite impressive. But in the end, in the real world it's all about achieving a desired end within a certain time frame.

If you can't achieve that end with the tools that VB6 provides, then VB6 has the flexibility of being able to call the Windows APIs from the Platform Software Developer Kit (PSDK). But as a general rule, use the tools that VB6 provides and only venture into APIs if VB6 doesn't provide the means to accomplish your end.

When it comes right down to where the rubber meets the road the end user will never see your code. He only sees your program. The programmer should not try to impress someone with his knowledge of Windows APIs, the end user probably doesn't have a clue as to what an API is.

Knowledge tends to puff people up. But a truly great programmer uses his knowledge to meet the needs of his client not to enhance his ego.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 31
Reputation: rabbithaveit is an unknown quantity at this point 
Solved Threads: 0
rabbithaveit's Avatar
rabbithaveit rabbithaveit is offline Offline
Light Poster

Re: Apply code to 'x' button on form

 
0
  #14
Mar 29th, 2009
@Koolsid

I actually want the 'x' enabled. But I want to apply code to it.

@Jbennet

Thanks, that worked. Just one problem. Whether Yes or NO is chosen. The program still closes. Any reason why?
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 35
Reputation: koolsid is an unknown quantity at this point 
Solved Threads: 6
koolsid's Avatar
koolsid koolsid is offline Offline
Light Poster

Re: Apply code to 'x' button on form

 
1
  #15
Mar 29th, 2009
Originally Posted by rabbithaveit View Post
@Koolsid

I actually want the 'x' enabled. But I want to apply code to it.

@Jbennet

Thanks, that worked. Just one problem. Whether Yes or NO is chosen. The program still closes. Any reason why?
Oh Ok I understand

Is this what you want?

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  2. If UnloadMode = vbFormControlMenu Then
  3. Ret = MsgBox("Do You want to Exit?", vbOKCancel)
  4. '~~> If user decides against it...
  5. If Ret = vbCancel Then Cancel = 1
  6. End If
  7. End Sub
A good excercise for the Heart is to bend down and help another up...

Please Mark your Thread "Solved", if the query is solved...

==>If a post has helped you then Please Rate it!
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 10
Reputation: KSS is an unknown quantity at this point 
Solved Threads: 1
KSS's Avatar
KSS KSS is offline Offline
Newbie Poster

Re: Apply code to 'x' button on form

 
1
  #16
Mar 29th, 2009
Check the attachement file..
I hope that it will help you...
Attached Files
File Type: zip X button.zip (5.8 KB, 7 views)
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 31
Reputation: rabbithaveit is an unknown quantity at this point 
Solved Threads: 0
rabbithaveit's Avatar
rabbithaveit rabbithaveit is offline Offline
Light Poster

Re: Apply code to 'x' button on form

 
0
  #17
Mar 29th, 2009
Gentlemen / Women...People

Thank you so very much for your suggestions and help, I really do appreciate it.

I have not yet gotten to try the zip files. But I am going to test them now. Again, I do appreciate it.

-Russell aka Rabbit
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 31
Reputation: rabbithaveit is an unknown quantity at this point 
Solved Threads: 0
rabbithaveit's Avatar
rabbithaveit rabbithaveit is offline Offline
Light Poster

Re: Apply code to 'x' button on form

 
0
  #18
Mar 29th, 2009
KSS and Sidz

You have both my thanks!

@Sidz, the zip file you gave me actually helped with another situation I had. lol One less thread to start up. Because I want my icons to show. So thank you.

@KSS, the zip you gave was EXACTLY what I was looking for. Thank again.

Now that I think of it...That final snippet you provided Sidz was the same thing in the zip KSS gave. Thanks again.

I do appreciate it.

Thread Solved!

-Russell aka Rabbit
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,147
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 530
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Apply code to 'x' button on form

 
-7
  #19
Mar 29th, 2009
No problem. Glad you got it solved.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC