|
-
Jan 1st, 2006, 03:53 PM
#1
Thread Starter
Member
variable txt in Tray
Hi,
I want to show a text in the tray. But I must create this text while the prog is running.
I´ve tried to print text to a picturebox with "print" and get the "image" over the .picture method.. But it doesn´t work ...
Greetings
Byte
-
Jan 1st, 2006, 04:04 PM
#2
Re: variable txt in Tray
Check out this balloon tip sample project by Randy Birch.
-
Jan 1st, 2006, 04:12 PM
#3
Re: variable txt in Tray
Or, a tooltip. I'm not sure how the weather programs display the temperature in the system tray.
-
Jan 1st, 2006, 11:00 PM
#4
Re: variable txt in Tray
Or this..
Add to your Form: 1 imagelist, 1 picturebox, 1 command button
VB Code:
Option Explicit
Private Type NotifyIconData
Size As Long
Handle As Long
ID As Long
Flags As Long
CallBackMessage As Long
Icon As Long
Tip As String * 64
End Type
Private Declare Function Shell_NotifyIcon _
Lib "shell32" Alias "Shell_NotifyIconA" ( _
ByVal Message As Long, Data As NotifyIconData) As Boolean
Private Const AddIcon = &H0
Private Const ModifyIcon = &H1
Private Const DeleteIcon = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDBLCLK = &H203
Private Const MessageFlag = &H1
Private Const IconFlag = &H2
Private Const TipFlag = &H4
Private Data As NotifyIconData
Private mNumTray As Long 'Just to add a number
Private Sub Command1_Click()
Randomize
Picture1.Cls
Picture1.BackColor = vbBlue * Rnd(10000)
Picture1.ForeColor = vbWhite * Rnd(10000)
mNumTray = mNumTray + 1
Picture1.Print CStr(mNumTray)
ImageList1.ListImages.Remove 1
ImageList1.ListImages.Add 1, , Picture1.Image
AddIconToTray (ModifyIcon)
End Sub
Private Sub Form_Load()
mNumTray = 0
Picture1.ScaleMode = vbPixels
Picture1.AutoRedraw = True
Picture1.Width = 1200
Picture1.Height = 1200
Picture1.BackColor = vbBlue
Picture1.ForeColor = vbWhite
Picture1.Font.Size = 52
Picture1.CurrentX = 10
Picture1.CurrentY = 1
Picture1.Print CStr(mNumTray)
ImageList1.ListImages.Add 1, , Picture1.Image
AddIconToTray (AddIcon)
Visible = False
End Sub
Private Sub Form_Terminate()
DeleteIconFromTray
End Sub
Private Sub AddIconToTray(pEvent As Long)
Data.Size = Len(Data)
Data.Handle = hwnd
Data.ID = vbNull
Data.Flags = IconFlag Or TipFlag Or MessageFlag
Data.CallBackMessage = WM_MOUSEMOVE
Data.Icon = ImageList1.ListImages(1).ExtractIcon
Data.Tip = "Dynamic Systray Icon" & vbNullChar
Call Shell_NotifyIcon(pEvent, Data)
End Sub
Private Sub DeleteIconFromTray()
Call Shell_NotifyIcon(DeleteIcon, Data)
End Sub
Private Sub Form_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Dim Message As Long
Message = X / Screen.TwipsPerPixelX
Picture1.BackColor = ImageList1.MaskColor
Select Case Message
Case WM_LBUTTONDBLCLK
Visible = Not Visible
WindowState = Abs(Not Visible)
End Select
End Sub
The app will start minimized, so double click the tray icon to see the Form.
change tray icon by clicking the button, it will generate different number to show, with different background color.
-
Jan 2nd, 2006, 12:39 AM
#5
Re: variable txt in Tray
Very cool. Sorry I have to spread some points out before I can rate you. That is worth a few points. I've saved it as a future sample. Thanks.
-
Jan 2nd, 2006, 12:46 AM
#6
Re: variable txt in Tray
No prob DG
That's common system tray stuff, the only interesting add here is the "ExtractIcon" method of Imagelist, this is one of the few ( if not the only) way to create icons at runtime, and also works when wanting to change the Form icon at runtime.
-
Jan 2nd, 2006, 01:06 AM
#7
Re: variable txt in Tray
You should post that in the CodeBank. I don't recall ever seeing it before.
-
Jan 2nd, 2006, 03:14 AM
#8
Thread Starter
Member
Re: variable txt in Tray
Hi,
thanks for the answers. I will try it!
How can I rate someone ?
greetings
byte
-
Jan 2nd, 2006, 03:42 AM
#9
Re: variable txt in Tray
 Originally Posted by dglienna
You should post that in the CodeBank. I don't recall ever seeing it before.
Ok, posted in the Codebank, with new stuff: Transparent background for Form Icons and Random colored background and text for Tray Icons.
Here is the link: Icons at runtime
-
Jan 2nd, 2006, 07:41 AM
#10
Hyperactive Member
Re: variable txt in Tray
to rate someone, ByteChanger, find the member you wish to rate and then below all the info about that user there is a link called ' Rate this post' click on it and that is how it is done. make sense
-
Jan 2nd, 2006, 07:56 AM
#11
Re: variable txt in Tray
 Originally Posted by dglienna
Very cool. Sorry I have to spread some points out before I can rate you. That is worth a few points. I've saved it as a future sample. Thanks.
Me too and me too. 
If you don't put this in the CodeBank, I will!
In fact, in addition to the code, why don't you put together a sample project on how to use it.
-
Jan 2nd, 2006, 08:15 AM
#12
Re: variable txt in Tray
 Originally Posted by Hack
In fact, in addition to the code, why don't you put together a sample project on how to use it.
I added the code in the CodeBank and a Project is attached to it as a sample (the code in the sample is the same that the code in that post).
-
Jan 2nd, 2006, 08:54 AM
#13
Re: variable txt in Tray
Nice stuff jcis!!
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
|