• Welcome to Valhalla Legends Archive.
 

Pulling a program from tray (Making it re-appear).

Started by LackLuster), August 06, 2005, 11:20 PM

Previous topic - Next topic

LackLuster)

I am implementing this: http://forum.valhallalegends.com/phpbbs/index.php?topic=612.msg4583#msg4583

It goes down, but won't pull back up, I have looked over the code, and have found nothing as to why it would be doing this... Any suggestions?

Lenny

Well if you don't show the code, we can only guess and poke fun at you.

Also, this isn't in the correct forum.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

LackLuster)

Did you click the link...? Uhm, that IS the code, and it IS bot developement (it's for a bot...)... So, would it be rude for me to ask you to please click links before you post...?

Lenny

Ah, so you copy and pasted, I don't think you can call that implementation.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

LackLuster)

It pretty much fit... And I am going to say it is his module, it's not like I am saying "I CODED IT IT'S ALL ORINGAL!"...

Lenny

Since I can't be sure how you're using this code, the only guess I can make is you missed reading the last post in that thread or one of the methods in that post that wasn't enclosed by the code tags.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

LackLuster)


      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

     Global Const NIM_ADD = &H0
     Global Const NIM_MODIFY = &H1
     Global Const NIM_DELETE = &H2
     Global Const WM_MOUSEMOVE = &H200
     Global Const NIF_MESSAGE = &H1
     Global Const NIF_ICON = &H2
     Global Const NIF_TIP = &H4
     Global Const WM_LBUTTONDBLCLK = &H203   'Double-click
     Global Const WM_LBUTTONDOWN = &H201     'Button down
     Global Const WM_LBUTTONUP = &H202       'Button up

     'Right-click constants.
     Global Const WM_RBUTTONDBLCLK = &H206   'Double-click
     Global Const WM_RBUTTONDOWN = &H204     'Button down
     Global Const WM_RBUTTONUP = &H205       'Button up

     Declare Function Shell_NotifyIcon Lib "shell32" _
        Alias "Shell_NotifyIconA" _
        (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
     Global nid As NOTIFYICONDATA

Sub AddToTray(TrayIcon, TrayText As String, TrayForm As Form)
        'Set the individual values of the NOTIFYICONDATA data type.
        nid.cbSize = Len(nid)
        nid.hwnd = TrayForm.hwnd
        nid.uId = vbNull
        nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        nid.uCallBackMessage = WM_MOUSEMOVE
        nid.hIcon = TrayIcon 'You can replace form1.icon with loadpicture=("icon's file name")
        nid.szTip = TrayText & vbNullChar

        'Call the Shell_NotifyIcon function to add the icon to the taskbar
        'status area.
        Shell_NotifyIcon NIM_ADD, nid
        TrayForm.Hide
End Sub

Sub ModifyTray(TrayIcon, TrayText As String, TrayForm As Form)
        nid.cbSize = Len(nid)
        nid.hwnd = TrayForm.hwnd
        nid.uId = vbNull
        nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        nid.uCallBackMessage = WM_MOUSEMOVE
        nid.hIcon = TrayIcon
        nid.szTip = TrayText & vbNullChar
        Shell_NotifyIcon NIM_MODIFY, nid
End Sub

Sub RemoveFromTray()
Shell_NotifyIcon NIM_DELETE, nid
End Sub

Function RespondToTray(X As Single)
         RespondToTray = 0
         Dim msg As Long
         Dim sFilter As String
         If Form1.ScaleMode <> 3 Then msg = X / Screen.TwipsPerPixelX Else: msg = X
         Select Case msg
            Case WM_LBUTTONDOWN
            Call ShowFormAgain
            Case WM_LBUTTONUP
            Call ShowFormAgain
            Case WM_LBUTTONDBLCLK 'Left button double-clicked
            Call ShowFormAgain
            RespondToTray = 1
            Case WM_RBUTTONDOWN 'Right button pressed
            RespondToTray = 2
            Case WM_RBUTTONUP
            Case WM_RBUTTONDBLCLK
         End Select
End Function

     Sub ShowFormAgain(TrayForm As Form)
     Call RemoveFromTray
     frmMain.Show
     End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If RespondToTray(X) <> 0 Then Call ShowFormAgain(Me)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call RemoveFromTray
End Sub


That is all in a module... Also, I have it initializing (Going to tray) if you click a menu button "Hide"...

Lenny

From what I can remember of VB, I believe you want this:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If RespondToTray(X) <> 0 Then Call ShowFormAgain(Me)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call RemoveFromTray
End Sub

in the form which you want to send to the tray.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Networks

I have had huge problems with the seemingly popular way people do tray support. I use a subclassed version, one open source class I believe can be found in q Bot or something to that affect. And I've found this method to work better and 100% of the time for me and it's the only method I use. Here's where you can find the class:

http://www.zeroforce.net/pafiledb/pafiledb.php?action=file&id=182

Kp

FYI, your NOTIFYICONDATA structure is both misnamed and incomplete. :)  Its proper names are NOTIFYICONDATAA and NOTIFYICONDATAW, depending on whether you're using the old ANSI version or the new Unicode version.  Also, you're missing quite a few new members, which means you won't be able to take advantage of many of the new features introduced in Win2k and WinXP.  A more complete definition, taken from the w32api component of the MinGW project:

typedef struct _NOTIFYICONDATAW {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
#if _WIN32_IE >= 0x0500
WCHAR szTip[128];
DWORD dwState;
DWORD dwStateMask;
WCHAR szInfo[256];
_ANONYMOUS_UNION union {
UINT uTimeout;
UINT uVersion;
} DUMMYUNIONNAME;
WCHAR szInfoTitle[64];
DWORD dwInfoFlags;
#else
WCHAR szTip[64];
#endif
#if _WIN32_IE >= 0x600
GUID guidItem;
#endif
} NOTIFYICONDATAW,*PNOTIFYICONDATAW;
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Mystical

I Just just MicroSofts systray control... :|

simple n easy..

QwertyMonster

I use that too. And then you use it like this:

Private Sub Hide_Click()
sysTray1.InTray = True
frmMain.Hide
End Sub


And then when i want it back


Private Sub sysTray1_MouseDown()
sysTray1.InTray = False
frmMain.Show
End Sub


That is how i do it..