|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
HelpCursor on ToolStripMenuItemI need to enable context sensitive help in my application. For this when user clicks on a menu item( "Whatis this"), i would change the cursor to a help cursor. I used system.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Help As this code did not help in changing the cursor, i modified the code to Me.Cursor = System.Windows.Forms.Cursors.Help This code indeed worked. But when i move the cursor over a item in the menu, it changes back to the default cursor. Can someone tell me a way by which the cursor would remain as a help cursor irrespective of the item the cursor hovers over. Thanks, Sugan Has no one had come across this issue? Can someone write about the work
around for this issue. Is there no one who has a resolution to this problem. I'm trying to
keep replying to this topic, to keep it in the top of the list Can someone come up with the work around for this problem. I'm not
getting reply from any of the forums in this regard. Is it such a big deal to resolve this problem. Thanks, Sugan
Show quote
Hide quote
On 7 Jun 2006 00:06:03 -0700, "Sugan" <vsu***@gmail.com> wrote: ToolStripMenuItems do not have a Cursor Property, therefore, the>Hi all, > >I need to enable context sensitive help in my application. For this >when user clicks on a menu item( "Whatis this"), i would change the >cursor to a help cursor. > >I used > >system.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Help > >As this code did not help in changing the cursor, i modified the code >to > >Me.Cursor = System.Windows.Forms.Cursors.Help > >This code indeed worked. But when i move the cursor over a item in the >menu, it changes back to the default cursor. > >Can someone tell me a way by which the cursor would remain as a help >cursor irrespective of the item the cursor hovers over. > >Thanks, > >Sugan Form's current cursor has no meaning when the mouse is over a DropDownItem. It's not exactly clear what you want to accomplish. Here is an example of using API to toggle the system cursor to CUR_HAND when the mouse enters any of the DropDownItem in a TopLevelMenu named FileMenu and back to the default cursor (NORMAL) when the mouse leaves the DropDownItems. There are two versions of the help cursor which you can use in place of CUR_HAND: Private Const OCR_NORMAL As Int32 = 32512 Private Const CUR_BUSY As Int32 = 21 Private Const CUR_HELP1 As Int32 = 39 Private Const CUR_HELP2 As Int32 = 41 Private Const CUR_HAND As Int32 = 45 Private Declare Function SetSystemCursor Lib "user32.dll" _ (ByVal hcur As Int32, ByVal id As Int32) As Int32 Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Load With Me.FileMenu If .HasDropDownItems Then Dim i As Integer For i = 0 To .DropDownItems.Count - 1 AddHandler .DropDownItems(i) _ .MouseEnter, AddressOf Me.ShowMenuCursor AddHandler .DropDownItems(i) _ .MouseLeave, AddressOf Me.ShowMenuCursor Next End If End With End Sub Private Sub ShowMenuCursor(ByVal sender As Object, _ ByVal e As System.EventArgs) SetSystemCursor(CUR_HAND, OCR_NORMAL) End Sub Gene Hello gene,
Thanks for the help. My aim is to provide a context dependent help. So when the user clicks on "What is this" menu item, i change the cursor to a help cursor. Your code in deed worked in this regard. I'm converting a VB 6 project to VB 2005. This worked perfectly with VB 6 where i used Screen.MousePointer = vbArrowQuestion to convert the pointer to a help pointer. When the user clicks on any other menu item, i check for (cursor = cursors.help) to see whether the user is looking for help or the user is looking for the the functionality of the particular item. This code fails to identify the help cursor which is set as per your code. Why does this happen?? Thanks, Sugan gene kelley wrote: Show quoteHide quote > On 7 Jun 2006 00:06:03 -0700, "Sugan" <vsu***@gmail.com> wrote: > > >Hi all, > > > >I need to enable context sensitive help in my application. For this > >when user clicks on a menu item( "Whatis this"), i would change the > >cursor to a help cursor. > > > >I used > > > >system.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Help > > > >As this code did not help in changing the cursor, i modified the code > >to > > > >Me.Cursor = System.Windows.Forms.Cursors.Help > > > >This code indeed worked. But when i move the cursor over a item in the > >menu, it changes back to the default cursor. > > > >Can someone tell me a way by which the cursor would remain as a help > >cursor irrespective of the item the cursor hovers over. > > > >Thanks, > > > >Sugan > > ToolStripMenuItems do not have a Cursor Property, therefore, the > Form's current cursor has no meaning when the mouse is over a > DropDownItem. > > It's not exactly clear what you want to accomplish. > Here is an example of using API to toggle the system cursor to > CUR_HAND when the mouse enters any of the DropDownItem in a > TopLevelMenu named FileMenu and back to the default cursor (NORMAL) > when the mouse leaves the DropDownItems. > > There are two versions of the help cursor which you can use in place > of CUR_HAND: > > Private Const OCR_NORMAL As Int32 = 32512 > Private Const CUR_BUSY As Int32 = 21 > Private Const CUR_HELP1 As Int32 = 39 > Private Const CUR_HELP2 As Int32 = 41 > Private Const CUR_HAND As Int32 = 45 > > Private Declare Function SetSystemCursor Lib "user32.dll" _ > (ByVal hcur As Int32, ByVal id As Int32) As Int32 > > Private Sub Form1_Load(ByVal sender As Object, _ > ByVal e As System.EventArgs) Handles Me.Load > With Me.FileMenu > If .HasDropDownItems Then > Dim i As Integer > For i = 0 To .DropDownItems.Count - 1 > AddHandler .DropDownItems(i) _ > .MouseEnter, AddressOf Me.ShowMenuCursor > AddHandler .DropDownItems(i) _ > .MouseLeave, AddressOf Me.ShowMenuCursor > Next > > End If > End With > End Sub > > Private Sub ShowMenuCursor(ByVal sender As Object, _ > ByVal e As System.EventArgs) > SetSystemCursor(CUR_HAND, OCR_NORMAL) > End Sub > > Gene
Show quote
Hide quote
On 13 Jun 2006 04:54:36 -0700, "Sugan" <vsu***@gmail.com> wrote: I still do not understand exactly what you are trying to accomplish.>Hello gene, > >Thanks for the help. >My aim is to provide a context dependent help. So when the user clicks >on "What is this" menu item, i change the cursor to a help cursor. Your >code in deed worked in this regard. > >I'm converting a VB 6 project to VB 2005. This worked perfectly with VB >6 where i used Screen.MousePointer = vbArrowQuestion to convert the >pointer to a help pointer. > >When the user clicks on any other menu item, > >i check for (cursor = cursors.help) to see whether the user is looking >for help or the user is looking for the the functionality of the >particular item. This code fails to identify the help cursor which is >set as per your code. Why does this happen?? > >Thanks, >Sugan > >gene kelley wrote: >> On 7 Jun 2006 00:06:03 -0700, "Sugan" <vsu***@gmail.com> wrote: >> >> >Hi all, >> > >> >I need to enable context sensitive help in my application. For this >> >when user clicks on a menu item( "Whatis this"), i would change the >> >cursor to a help cursor. >> > >> >I used >> > >> >system.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Help >> > >> >As this code did not help in changing the cursor, i modified the code >> >to >> > >> >Me.Cursor = System.Windows.Forms.Cursors.Help >> > >> >This code indeed worked. But when i move the cursor over a item in the >> >menu, it changes back to the default cursor. >> > >> >Can someone tell me a way by which the cursor would remain as a help >> >cursor irrespective of the item the cursor hovers over. >> > >> >Thanks, >> > >> >Sugan >> >> ToolStripMenuItems do not have a Cursor Property, therefore, the >> Form's current cursor has no meaning when the mouse is over a >> DropDownItem. >> >> It's not exactly clear what you want to accomplish. >> Here is an example of using API to toggle the system cursor to >> CUR_HAND when the mouse enters any of the DropDownItem in a >> TopLevelMenu named FileMenu and back to the default cursor (NORMAL) >> when the mouse leaves the DropDownItems. >> >> There are two versions of the help cursor which you can use in place >> of CUR_HAND: >> >> Private Const OCR_NORMAL As Int32 = 32512 >> Private Const CUR_BUSY As Int32 = 21 >> Private Const CUR_HELP1 As Int32 = 39 >> Private Const CUR_HELP2 As Int32 = 41 >> Private Const CUR_HAND As Int32 = 45 >> >> Private Declare Function SetSystemCursor Lib "user32.dll" _ >> (ByVal hcur As Int32, ByVal id As Int32) As Int32 >> >> Private Sub Form1_Load(ByVal sender As Object, _ >> ByVal e As System.EventArgs) Handles Me.Load >> With Me.FileMenu >> If .HasDropDownItems Then >> Dim i As Integer >> For i = 0 To .DropDownItems.Count - 1 >> AddHandler .DropDownItems(i) _ >> .MouseEnter, AddressOf Me.ShowMenuCursor >> AddHandler .DropDownItems(i) _ >> .MouseLeave, AddressOf Me.ShowMenuCursor >> Next >> >> End If >> End With >> End Sub >> >> Private Sub ShowMenuCursor(ByVal sender As Object, _ >> ByVal e As System.EventArgs) >> SetSystemCursor(CUR_HAND, OCR_NORMAL) >> End Sub >> >> Gene If your menu items have context help available, setting a help cursor as a "flag" is a very odd way to accomplish this. The above example sets a system (global) cursor and has no relationship to the .net Cursors values. The VB6 Screen.MousePointer object was a better and safer method, but that was removed in VB2005. I use this method in my apps for "Busy" as the Form's WaitCursor does not always work properly, particularly when some 3rd party controls are on the form. You have to be careful, however, that you use the function in pairs, otherwise the system will maintain the set cursor until you reboot the system. In the above example, you can play with these additions and see if you can adapt to you project. The example with the additions, per se, is meaningless as the original example always displays a hand cursor over all the DropDownItems : 1) Add a new variable: Private IsCur_Hand As Boolean 2) In the Sub ShowMenuCursor add the line: IsCur_Hand = Not IsCur_Hand 3) Add this: Private Sub Item1ToolStripMenuItem_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Item3ToolStripMenuItem.Click If IsCur_Hand Then MessageBox.Show("Current cursor is Cur_Hand") Else End If End Sub Hello Gene,
Thanks for the response. i'm sure this logic would be useful to me. Thanks, Sugan gene kelley wrote: Show quoteHide quote > On 13 Jun 2006 04:54:36 -0700, "Sugan" <vsu***@gmail.com> wrote: > > >Hello gene, > > > >Thanks for the help. > >My aim is to provide a context dependent help. So when the user clicks > >on "What is this" menu item, i change the cursor to a help cursor. Your > >code in deed worked in this regard. > > > >I'm converting a VB 6 project to VB 2005. This worked perfectly with VB > >6 where i used Screen.MousePointer = vbArrowQuestion to convert the > >pointer to a help pointer. > > > >When the user clicks on any other menu item, > > > >i check for (cursor = cursors.help) to see whether the user is looking > >for help or the user is looking for the the functionality of the > >particular item. This code fails to identify the help cursor which is > >set as per your code. Why does this happen?? > > > >Thanks, > >Sugan > > > >gene kelley wrote: > >> On 7 Jun 2006 00:06:03 -0700, "Sugan" <vsu***@gmail.com> wrote: > >> > >> >Hi all, > >> > > >> >I need to enable context sensitive help in my application. For this > >> >when user clicks on a menu item( "Whatis this"), i would change the > >> >cursor to a help cursor. > >> > > >> >I used > >> > > >> >system.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Help > >> > > >> >As this code did not help in changing the cursor, i modified the code > >> >to > >> > > >> >Me.Cursor = System.Windows.Forms.Cursors.Help > >> > > >> >This code indeed worked. But when i move the cursor over a item in the > >> >menu, it changes back to the default cursor. > >> > > >> >Can someone tell me a way by which the cursor would remain as a help > >> >cursor irrespective of the item the cursor hovers over. > >> > > >> >Thanks, > >> > > >> >Sugan > >> > >> ToolStripMenuItems do not have a Cursor Property, therefore, the > >> Form's current cursor has no meaning when the mouse is over a > >> DropDownItem. > >> > >> It's not exactly clear what you want to accomplish. > >> Here is an example of using API to toggle the system cursor to > >> CUR_HAND when the mouse enters any of the DropDownItem in a > >> TopLevelMenu named FileMenu and back to the default cursor (NORMAL) > >> when the mouse leaves the DropDownItems. > >> > >> There are two versions of the help cursor which you can use in place > >> of CUR_HAND: > >> > >> Private Const OCR_NORMAL As Int32 = 32512 > >> Private Const CUR_BUSY As Int32 = 21 > >> Private Const CUR_HELP1 As Int32 = 39 > >> Private Const CUR_HELP2 As Int32 = 41 > >> Private Const CUR_HAND As Int32 = 45 > >> > >> Private Declare Function SetSystemCursor Lib "user32.dll" _ > >> (ByVal hcur As Int32, ByVal id As Int32) As Int32 > >> > >> Private Sub Form1_Load(ByVal sender As Object, _ > >> ByVal e As System.EventArgs) Handles Me.Load > >> With Me.FileMenu > >> If .HasDropDownItems Then > >> Dim i As Integer > >> For i = 0 To .DropDownItems.Count - 1 > >> AddHandler .DropDownItems(i) _ > >> .MouseEnter, AddressOf Me.ShowMenuCursor > >> AddHandler .DropDownItems(i) _ > >> .MouseLeave, AddressOf Me.ShowMenuCursor > >> Next > >> > >> End If > >> End With > >> End Sub > >> > >> Private Sub ShowMenuCursor(ByVal sender As Object, _ > >> ByVal e As System.EventArgs) > >> SetSystemCursor(CUR_HAND, OCR_NORMAL) > >> End Sub > >> > >> Gene > > > I still do not understand exactly what you are trying to accomplish. > If your menu items have context help available, setting a help cursor > as a "flag" is a very odd way to accomplish this. > > The above example sets a system (global) cursor and has no > relationship to the .net Cursors values. The VB6 Screen.MousePointer > object was a better and safer method, but that was removed in VB2005. > I use this method in my apps for "Busy" as the Form's WaitCursor does > not always work properly, particularly when some 3rd party controls > are on the form. You have to be careful, however, that you use the > function in pairs, otherwise the system will maintain the set cursor > until you reboot the system. > > In the above example, you can play with these additions and see if you > can adapt to you project. The example with the additions, per se, is > meaningless as the original example always displays a hand cursor over > all the DropDownItems : > > 1) Add a new variable: Private IsCur_Hand As Boolean > > 2) In the Sub ShowMenuCursor add the line: > IsCur_Hand = Not IsCur_Hand > > 3) Add this: > Private Sub Item1ToolStripMenuItem_Click(ByVal sender As Object, _ > ByVal e As System.EventArgs) Handles Item3ToolStripMenuItem.Click > If IsCur_Hand Then > MessageBox.Show("Current cursor is Cur_Hand") > > Else > > End If > End Sub Hi,
But is there no way, by which i can change the cursor for an application, instead of changing the system cursor. When a cursor for a application is changed, i want to see the changed cursor for all the items in the application ( menus, buttons, text boxes etc.). Is there a way to do it. In VB 6 this is accomplished using Screen.MousePointer = 14 Is there a similar way in VB .Net to accomplish this. Thnx in advance, Sugan |
|||||||||||||||||||||||