How does VB6 write application icons in a tray?

Source: Internet
Author: User

1. Create a VB6 project and set the ShowInTaskBar attribute of Form1 to False.
2. Menu: Project-add module press "open" to add a new module named Module1 and save it as Module1.bas
3. Write the following code in Module1:
Option Explicit
Public Const MAX_TOOLTIP As Integer = 64
Public Const NIF_ICON = & H2
Public Const NIF_MESSAGE = & H1
Public Const NIF_TIP = & H4
Public Const NIM_ADD = & H0
Public Const NIM_DELETE = & H2
Public Const WM_MOUSEMOVE = & H200
Public Const WM_LBUTTONDOWN = & H201
Public Const WM_LBUTTONUP = & H202
Public Const WM_LBUTTONDBLCLK = & H203
Public Const WM_RBUTTONDOWN = & H204
Public Const WM_RBUTTONUP = & H205
Public Const WM_RBUTTONDBLCLK = & H206
Public Const SW_RESTORE = 9
Public Const SW_HIDE = 0
Public nfIconData As policyicondata
Public Type policyicondata
CbSize As Long
HWnd As Long
UID As Long
UFlags As Long
UCallbackMessage As Long
HIcon As Long
SzTip As String * MAX_TOOLTIP
End Type
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function shell_policyicon Lib "shell32.dll" Alias "shell_policyicona" (ByVal dwMessage As Long, lpData As policyicondata) As Long
4. Write the following code in the Load event of Form1:
Private Sub Form_Load ()
'Put the program in System Tray ======================================== === System Tray Begin
With nfIconData
. HWnd = Me. hWnd
. UID = Me. Icon
. UFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
. UCallbackMessage = WM_MOUSEMOVE
. HIcon = Me. Icon. Handle
'Defines the Tip displayed when you move the cursor over the tray.
. SzTip = App. Title + "(version" & App. Major & "." & App. Minor & "." & App. Revision & ")" & vbNullChar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.