 |
| VB How-To Ask your "How do I do this with VB?" questions in this forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 20th, 2004, 11:53 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Menu help in Status Bar.panel(1).text
You may have observed that when you move your mouse over any menu item in any microsoft application then you get a note on the status bar about the menu item over which your mouse is standing. But as soon as you leave the menu item it changes.
I want to do the same in my application. How can i? PLease tell me if it can be done with any API calls and how?
Bye
------------------
Kaustav
__________________
------------------
Kaustav
|
|

January 20th, 2004, 05:08 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yuo have two choices.
First, put some code in MouseMove event of *every* component for which you want to display some information. This has the problem that the status bar does not "reset" if the cursor is in some component with no Move event, or it goes outside the window.
Second, in a timer event (1 second should be enough) use the GetCursorPos API to get the mouse position and the ChildWindowFromPoint to get the window where the mouse is. Now loop through all the controls in your form until you find the control with the right Hwnd. If found, display something, otherwise reset the status bar.
Marco
|
|

January 31st, 2004, 03:06 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanx marcostraf.
But this is not the thing i wanted. I wanted to know that how can i isplay a string in the status bar when i am on a specific menu item .
That is if i click on "file" menu and highlight the "New" menu item but do not click on it i get to see "Opends the new Dialog box" message on my status bar.
PLz help.
bye
------------------
Kaustav
|
|

February 2nd, 2004, 08:30 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is a Sub I use in my MDI form to do this. I hope this helps.
Private Sub HandleSelect(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles mnuStatusBar.Select, mnuAbout.Select, mnuCascade.Select, mnuExit.Select, _
mnuOpen.Select, mnuTileHorizontal.Select, mnuTileVertical.Select, mnuFile.Select, _
mnuView.Select, mnuWindow.Select, mnuHelp.Select
Dim strText As String
If sender Is mnuStatusBar Then
strText = "Toggle display of the status bar"
ElseIf sender Is mnuAbout Then
strText = "Display the About dialog box"
ElseIf sender Is mnuCascade Then
strText = "Cascade child windows"
ElseIf sender Is mnuExit Then
strText = "Exit"
ElseIf sender Is mnuOpen Then
strText = "Create new child window"
ElseIf sender Is mnuTileHorizontal Then
strText = "Tile windows horizontally"
ElseIf sender Is mnuTileVertical Then
strText = "Tile windows vertically"
Else
strText = String.Empty
End If
WriteToStatusBar(strText)
End Sub
|
|

February 2nd, 2004, 02:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This will work in .NET only...
The VB standard menu exposes only the click event, thus we are out of luck. It is possible to do it subclassing the form (well, you can do everything subclassing!) but it is a messy business and you need a lot of code. A third party component that exposes the MenuItemEnter and MenuItemLeave events (like the ActiveBar control by Data Dynamics) can do the trick.
Marco
Quote:
quote:Originally posted by nbryson
This is a Sub I use in my MDI form to do this. I hope this helps.
Private Sub HandleSelect(ByVal sender As Object, ByVal e As System.EventArgs) _
|
|
|

February 3rd, 2004, 02:03 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dear nbryson,
Thanx for your help . But can you tell me plz where to place this sub function and how to call it. PLz give the full details.
Bye
------------------
Kaustav
|
|

February 3rd, 2004, 02:08 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
dear Marcostraf,
PLz tell me hw can i do the same with subclassing. Provide the full step. Since i have less knowledge in subclassing.
bye
------------------
Kaustav
|
|

February 3rd, 2004, 05:55 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Kaustav
Dear nbryson,
Thanx for your help . But can you tell me plz where to place this sub function and how to call it. PLz give the full details.
Bye
------------------
Kaustav
|
What environment are you using?. The code I send was using VB.Net.
|
|

February 3rd, 2004, 03:03 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dear Kaustav,
subclassing is a messy business and I suggest you to try only if you have a lot of time and patience. It is a too big of a subject for a post, try searching the web (careful, 90% is junk, as all the internet is). Start with 'good' we sites like the developers exchange www.dex.com and the VBPJ archives www.fawcette.com/archives/magazines/vsm
Marco
Quote:
quote:Originally posted by Kaustav
dear Marcostraf,
PLz tell me hw can i do the same with subclassing. Provide the full step. Since i have less knowledge in subclassing.
bye
------------------
Kaustav
|
|
|

February 5th, 2004, 01:14 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i use VB 6.0 on windows XP
------------------
Kaustav
|
|
 |