|
-
Aug 18th, 2006, 08:34 AM
#1
Thread Starter
Lively Member
Few Questions
1.How can I change the behavior of the X button on a window.
2.If I do the above what code would I need to make it minimize to the tray.
3.Once in tray. how can I make it so that if you right click, it will bring up a little menu like on other apps. Thanks.
-
Aug 18th, 2006, 08:37 AM
#2
Re: Few Questions
The 'x' button click fires the Form_QueryUnload event where you can check the UnloadMode for it closing because of being clicked. Then cancel the unload and code to minimize to the system tray. Code for the minimize to tray can be found with a search on VBF
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 
-
Aug 18th, 2006, 08:39 AM
#3
Re: Few Questions
VB Code:
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1 'prevents from closing
'your continue code
End Sub
-
Aug 18th, 2006, 08:39 AM
#4
Addicted Member
Re: Few Questions
try this one!
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Me.WindowState = vbMinimized
Cancel = True
End Sub
-
Aug 18th, 2006, 09:05 AM
#5
Re: Few Questions
The problem with just added minimize function to the QueryUnload event is that regardles of how you are closing your application, the only thing that will ever happen is that it will be minimized. You need a way to both minimize the form it the X is clicked, but, also to completely close the application if so desired. The way to do that is to check the UnloadMode. That will tell HOW the window is being closed.
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then 'they hit the X
Me.WindowState = vbMinimized
Cancel = True
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
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
|