|
-
Jul 11th, 2000, 12:28 PM
#1
Thread Starter
Addicted Member
minimize to the systray
How can I minimize a Form to the systemtray by
clicking on a command button ?
[Edited by Kars Lensen on 07-11-2000 at 01:36 PM]
-
Jul 11th, 2000, 12:41 PM
#2
_______
<?>
See..the post above you..re: system icon bla bla
Change the mouse event to this..
you could put it into a cmdButton as well but
you need all except for the popup menu junk
and the msgbox...I'm sure you get the drift
Code:
minimze by clicking the icon in the system tray.
Private Sub picSysTray_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
'You can use the Hex of the X coord to findout if
'there was any MouseButton activity
'2D represents a Left Button Double Click
'0F represents mouse down (zero)
'1E represents mouse up
If Right(Hex(x), 2) = "0F" Then
'System tray Icon Double Clicked
'If the Window is Minimized, Restore it,
'Else Minimize it.
WindowState = IIf(WindowState = vbNormal, vbMinimized, vbNormal)
Text1.SetFocus
End If
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 11th, 2000, 12:53 PM
#3
_______
<?>
here is the complete thing..sorry the boss was coming
around the corner so I rushed my last post...
Code:
Option Explicit
' Constants required by Shell_NotifyIcon API call
Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4
Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDOWN = &H201 'Button down
Private Const WM_LBUTTONUP = &H202 'Button up
Private Const WM_LBUTTONDBLCLK = &H203 'Double-click
Private Const WM_RBUTTONDOWN = &H204 'Button down
Private Const WM_RBUTTONUP = &H205 'Button up
Private Const WM_RBUTTONDBLCLK = &H206 'Double-click
'API call
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
'variable declaration
Private nid As NOTIFYICONDATA
'Show form icon in system tray
' User defined type required by Shell_NotifyIcon API call
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 Sub Form_Load()
Me.Show
Me.Refresh
With nid
.cbSize = Len(nid)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
.szTip = App.ProductName & " " & App.Major & "." & App.Minor & ", Build " & App.Revision & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'You can use the Hex of the X coord to findout if
'there was any MouseButton activity
'2D represents a Left Button Double Click
'0F represents mouse down (zero)
'1E represents mouse up
If Right(Hex(X), 2) = "0F" Then
'System tray Icon Double Clicked
'If the Window is Minimized, Restore it,
'Else Minimize it.
WindowState = IIf(WindowState = vbNormal, vbMinimized, vbNormal)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Remove Icon from System Tray
'if you use another unload put this there as well
Shell_NotifyIcon NIM_DELETE, nid
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 11th, 2000, 01:03 PM
#4
Thread Starter
Addicted Member
Re: <?>
Thanks, but how do i this with me commandbutton ?
-
Jul 11th, 2000, 04:49 PM
#5
transcendental analytic
You can not minimize anything to system tray, if you say minimize it will probably go under the taskbar, in your command button, put
Code:
yourform.windowstate=vbminimized
where yourform is your forms name
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 11th, 2000, 11:09 PM
#6
Thread Starter
Addicted Member
Originally posted by kedaman
You can not minimize anything to system tray, if you say minimize it will probably go under the taskbar, in your command button, put
Code:
yourform.windowstate=vbminimized
where yourform is your forms name
Thanks Kedeman, thats what I want.. (of course, it would be nice if it was just a small icon in the system tray but I am satisfied this far)
-
Jul 12th, 2000, 12:45 PM
#7
Thread Starter
Addicted Member
THANKS to ALL of you !! It works fine now.
-
Jul 20th, 2000, 03:04 PM
#8
New Member
i do the samething. that the code i put.
Private Sub Form_Resize()
If Me.WindowState = vbMinimized Then
Me.Visible = False
End If
End Sub
and when i click on my icontray
Private Sub Tray1_DblClick(ByVal Button As Long)
Me.Visible = True
End Sub
But the problem is when i dblClik on the icon my form appear like 1 sec in the windowsBar and dessapear after...I cant see my form.
What is the problem?
Sorry for my english.
-
Jul 20th, 2000, 04:33 PM
#9
Member
Im not exactly sure what's happening but I think something similar has happened to me before. If you double click, I think your form gains focus and then loses focus again to the icon. That's what I've been assuming but I really don't know how to fix it. Try, adding me.setfocus in the tray doubleclick event.
-
Jul 21st, 2000, 01:03 AM
#10
New Member
Originally posted by Jimlin41
Im not exactly sure what's happening but I think something similar has happened to me before. If you double click, I think your form gains focus and then loses focus again to the icon. That's what I've been assuming but I really don't know how to fix it. Try, adding me.socus in the tray doubleclick event.
Ok, i gonna try something else. if i found the answer i come back to post it. thanks
-
Feb 2nd, 2002, 08:30 PM
#11
Hyperactive Member
dear mags,
simple question simple answer ...
When you maximize the form, it also runs the resize code ...
Maximazing is also a way of resizing !!!
____________________________________________
Please rate my messages. Thank you!
____________________________________________
Bram Vandenbon
http://www.bramvandenbon.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|