Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-02-25
4
Medium Priority
?
445 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
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

578 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