zachtk8702
Feb 10 2005, 04:53 PM
This example will "minimize" your program to the system tray when you click on a button, and restore it when you click the system tray icon. For this example you'll need: 1 Form - Form1 1 button - Command1 Add a Module to your project, and ad this code: CODE ' Create an Icon in System Tray Needs Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long uCallBackMessage As Long hIcon As Long szTip As String * 64 End Type Public Const NIM_ADD = &H0 Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const WM_MOUSEMOVE = &H200 Public Const NIF_MESSAGE = &H1 Public Const NIF_ICON = &H2 Public Const NIF_TIP = &H4 Public Const WM_LBUTTONDBLCLK = &H203 'Double-click Public Const WM_LBUTTONDOWN = &H201 'Button down Public Const WM_LBUTTONUP = &H202 'Button up Public Const WM_RBUTTONDBLCLK = &H206 'Double-click Public Const WM_RBUTTONDOWN = &H204 'Button down Public Const WM_RBUTTONUP = &H205 'Button up
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Now at Form1 add this: CODE Code: Dim nid As NOTIFYICONDATA ' trayicon variable
'---------------------- '--- command1 click --- '---------------------- Private Sub Command1_Click() minimize_to_tray End Sub
'------------------------ '--- create tray icon --- '------------------------ Sub minimize_to_tray() Me.Hide nid.cbSize = Len(nid) nid.hwnd = Me.hwnd nid.uId = vbNull nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE nid.uCallBackMessage = WM_MOUSEMOVE nid.hIcon = Me.Icon ' the icon will be your Form1 project icon nid.szTip = "blablabla text u want to show when mouse over tray iicon" & vbNullChar Shell_NotifyIcon NIM_ADD, nid End Sub
'--------------------------------------------------- '-- Tray icon actions when mouse click on it, etc -- '--------------------------------------------------- Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Dim msg As Long Dim sFilter As String msg = x / Screen.TwipsPerPixelX Select Case msg Case WM_LBUTTONDOWN Me.Show ' show form Shell_NotifyIcon NIM_DELETE, nid ' del tray icon Case WM_LBUTTONUP Case WM_LBUTTONDBLCLK Case WM_RBUTTONDOWN Case WM_RBUTTONUP Me.Show Shell_NotifyIcon NIM_DELETE, nid Case WM_RBUTTONDBLCLK End Select End Sub
'------------------------------ '--- form Actions On unload --- '------------------------------ Private Sub Form_Unload(Cancel As Integer) Shell_NotifyIcon NIM_DELETE, nid ' del tray icon end Sub
Instead of restore it when you click the tray icon, you can make it show a popup with some actions: maximize/close//about//etc!
Reply
iGuest
Dec 11 2007, 04:26 AM
AWESOME MAN, thank you for the help. FAR simpler then any other examples. -Adam
Reply
iGuest
Dec 25 2007, 05:14 PM
Error%20%5C%22Invalid%20use%20of%20property%5C%22
[tutorial] Visual Basic 6 Minimize To Tray
Hello, When I try this solution, I have error "Invalid use of property" on instruction minimize_to_tray. Do you have a solution ? Thanks & regards. -Marcel
Reply
iGuest
Apr 8 2008, 06:49 PM
Great! Thank you for wonderful code. -reply by Zoran Milobratović
Reply
iGuest
Jul 4 2008, 07:04 AM
Great Work
[tutorial] Visual Basic 6 Minimize To Tray
This was exactly what I was looking for. Works great -reply by fourtwunty
Reply
Recent Queries:--
"visual basic 6" invalid icon - 0.21 hr back. (3)
-
minimize to tray vb - 2.12 hr back. (1)
-
vb minimize - 4.39 hr back. (1)
-
vb minimize toolbar - 4.52 hr back. (1)
-
vb minimize to toolbar - 4.62 hr back. (1)
-
minimize to tray vb6 - 6.23 hr back. (2)
-
vb 6 tray - 6.62 hr back. (1)
-
how to minimize to tray in vb - 6.70 hr back. (1)
-
vbasic send to tray - 9.02 hr back. (1)
-
tray icon visual basic 6 - 11.37 hr back. (1)
-
minimize to tray in vb6 - 13.31 hr back. (1)
-
minimize to tray visual studio - 13.74 hr back. (1)
-
vb6 script minimize to tray - 17.72 hr back. (1)
-
task tray tut for vb 2008 - 17.95 hr back. (1)
Similar Topics
Keywords : visual, basic, 6, minimize, tray, minimize, tray
- Tray Info Message
Kind of popup thingie (7)
Mysql In Visual Basic
Mysql in visual basic (5) I'm am trying to create a script so that visual basic 6 can interact with mysql Any ideas?....
Beginning Visual Basic
(4) CAn anyone give me a guide on VB? I've decided to learn it and I need something to work with....
thanks ....
My Guidewriter
Simple Visual Basic program to aid in making guides (3) I wrote this about 3 months ago for a different forum (Runescape Forums, one I'm currently a
G-Mod of. ) and I figured I'd share it with you. All it is, is a text editor with built in
buttons and menus for adding BBCodes. For example, if you wanted to make something bold, you type
what you want, highlight it, find bold in the text menu and click it. The nicest thing is, you
can save, and you don't have to worry about a forum failing after taking hours to write a guide.
I highly suggest you try it if you write guides often, the members on RsForums really lo....
Some Visual Basic 6.0 Uncompleted Projects
(2) hi friends, i have some good complete and incomplete projects in visual basic 6.0. and now i
want to sale them for some credit points. 100 credit points only....
Visual Basic And Internet Transmission
is it possible to encrypt a http request? (2) I've used VB before which is why im asking this in the VB forum and not any other forum because
i know with any other language other than PHP i have no chance so i dont actually know if this is
possible with VB WHat i want to do is change a HTTP request that is sent to a server so that a web
filter cannot understand it and block the request. Before anyone says that i shouldnt do that its
hacking etc...its not...im only doing it to see if it can be done. if i wanted to get around a
filter i wouldnt bother making my own tool I'd use someone else (skript kiddy-ish ....
Visual Basic 6
(5) Well currently I have the working model edition for Visual Basic 6.0 which won't allow me to
make .exe files. I was looking into buying the Learning Edition but I can't find it cheap or in
stock anywhere. I want to try and find it for under $100 used or new. If anyone has it, and
would like to make the .exe file for me if I send you the files that would be great, or if anyone
could help me find it for cheap.....
Visual Basic Express Edition Beta
How does it work? (2) Hey, I'm using (sorta) Visual Basic Express Edition Beta 2 (long name, eh?), but I can't
find any good tutorials on it; all of them are for visual basic.net... Is this the same thing? I
don't think so, and if I'm right, where can I go to get help for it?....
Visual Basic 6.0 Help Needed
Adding lines to a textbox without delete (13) I need help with Visual Basic 6.0 and adding lines to a textbox without deleting any previous
lines.. I've gotten as far as finding a way to add the lines, but it deletes the prevous entree.
Help is appreciated!....
Free Copy Of Visual Studio.net Pro
STUDENTS ONLY (11) Visit THE SPOKE for your free copy of Visual Studio.NET.....
[tutorial] Visual Basic 6 Removing List Duplicates
Removing List Duplicates (2) Removing duplicates from lists is something that you'll have to put up with if you're, say,
parsing names off Outwar. Many delete-duplicate for...next loops are very slow, especially when you
have thousands of names to loop through several thousand times for each name on the list. This
function that I made is, in my opinion, the best and quickest way to do it without too many annoying
and slow for loops (good for lists 1k +). It compares lstA to lstB. Anything that is in both lists
is added to lstC. To change it so that anything that isn't in both lists is ....
[tutorial] Visual Basic 6 Downloading Images From A Webpage
Downloading Images from a webpage (2) Here's how to grab an image off the internet easily. You'll need an Inet on your form to do
this. You can always get rid of your string variables and substitute the actual strings: Code:
CODE Dim localFile As String Dim remoteFile As String Dim fNum As Long Dim b() As Byte
remoteFile = "http://www.site.com/image.jpg" localFile = "C:\image.jpg"
fNum = FreeFile b() = Inet1.OpenURL(remoteFile, icByteArray) Open
localFile For Binary As #fNum Put #fNum, , b() Close #fNum MsgBox "Done....
Looking for visual, basic, 6, minimize, tray, minimize, tray
|
|
Searching Video's for visual, basic, 6, minimize, tray, minimize, tray
|
advertisement
|
|