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
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.
Related Posts
- HPE Announces General Availability for Haven OnDemand Machine Learning Platform
- Tip: Count the Number of Active ASP.NET Sessions
- Jon Sebastiani’s Journey: From Winemaking to Snack Innovator
- Expanded Perforce Consulting Services Help Customers Boost Security, Raise Development Efficiency and Adopt DevOps
- Report: Amazon Has 28% of the Cloud Computing Market























