|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB crash on .PopupMenu .zmnuDemo DefaultmenuI have used the following code to create an icon in the systray and have a popupmenu underneath the icon. Now I want to have the defaultmenu item in Bold but if I add the next line the whole thing crashes: ..PopupMenu .zmnuDemo,,,,mFile(9) Any ideas? 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 Select Case hWnd 'form-specific handler Case Main.hWnd Select Case uMsg 'WM_MYHOOK was defined as 'the .uCallbackMessage 'message of NOTIFYICONDATA Case WM_MYHOOK 'maintain focus on the app 'window to assure the menu 'disappears should the mouse 'be clicked outside the menu 'volgende uitgeschakeld is niet nodig!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'Call SetForegroundWindow(Main.hWnd) 'lParam is the value of the message 'that generated the tray notification. Select Case lParam Case WM_RBUTTONUP: 'show the menu With Main .PopupMenu .zmnuDemo End With End Select 'handle any other form messages by 'passing to the default message proc Case Else WindowProc = CallWindowProc(defWindowProc, _ hWnd, _ uMsg, _ wParam, _ lParam) Exit Function End Select 'this takes care of messages when the 'handle specified is not that of the form Case Else WindowProc = CallWindowProc(defWindowProc, _ hWnd, _ uMsg, _ wParam, _ lParam) End Select End Function Regards Marco The Netherlands <vonclausow***@gmail.com> wrote in message
news:1138547628.845328.242590@g49g2000cwa.googlegroups.com... What you're doing there is halting all message processing for the subclassed > Case WM_RBUTTONUP: > > 'show the menu > With Main > .PopupMenu .zmnuDemo > End With > > End Select window. You might want to try dropping a timer on 'Main' and use this instead.... > Case WM_RBUTTONUP: .Timer1.Interval = 1> > 'show the menu > With Main .Timer1.Enabled = True End With 'In the timer routine.... Private Sub Timer1_Timer() Timer1.Enabled = False With Main .PopupMenu .zmnuDemo End With End Sub -- Ken Halter - MS-MVP-VB - Please keep all discussions in the groups.. DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm Ken,
The problem is this line: ..PopupMenu .zmnuDemo,,,,mFile(9) to be more specific the last part: ,,,,mFile(9) with that it crashes, without it works. Why does it do that? I must be able to set a defaultItem in bold, aint I? Marco <vonclausow***@gmail.com> wrote in message
news:1138643140.246443.289890@f14g2000cwb.googlegroups.com... It "should" work. I still think it's quite a bit risky to use modal behavior > Ken, > > The problem is this line: > .PopupMenu .zmnuDemo,,,,mFile(9) > > to be more specific the last part: ,,,,mFile(9) > with that it crashes, without it works. Why does it do that? > I must be able to set a defaultItem in bold, aint I? > > Marco (popup menu is modal) in a message handler. Just for kicks, try the timer method. It should work "better" for a couple of reasons. First of all (and most importantly), it allows the messages to keep flowing through your message handler and secondly, the code is where it belongs... in the main form. The last reason to try it is.... it'll only take a minute <g> -- Ken Halter - MS-MVP-VB - Please keep all discussions in the groups.. DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm You mean getting rit of this whole function:
Public Function WindowProc? and use the timer instead? Marco
Why sending email programmatically must be so complicated?
VB 2005 Express..NOT OT...really! File Copy Without Win Buffering Stumped -- trying to update a VBA subroutine for VB.net VB6---.NET Passing data from a dll to the main VB program cRegistry problems read/writing to (Default) Help - What is the best approach? Short file names VBA stealing keys from ActiveX control? |
|||||||||||||||||||||||