|
-
May 23rd, 2013, 07:23 PM
#1
Thread Starter
Lively Member
[RESOLVED] selecting a menu item with 1 click rather than 2
I have two forms form1 and form 2.
form2 has a menu strip with an item -- tools and a subitem item1
form1 is loaded first and in form1.load form2 is shown
now select form 1 by clicking on it.
now form1 has the focus and form2 does not.
move the mouse over the form2 menu item tools and click on it. -- nothing happens except form 2 now has the focus. now click
again on tools and the dropdown appears.
is this the way it is supposed to work. no other windows application seems to work in this way. for example open two
notepads. then clicking on an item of one of them regardless of whether it has the focus will display the dropdown.
hopefully there is something I can do to overcome this awkward and not very useful behavior
thanks,
follys
-
May 23rd, 2013, 07:38 PM
#2
Re: selecting a menu item with 1 click rather than 2
is this the way it is supposed to work.
Nope. Which is why it doesn't. I'm completely unable to replicate the problem as you state it. As you haven't supplied us with any code I've no idea what but there is clearly something about your program which overrides the normal behaviour.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 23rd, 2013, 07:52 PM
#3
Thread Starter
Lively Member
Re: selecting a menu item with 1 click rather than 2
I have used vb.net to create form1 and form 2.
in form2 I have from the toolbox selected menustrip
in the menustrip I have the main item of tools.
a subitem of item1.
and that's all there is!
follys
-
May 23rd, 2013, 08:14 PM
#4
Re: selecting a menu item with 1 click rather than 2
 Originally Posted by follys
I have two forms form1 and form 2.
Actually that seems to be the normal behavior for the menu strip control, at least thats what I'm seeing here using menu strips.
Now if I use the "MainMenu" control on both forms instead then it works (and looks) just the way notepads work and the menu opens even when the form doesn't have focus as you want.
-
May 23rd, 2013, 08:39 PM
#5
Re: selecting a menu item with 1 click rather than 2
 Originally Posted by follys
no other windows application seems to work in this way.
That's a big call. How many other Windows applications did you test? Just Notepad? I just tested Outlook 2013 and it doesn't respond to clicks on ribbon tabs or items if the window doesn't have focus.
-
May 24th, 2013, 07:07 AM
#6
Addicted Member
Re: selecting a menu item with 1 click rather than 2
follys i understand your question. I asked the same question for a toolstrip in this tread. Scroll down to the bottom to find the code for the toolstrip and perhaps it can be modified for a menustrip.
Edit.. yes the code can be modified to work with the MenuStrip.
vb.net Code:
Public Class MenuStripEx
Inherits MenuStrip
Public Sub New()
MyBase.New()
End Sub
Private m_clickThrough As Boolean = False
''' <summary>
''' Gets or sets whether the MenuStripEx honors item clicks when its containing form does
''' not have input focus.
''' </summary>
''' <remarks>
''' Default value is false, which is the same behavior provided by the base MenuStrip class.
''' </remarks>
Public Property ClickThrough() As Boolean
Get
Return Me.m_clickThrough
End Get
Set(value As Boolean)
Me.m_clickThrough = value
End Set
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
If Me.m_clickThrough AndAlso m.Msg = NativeConstants.WM_MOUSEACTIVATE AndAlso m.Result = CType(NativeConstants.MA_ACTIVATEANDEAT, IntPtr) Then
m.Result = CType(NativeConstants.MA_ACTIVATE, IntPtr)
End If
End Sub
End Class
Friend NotInheritable Class NativeConstants
Private Sub New()
End Sub
Friend Const WM_MOUSEACTIVATE As UInteger = &H21
Friend Const MA_ACTIVATE As UInteger = 1
Friend Const MA_ACTIVATEANDEAT As UInteger = 2
Friend Const MA_NOACTIVATE As UInteger = 3
Friend Const MA_NOACTIVATEANDEAT As UInteger = 4
End Class
Last edited by OICU812; May 24th, 2013 at 07:24 AM.
-
May 24th, 2013, 07:57 AM
#7
Thread Starter
Lively Member
Re: selecting a menu item with 1 click rather than 2
I don't see "mainMenu" control in my toolbox. how do u get it?
-
May 24th, 2013, 08:34 AM
#8
Thread Starter
Lively Member
Re: selecting a menu item with 1 click rather than 2
thank you. I have added mainmenu control to toolbox by selecting "choose items" from right clicking the toolbox. and it works just like you said.
the menu strip that Microsoft replaced mainmenu by has that little feature that is really unwelcome.
again thank you very much.
follys
-
May 24th, 2013, 08:40 AM
#9
Thread Starter
Lively Member
Re: selecting a menu item with 1 click rather than 2
I have since ur comment looked at pdf, windows explorer, gmail, windows live mail, and infact visual studio itself. none seem to have this rather awkward feature of requiring the forms' focus before allowing the menu item to be selected. as you point out it is probably not a general feature of the menu control that apps incorporate. but I think that any app that has the sluggish behavior has probably been built with the vb menustrip. I think somebody should fix this.
follys
-
May 24th, 2013, 09:20 AM
#10
Re: selecting a menu item with 1 click rather than 2
 Originally Posted by follys
I think that any app that has the sluggish behavior has probably been built with the vb menustrip.
Office is not a .NET app and uses a ribbon, so there goes that idea.
-
May 24th, 2013, 10:52 AM
#11
Re: selecting a menu item with 1 click rather than 2
 Originally Posted by OICU812
Edit.. yes the code can be modified to work with the MenuStrip.
Nice one! 
That menu behavior was one of the first things I noticed when switching from VB6 to VB10(net) and I didn't like it either, but if I nitpick at everything I don't like about Windows and .Net I'd never use em.
-
May 24th, 2013, 11:45 AM
#12
Re: [RESOLVED] selecting a menu item with 1 click rather than 2
My guess is that some people considered preferable to make it easy to click and application to give it focus without activating some function of that application. By menus and tool bars not activating on a click when the app doesn't have focus, it means that you don;t have to be careful where you click to activate the app. I don't think that you say that either approach is right or wrong and which is better is a matter of preference but I reckon that that's the thinking behind it.
-
May 24th, 2013, 01:25 PM
#13
Thread Starter
Lively Member
Re: [RESOLVED] selecting a menu item with 1 click rather than 2
makes sense but not consistent. since if you have buttons on the form if you hit the button without giving the form the focus the button runs the event.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|