?
Solved

Minimize to tray - Works under VB but not as .exe

Posted on 2003-02-25
4
Medium Priority
?
442 Views
Last Modified: 2012-06-27
Hi.

I have this program, that when minimized should go to system tray, and on mouse click / dbl click should go back to maximized.

When I run this from VB(i.e. click the 'start' button) it works fine. But after I made the .exe file and run it, the systray icon doesn't respond to the mouse click/dbl click.

I will greatly appreciate any help. This is the code I used ( I got it from http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20310607.html and modified it a bit)

Private Sub MDIForm_Resize()
   If Me.WindowState = vbMinimized And tray Then
       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
       nid.szTip = "Software" & vbNullChar
       Shell_NotifyIcon NIM_ADD, nid
       Visible = False
   End If
End Sub

Private Sub MDIForm_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
   
   If msg = WM_LBUTTONUP Or msg = WM_LBUTTONDBLCLK Then
           WindowState = vbMaximized
           Visible = True
           Shell_NotifyIcon NIM_DELETE, nid
   End If
End Sub

0
Comment
Question by:spyderbilt
[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
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:PNJ
ID: 8016451
Do you need ME.WindowState = vbMaxmized and ME.Visible = True to specify precisely that you mean the form?
0
 

Author Comment

by:spyderbilt
ID: 8022300
hmm. I tried that but it didn't work. even when I put
MsgBox "Mouse clicked"
the msg box doesn't pop up
0
 
LVL 3

Accepted Solution

by:
PNJ earned 120 total points
ID: 8023902
Don't know then. But, I use "TrayIt.ocx" to do this sort of thing: http://axsoft.hypermart.net/products/trayit.htm
(found using Google "trayit.ocx")

I know it doesn't solve the actual problem, but this ocx works just fine for me:

Private Sub TrayIt1_TrayDblClick(ByVal Button As Integer)
     
   Me.Show
   DoEvents
   Me.WindowState = vbMaximized
     
   If Button = 1 Then ' Left mouse
....  
   End If
   
   If Button = 2 Then ' Right mouse
...
   End If

End Sub

HTH.
0
 

Author Comment

by:spyderbilt
ID: 8062331
Thanks. that component works great :)
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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

777 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