I'm currently working with the NotifyIcon, and ContextMenus in the notify icon, and was wondering if it is possible to call an event when something is dropped onto the icon. For instance, if I had document.docx, and I dragged it from explorer onto the icon, it would then save it to an online location. I haven't been able to find an event that would be suitable for this.

Any help is appreciated!

What you are describing is "non-trivial"...

Look at the <project> <components> for anything connected with Internet and research them...

Microsoft HTML Object Library
Microsoft Internet Control
Microsift Internet Transfer Control

I haven't done this, so all I can do is point you to where I would start my search. :)

I usually use an FTP app, like the free version of File Zilla...

You can also check out www.Karenware.com and see if she had anything like what you are looking for.

Karen Kenworthy was a very expert VB6 code writer who passed awhile back. But, her folks are keeping the site up as a tribute to her.

All her programs have the source code available...

Υοu'll have to do what is called subclassing in VB6. No vb6 form by default deals with all the Windows Messages generated by the Windows Operating System. VB6 deals with a limited set of Windows Messages in its Main Window: the rest are ignored.

So you add a subclass that allows you the flexibility of dealing with whatever message you want to deal with. To do this you have to use a few WIN32 SDK API's. But the subclass intercepts or hooks the messages being delivered to your vb6.exe's window and allows you to deal with them before, after, or both before and after your vb6 application deals with the message.

You must create what is called the Windows Process in a bas module: not a class module.
The following example picks up the MouseWheel Event Message which is not listed as an event in your VB6 window. The example code picks up a mouse wheel scroll event, tells you which way it's going (negative or positive value) and then lists the current mouse position at the time of the scroll event.

Your VB6 application has its own WindowsProc function which is hidden from the programmer. This function processes the Windows Messages for your VB6 window. But you must write code to insure that your application picks up the Windows Message before VB6. You do this by setting what is called a Hook. The Hook will use the handle of your vb6 application and with a win32 api function intercept the windows messages and force them to go to your subclass function. Use the SetWindowLong API call to do this.

You can also write an Unhook function in your bas module to return the processing of Windows Messages to the normal VB6 Window Process, if you like.

You use the VB6 AddressOf function to obtain the memory address for your own personally created function for the Windows Process. If you're familiar with the C Programming Language, AddressOf just replaces the & symbol. In C the & symbol is used to return the pointer to the memory address of variables, functions, etc. So, it definitely helps to have some experience with C and with the WIN32 Software Development Kit (SDK). You can only use the AddressOf function inside a parameter list in VB6. So when an API requests the memory address to a function, pointer, etc. inside the parameter list area, use the AddressOf function.

You'll have a better understanding of what's going on here, if you'll try writing C code for creating a simple window. You'll understand what is a memory address, what is a Windows Process, and you'll see how Windows Messages are normally handled using straight C programming.

This doesn't deal specifically with your problem of using the TaskBar. But should give you a starting point. You need to add code to use the shell functions that deal with the task bar. You can find information for the C code for this on the web. You'll have to convert these shell functions to publicly declared functions in VB6 and write a function to handle the processing of the taskbar message. I've helped you to start by giving you the values of some of the Notify Icon Flag (NIF) constants you'll most likely need and converted the C NotifyIconData structure to a VB6 Public type.

' Constants for use in the NOTIFYICONDATA Type (uFlags Parameter)
Public Const NIF_ICON = &h1  ' The hIcon member is valid. 
Public Const NIF_MESSAGE = &h2 '	The uCallbackMessage member is valid.
Public Const NIF_TIP = &h4 

    cbSize as long 
    hWnd as long 
    uID as long
    uFlags as long
    uCallbackMessage as long   ' This is your own message ID you specify. This is the value you will check for in your subclass to deal with the event. When you find this value, you must write code to execute what you desire to do at this point.
    hIcon as long
    szTip as string * 64 
End Type 
' GWL_WNDPROC Sets a new address for the window procedure. Used in the SetWindowLong API for the second parameter.
Public Const GWL_WNDPROC = -&H4

Public ghWnd As Long ' Handle for your VB6 application.
Public lpPrevWndProc As Long ' Variable to save original VB6 handle. 

Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
    (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, _
    ByVal wParam As Long, ByVal lParam As Long) As Long

' The SetWindowLong function changes an attribute of the specified window. The
' function also sets a 32-bit (long) value at the specified offset into the extra window
' memory of a window.
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal lhWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

' Change the address attribute for the Window Procedure of the window specified by ghWnd
Public Sub Hook()
    lpPrevWndProc = SetWindowLong(ghWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

' Return processing of Windows Messages to VB6's Window Process.
Public Sub Unhook()
    Dim lngRtrn As Long
    lngRtrn = SetWindowLong(ghWnd, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, _
    ByVal lParam As Long) As Long
    On Error Resume Next
    Dim lngMousPt As Long
    Select Case uMsg
        With frmSC.lstMsg
            .AddItem "Mouse Wheel" & "  Distance: " & ReturnHIWORD(wParam)
            .AddItem "Virtual Keys: " & ReturnLOWORD(wParam)
            .AddItem "Mouse Cordinates: " & ReturnLOWORD(lParam) & ", " & ReturnHIWORD(lParam)
        End With
        WindowProc = 0
    Case Else
        ' Return message information to original VB6 Window Process: process specified by handle lpPrevWndProc. This allows your VB6 Window Process to process the other messages.
        WindowProc = CallWindowProc(lpPrevWndProc, hWnd, uMsg, wParam, lParam)
    End Select
End Function

Oh, by the way. The reason you can't find an event to do this: you have to define your own peculiar event ID in the NOTIFYICONDATA structure (VB6 public type). You set this flag using the MyTaskBarAddIcon shell function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.