Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 20, 1997

Menu Status on MDI Forms with Spyworks-VB

Many features of SBCEasy (a tool that comes with Desaware's SpyWorks-VB) work only on its container, and because it cannot be placed on a MDI Parent form, the MenuSelect event does not work on MDI forms. Fortunately, it is quite easy to use SBC.VBX to implement the same functionality.
First, create MDI Parent and MDI Child windows and place a PictureBox control onto the MDI Parent. Place an SBC SubClass control on top of that PictureBox. In the Parent's Load event, set the window to be subclassed:
 SubClass1.HwndParam = MDIForm1.hWnd 
Adjust the SubClass control's Message property to intercept WM_MENUSELECT. Then, in the SubClass control's WndMessage event, get the caption of the selected menu item with this code:
 Sub SubClass1_WndMessage (wnd As Integer, _ 
msg As Integer, wp As Integer, lp As Long, _ 
retval As Long, nodef As Integer) 
Dim id%, di% 
Dim hmenu%, menuflags% 
Dim menustring$ 

dwDWORDto2Integers lp, menuflags%, hmenu% 
id% = wp 
' Ignore bitmaps, popups and system menu for now 
If menuflags And (MF_BITMAP Or MF_POPUP Or _ 
MF_SYSMENU) Then 
Form1.Label1.Caption = "" 
Exit Sub 
End If 
menustring$ = String$(32, 0) 
' Get the string 
di% = GetMenuString(hmenu%, id%, menustring$, _ 
31, MF_BYCOMMAND) 
' Strip off anything past the null termination 
menustring$ = dwGetStringFromLPSTR$(menustring$) 

' This menu string can be used as you wish (for 
' example, to update status bars) 
End Sub 
Dan Appleman
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date