I was wondering how to make a screen mate by using simple vb code and it can able to minimize to the tray icon.
is it possible to do it in vb ?how?can anybody show me the code...?
Printable View
I was wondering how to make a screen mate by using simple vb code and it can able to minimize to the tray icon.
is it possible to do it in vb ?how?can anybody show me the code...?
you could try experimenting with ms agent, or even create your own agent, with their character creation kit thingy
Here's how you make it minimize to the tray.
Create a form (not your main form), call it frmTray.
Change its Icon property to the icon you want in the tray.
Change its Caption property to the ToolTip of the icon in the tray (the text which appears when you put the mouse cursor over the icon and wait a bit).
IMPORTANT ALERT TO PREVENT SITTING FRUSTRATED AT 3 A.M. ASKING YOURSELF IT IS NOT WORKING:
Set the form's ScaleMode to 3 - Pixel. :rolleyes:
Add a single menu to the form. Just one. Call it mnuTray. Add whatever submenus you want but this should be the only menu at 1st level.
Add this code:
Also, add code to the menu items like you normally would.Code:Option Explicit
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4
Private Const NIM_ADD = &H0
Private Const NIM_DELETE = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONUP = &H202
Private Const WM_RBUTTONUP = &H205
Private 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
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Dim NID As NOTIFYICONDATA
Private Sub Form_Load()
With NID
.cbSize = Len(NID)
.hWnd = hWnd
.uID = 1
.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Icon.Handle
.szTip = Right(Caption, 63) & vbNullChar
End With
Call Shell_NotifyIcon(NIM_ADD, NID)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case X
Case WM_MOUSEMOVE
' The mouse moved over the tray icon!
Case WM_LBUTTONUP
' The tray icon has been left-clicked!
Case WM_RBUTTONUP
' The tray icon has been right-clicked!
' Show the menu:
Call PopupMenu(mnuTray)
End Select
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call Shell_NotifyIcon(NIM_DELETE, NID)
End Sub
Now, the main form:
So the form frmTray isn't really used as a form, but as an object which lets you create a tray icon.Code:Private Sub Form_Load()
Call Load(frmTray)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call Unload(frmTray)
End Sub
Hope this works for you! :)
It can be done in Vb. They are called Sprites. And here are a few samples from http://www.planet-source-code.com on how to use them.
yonatan,
then how about to make the "screen mate"?
i can only make the image randomly move by up side down
by form load,
how can i do further more about animation and
i want it to run the same like the screen mate like.
you can catch it by dragging and close it by double click.
lastly iwant to know how can i do without the form?
i don't need the form and the image is inside the form.
i wanna make only the stand alone image move around in the windows.
how can i do it?
[Edited by Satangel on 08-30-2000 at 12:52 AM]
make the form full screen, then find some code to make it go invisible