Author | Message | Time |
---|---|---|
TeEhEiMaN | Can someone tell me how to minamize to tray by clicking a button for VB. Thanks TeEhEiMaN | May 25, 2003, 2:22 AM |
TriCk | I know how to minimize but i dunno how to make it come back up anyway heres the code for that ... Make a module Called Systray ( or something ) and put this in it Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long 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 NID As NOTIFYICONDATA Private Sub Form_Resize() On Error Resume Next If Me.WindowState = vbMinimized Then Me.Hide With NID .cbSize = Len(NID) .hwnd = frmChat.hwnd .uID = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .uCallbackMessage = WM_MOUSEMOVE .hIcon = frmChat.Icon .szTip = "StealthBot v1.39 Test Edition" & vbNullChar End With Shell_NotifyIcon NIM_ADD, NID Else Shell_NotifyIcon NIM_DELETE, NID End If ' cboSend.SetFocus ' rtbChat.Width = Me.ScaleWidth - lvChannel.Width ' rtbChat.Height = Me.ScaleHeight - cboSend.Height ' txtPre.Height = Me.ScaleHeight - rtbChat.Height ' txtPost.Height = Me.ScaleHeight - rtbChat.Height ' lvChannel.Height = Me.ScaleHeight - lblCurrentChannel.Height - cboSend.Height ' cboSend.Width = Me.ScaleWidth - txtPre.Width - txtPost.Width ' txtPre.Top = rtbChat.Height ' txtPost.Top = rtbChat.Height ' txtPost.Left = cboSend.Width + 700 ' lblCurrentChannel.Left = rtbChat.Width ' lblCurrentChannel.Width = lvChannel.Width ' lvChannel.Left = rtbChat.Width ' cboSend.Top = rtbChat.Height ' txtPost.Left = cboSend.Width + 700 ' txtPre.Width = Me.ScaleWidth - cboSend.Width - txtPost.Width End Sub | May 25, 2003, 2:33 AM |
TriCk | I took that one out of a StealthBot code i had Enjoy ^^ | May 25, 2003, 2:34 AM |
Stealth | It may be important to note that that code ceased to function, for as-yet unknown reasons, after my 1.4 public release. It is discussed here: https://davnit.net/bnet/vL/phpbbs/index.php?board=5;action=display;threadid=334 | May 25, 2003, 6:02 AM |
TriCk | Stealth It worked for me... And TeEhEiMaN | May 25, 2003, 7:36 AM |
timbo | [code]Private Sub Form_Resize() If Me.WindowState = vbMinimized Then Me.Hide End Sub[/code] | May 25, 2003, 2:03 PM |
TeEhEiMaN | its a really bad minamize to tray tho, Its impossible to bring back, Kinda useless, If anyone knows any better ones please post | May 25, 2003, 5:03 PM |
OcTaViuS | [code] 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 Sub Initialise(mee As Form) 'Place in form load With nid .cbSize = Len(nid) .hwnd = mee.hwnd .uId = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .uCallBackMessage = WM_MOUSEMOVE .hIcon = mee.Icon .szTip = " Right Click Mouse Button " & vbNullChar End With Shell_NotifyIcon NIM_ADD, nid mee.Hide App.TaskVisible = False End Sub Sub PopMenu(mee As Form, x As Single) 'Place in form mouse move Dim Msg As Long Msg = x / Screen.TwipsPerPixelX Select Case Msg Case WM_LBUTTONDBLCLK: Case WM_LBUTTONDOWN: Case WM_LBUTTONUP: mee.PopupMenu mee.mnuPopMenu Case WM_RBUTTONDBLCLK: Case WM_RBUTTONDOWN: Case WM_RBUTTONUP: mee.PopupMenu mee.mnuPopMenu End Select End Sub Sub CloseApp() 'Place in form unload Shell_NotifyIcon NIM_DELETE, nid End Sub Sub Down(mee As Form) 'Place in form resize If mee.WindowState = vbMinimized Then mee.Hide End Sub [/code] | May 25, 2003, 7:38 PM |
OcTaViuS | ok, ignore the code i just posted its too confusing lol. i got a method that works, im just trying to reword it so even the biggest newb can understand it. | May 25, 2003, 8:44 PM |
timbo | i was assuming you knew how to up a tasktray icon already... i was just nudging you in a possible direction. you could set the shellnotifyicon in the same if or you could do it at formload. | May 25, 2003, 9:04 PM |
MrRaza | Again, the forum search option will help you alot. This topic has been covered countless times. You all will soon realize how useful msdn, google and the search page are. Also if your blind(or stupid), here's a link: https://davnit.net/bnet/vL/phpbbs/index.php?board=17;action=search | May 25, 2003, 9:24 PM |
OcTaViuS | ok here goes. the biggest newb wont understand but owell. this is what im now using in my bot. first u gotta declare it and shyt. put this in a module. [code] 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 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 [/code] U'll need to create a menu for the popup menu when u right click the tray icon. I named mine 'pop_systray' and added 'connect' 'disconnect' 'maximize' and 'exit' to it for dropdown option thingys. put this in Form_Load() to keep the menu from showing in the menu bar [code] pop_systray.Visible = False [/code] my bot minimizes to the tray when you click 'minimize to tray' (named mnusystray) from the menubar. heres the code for when u click it. [code] Private Sub mnusystray_Click() Me.WindowState = vbMinimized 'minimizes to taskbar Me.Hide 'hides form from taskbar With nid 'settings for system tray .cbSize = Len(nid) .hwnd = Me.hwnd .uId = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .uCallBackMessage = WM_MOUSEMOVE .hIcon = Me.Icon 'use form's icon in tray .szTip = "VeGCHaT Version 1.00 Created By: VeGBoT Products" & vbNullChar 'tooltip text End With Shell_NotifyIcon NIM_ADD, nid 'adds icon to tray End Sub [/code] now u gotta add the code to show the right click popup menu, aswell there is also code to maximize from double clicking the icon. [code] Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim result, Action As Long 'there are two display modes and we need to find out which one the application is using If Me.ScaleMode = vbPixels Then Action = X Else Action = X / Screen.TwipsPerPixelX End If Select Case Action Case WM_LBUTTONDBLCLK 'If The Left Button Double Clicks The Icon... Me.WindowState = vbNormal 'This will put back into taskbar result = SetForegroundWindow(Me.hwnd) Me.Show 'this will maximize the form Shell_NotifyIcon NIM_DELETE, nid 'this will remove the icon from tray Case WM_RBUTTONUP 'If The Right Button Is Clicked... result = SetForegroundWindow(Me.hwnd) PopupMenu pop_systray 'the hidden menu from the menubar becomes your popup menu, cool huh? End Select End Sub [/code] Heres the code if they click 'Exit' (named 'popExit') from the popup menu [code] Private Sub popExit_click() unload me End Sub [/code] And if they click 'Maximize' (named 'popMax')... [code] Private Sub popMax_click() Dim result As Long Me.WindowState = vbNormal result = SetForegroundWindow(Me.hwnd) Me.Show Shell_NotifyIcon NIM_DELETE, nid End Sub [/code] if they click 'Connect' (named 'popConnect')... [code] Private Sub popConnect_click() 'your code to connect the bot End Sub [/code] And if they click 'Disconnect' (named 'popDisconnect')... [code] Private Sub popDisconnect_click() 'your code to disconnect the bot End Sub [/code] Im pretty sure i mentioned everything on how i did it so that code should work. hope it dont sound too confusing ;) | May 25, 2003, 9:43 PM |
OcTaViuS | [quote author=MrRaza link=board=17;threadid=1423;start=0#msg10648 date=1053897856] Again, the forum search option will help you alot. This topic has been covered countless times. You all will soon realize how useful msdn, google and the search page are. Also if your blind(or stupid), here's a link: https://davnit.net/bnet/vL/phpbbs/index.php?board=17;action=search [/quote] msdn is confusing, google takes a long time, and the search doesnt have any (correct) information on this topic. | May 25, 2003, 9:53 PM |
MrRaza | Then your doing it all wrong. | May 25, 2003, 9:58 PM |
Zakath | MSDN is an invaluable resource. You're doing Windows programming - well, MSDN contains the definitions for all the API functions that drive a Windows application, as well as details for every standard function in VB. You say it's too confusing...well, learn to use it. Incidentally, you're incorrect about the search. It's quite easy to find one of several topics where solutions to your exact problem were presented. | May 25, 2003, 10:38 PM |
OcTaViuS | [quote author=Zakath link=board=17;threadid=1423;start=0#msg10661 date=1053902326] Incidentally, you're incorrect about the search. It's quite easy to find one of several topics where solutions to your exact problem were presented. [/quote] almost all topics from search displayed how to get it minimized yes, but the real problem in this thread is how to get it maximized again. and nowhere on these forums can an exact answer on that be found, only suggestions based on a theory. | May 25, 2003, 10:49 PM |
Camel | [quote author=OcTaViuS link=board=17;threadid=1423;start=15#msg10662 date=1053902967] [quote author=Zakath link=board=17;threadid=1423;start=0#msg10661 date=1053902326] Incidentally, you're incorrect about the search. It's quite easy to find one of several topics where solutions to your exact problem were presented. [/quote] almost all topics from search displayed how to get it minimized yes, but the real problem in this thread is how to get it maximized again. and nowhere on these forums can an exact answer on that be found, only suggestions based on a theory. [/quote] [code]Show WindowState = vbMaximized[/code] | May 26, 2003, 4:52 PM |
Zakath | If you don't know how to cause a window that you have a handle for to be displayed, you shouldn't be messing with systray stuff, period. Either use the VB "Show" builtin, or the API function ShowWindow. It's not hard to figure out. | May 26, 2003, 6:38 PM |
OcTaViuS | [quote author=Camel link=board=17;threadid=1423;start=15#msg10762 date=1053967947] [code]Show WindowState = vbMaximized[/code] [/quote] well ya that parts obviose. i meant figuring out how to implement it with the call back message | May 26, 2003, 6:55 PM |
Camel | [quote author=OcTaViuS link=board=17;threadid=1423;start=15#msg10777 date=1053975347] [quote author=Camel link=board=17;threadid=1423;start=15#msg10762 date=1053967947] [code]Show WindowState = vbMaximized[/code] [/quote] well ya that parts obviose. i meant figuring out how to implement it with the call back message [/quote] [code]Sub thecallbackmessage() someform.Show someform.WindowState = vbMaximized End Sub[/code] | May 29, 2003, 3:15 AM |