We should be able to minimize DarkClerk in system tray.
This is on my list to look at doing. In VB6 it isn't the easiest thing to do as you need to disable all toolbar controls on all forms to minimise and restore a program from the system tray. As every form has a toolbar in Grimoire/DarkClerk, disabling them is not as easy as it sounds.
Well, i understand. just had a thought and thought of sharing it with you.
And all thoughts for improvement are welcome.
My answer was not meant to be a dismissal of the idea. I am going to be looking into it but it may not be quickly done to the practicalities involved.
This is the VB .Net code i used in some programs to accomplish this:
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
'NotifyIcon1
'
Me.NotifyIcon1.Icon = CType(resources.GetObject("NotifyIcon1.Icon"), System.Drawing.Icon)
Me.NotifyIcon1.Text = "?˜??•=- BanBot Client -=•??˜?"
Me.NotifyIcon1.Visible = True
'
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
If Me.WindowState = FormWindowState.Minimized Then
Me.ShowInTaskbar = False
End If
End Sub
Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Maximized
End Sub
I saw you used VB6 instead, so it will not be completely the same, but it may be handy anyways :)
Hey CrazyGuy,
The code for it in VB is different to this and is actually a pain in the backside as you need to make Windows API calls to do it. I will keep a copy of your .NET though for any project I do in that language ;)
The VB is along these lines;
'user defined type required by Shell_NotifyIcon API call
Public 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
'constants required by Shell_NotifyIcon API call:
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click
Public Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public nid As NOTIFYICONDATA
Private Sub mUpdateSysTrayIcon(Optional Reset As Boolean, Optional Icon)
If Reset Then
If nid.hIcon <> 0 Then Shell_NotifyIcon NIM_DELETE, nid
Else
With nid
.cbSize = Len(nid)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Icon
.szTip = "Calculator" & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
End If
End Sub
Private Sub mPopRestore_Click()
'called when the user clicks the popup menu Restore command
Dim Result As Long
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
End Sub
Yea the VB6 code looks a bit more complicated because of the WinAPI.
Thank god for .Net ;) ;D