Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Minimizing a Program

Posted on 1999-07-05
1
Medium Priority
?
245 Views
Last Modified: 2010-05-02
How can I Minimize a program like whatch, Viruscan and other programs do on the right botton of the conner ?

0
Comment
Question by:mvianna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Smout earned 200 total points
ID: 1521976
Make a new project. To the form add a picture box, a
              menu and a timer. Change it's Interval property to 100.

              Code:
              Add this code to the form's General Declarations
              procedure:

              Option Explicit

              Private 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

              Private Const NIM_ADD = &H0
              Private Const NIM_MODIFY = &H1
              Private Const NIM_DELETE = &H2
              Private Const WM_MOUSEMOVE = &H200
              Private Const NIF_MESSAGE = &H1
              Private Const NIF_ICON = &H2
              Private Const NIF_TIP = &H4

              Private Declare Function Shell_NotifyIcon Lib "shell32"
              Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid
              As NOTIFYICONDATA) As Boolean
              Dim t As NOTIFYICONDATA

              Add this code to the form's QueryUnload procedure:

              Private Sub Form_QueryUnload(Cancel As Integer,
              UnloadMode As Integer)
              Timer1.Enabled = False
              t.cbSize = Len(t)
              t.hWnd = Picture1.hWnd
              t.uId = 1&
              Shell_NotifyIcon NIM_DELETE, t
              End Sub

              Add this code to the picture box's MouseMove procedure:

              Private Sub Picture1_MouseMove(Button As Integer, Shift
              As Integer, X As Single, Y As Single)
              If Hex(X) = "1E3C" Then
              Me.PopupMenu menu1
              End If
              End Sub

              Add this code to the timer:

              Private Sub Timer1_Timer()
              Static i As Long, img As Long
              t.cbSize = Len(t)
              t.hWnd = Picture1.hWnd
              t.uId = 1&
              t.uFlags = NIF_ICON
              t.hIcon = Picture1.Picture
              Shell_NotifyIcon NIM_MODIFY, t
              Timer1.Enabled = True
              i = i + 1
              If i = 2 Then i = 0
              End Sub

              Add this code to the form's load procedure:

              Private Sub Form_Load()
              t.cbSize = Len(t)
              t.hWnd = Picture1.hWnd
              t.uId = 1&
              t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
              t.ucallbackMessage = WM_MOUSEMOVE
              t.hIcon = Picture1.Picture
              t.szTip = "System Tray" & Chr$(0)
              Shell_NotifyIcon NIM_ADD, t
              Timer1.Enabled = True
              Me.Hide
              App.TaskVisible = False
              End Sub
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question