Spike
10-07-2001, 08:28 PM
How do i get a pop menu when the user clicks on the icon that i put there?
I just want plain code, i dont want to use an ocx or dll.
Thanks Everyone.
Spike
dcl3500
10-07-2001, 09:23 PM
put the menu on the form that will open when you double-click the icon and then use this function:
Friend Function WindowProc(ByVal sHwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
' This is where we will handle all messages. Handle only messages
' for the Form (Form1)
If sHwnd = Me.hwnd Then
Select Case uMsg
Case WM_MYHOOK
' the lParam of the message holds the message we want
' to handle
Select Case lParam
Case WM_LBUTTONUP
' Left mousebutton was pressed on the icon.
Form1.Show
Case WM_RBUTTONUP
PopupMenu Form1.mnuPopOne
End Select
End Select
End If
' Pass all messages back to the defaul WindowProc
WindowProc = CallWindowProc(mWndProcNext, sHwnd, uMsg, _
wParam, ByVal lParam)
End Function
Just don't ask me to exactly describe how it works. I got the code from someone else (not on this forum) because they were handing me a quick fix when I needed one images/icons/blush.gif.
Don
Time is the best teacher; unfortunately it kills all its students.
Garrett Sever
10-07-2001, 10:27 PM
If that doesn't make sense to you, look at this tutorial (http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=tu&Number=51154&page=0&view=collapsed&sb=5&o=31&part=) that squirm put together. Yes, he talks about compiling the Microsoft project into an OCX project, but that's not necessary. You can actually just put the control and module into your project and compile it into your program directly.
I did exactly that in my forum status project (http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=CodeLib&Number=54564&page=0&view=collapsed&sb=5&o=7&part=).
If you wish to re-invent the wheel, be my guest. Microsoft did a good job with their unsupported but relatively well documented SysTray control, and I would recommend using it. Also remember that this requires a form of subclassing / callback, which will <font color=red>CRASH YOUR VB</font color=red> environment if you don't close down correctly.
Regards,
-<font color=purple>The Hand</font color=purple>
<font color=green>All your code are belong to us...</font color=green> images/icons/tongue.gif
dcl3500
10-07-2001, 10:42 PM
Hand :( once again I have it pointed out to me that I do not spend enough time reading through the code you graciously post. I should have known though that you did something at least similar to what I posted. You have a context sensitive menu in your forum checker. Unfortunately, the first project that came to mind to me was my ill-fated RichCheck utility. If I had been thinking cleary I would have just given him a link to your code.....sorry.
Don
Time is the best teacher; unfortunately it kills all its students.
Spike
10-08-2001, 04:55 PM
Thanks everybody, i got it working.
Spike