this is very hard to do...

you have to capture your icon's position... that's a given.

you need to determine which edge of the screen the taskbar is docked to.

You need to handle the auto-hide case.

you need to handle the message broadcast by explorer.exe when it restarts (after a crash or explorer is term'ed and restarted.) because your icon will move.

You can see that many ISVs opt to just slide in the form from an edge (think FW notifications and AV products).  If your tray icon is also on the form, the user gets the association.

[Note: I made an app that allowed you to drag and drop tray icons into subrtrays to eliminate clutter and annoying "hyperactive" icons (that blink incessantly).  the subtrays would reveal themselves when you hovered over their "dot" on the taskbar.]