Menu Status on MDI Forms with Spyworks-VB

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 Parentform, the MenuSelect event does not work on MDI forms. Fortunately, itis quite easy to use SBC.VBX to implement the same functionality.
First, create MDI Parent and MDI Child windows and place a PictureBoxcontrol onto the MDI Parent. Place an SBC SubClass control on top of thatPictureBox. 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 theselected 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 
See also  How AI Art Generators Can Save Time and Money for Startups

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist