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
Printable View
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
Check out this balloon tip sample project by Randy Birch.
Or, a tooltip. I'm not sure how the weather programs display the temperature in the system tray.
Or this..
Add to your Form: 1 imagelist, 1 picturebox, 1 command button
The app will start minimized, so double click the tray icon to see the Form.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
change tray icon by clicking the button, it will generate different number to show, with different background color.
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.
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.
You should post that in the CodeBank. I don't recall ever seeing it before.
Hi,
thanks for the answers. I will try it!
How can I rate someone ?
greetings
byte
Ok, posted in the Codebank, with new stuff: Transparent background for Form Icons and Random colored background and text for Tray Icons.Quote:
Originally Posted by dglienna
Here is the link: Icons at runtime
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
Me too and me too. :thumb:Quote:
Originally Posted by dglienna
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.
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).Quote:
Originally Posted by Hack
Nice stuff jcis!! :thumb: