Status bar text and Menu 
Author Message
 Status bar text and Menu

Hello,

I was wondering how can I change the status bar text as the mouse
moves on the menu items.  For example, if the mouse is on "Open" menu
item, I want to show some message like "Open a document" in the status
bar.

How can it be done with VB?

Thanks in advance!

Joshua



Sat, 11 Sep 2004 09:21:51 GMT  
 Status bar text and Menu
What do you mean by 'the status bar' ?

Do you mean the Form's caption ?

Regardless, take a look at the MouseMouve event


Quote:
>Hello,

>I was wondering how can I change the status bar text as the mouse
>moves on the menu items.  For example, if the mouse is on "Open" menu
>item, I want to show some message like "Open a document" in the status
>bar.

>How can it be done with VB?

>Thanks in advance!

>Joshua



Sat, 11 Sep 2004 10:13:36 GMT  
 Status bar text and Menu
Set the ToolTextTip in properties
Bill


Quote:
> Hello,

> I was wondering how can I change the status bar text as the mouse
> moves on the menu items.  For example, if the mouse is on "Open" menu
> item, I want to show some message like "Open a document" in the status
> bar.

> How can it be done with VB?

> Thanks in advance!

> Joshua



Sat, 11 Sep 2004 14:06:21 GMT  
 Status bar text and Menu
I think it is called status bar.  if it is not status bar, what it is?
 It comes with MSCOMCTL.OCX and is used to display status message. For
example, in IE, when you move the mouse over a link, the URL of the
link will be displayed on "StatusBar".

Hope this makes it clear,
Joshua

Quote:

> Set the ToolTextTip in properties
> Bill



> > Hello,

> > I was wondering how can I change the status bar text as the mouse
> > moves on the menu items.  For example, if the mouse is on "Open" menu
> > item, I want to show some message like "Open a document" in the status
> > bar.

> > How can it be done with VB?

> > Thanks in advance!

> > Joshua



Sat, 11 Sep 2004 21:48:02 GMT  
 Status bar text and Menu
Do you mean a label ?


Quote:
>I think it is called status bar.  if it is not status bar, what it is?
> It comes with MSCOMCTL.OCX and is used to display status message. For
>example, in IE, when you move the mouse over a link, the URL of the
>link will be displayed on "StatusBar".

>Hope this makes it clear,
>Joshua


>> Set the ToolTextTip in properties
>> Bill



>> > Hello,

>> > I was wondering how can I change the status bar text as the mouse
>> > moves on the menu items.  For example, if the mouse is on "Open" menu
>> > item, I want to show some message like "Open a document" in the status
>> > bar.

>> > How can it be done with VB?

>> > Thanks in advance!

>> > Joshua



Sun, 12 Sep 2004 00:58:10 GMT  
 Status bar text and Menu
J,

This is status bar
In MS Word (for example)

You see Page 1 Sec 1...
On a bottom of Form.

This is status bar.


Quote:
> Do you mean a label ?


> >I think it is called status bar.  if it is not status bar, what it is?
> > It comes with MSCOMCTL.OCX and is used to display status message. For
> >example, in IE, when you move the mouse over a link, the URL of the
> >link will be displayed on "StatusBar".

> >Hope this makes it clear,
> >Joshua




Quote:
> >> Set the ToolTextTip in properties
> >> Bill



> >> > Hello,

> >> > I was wondering how can I change the status bar text as the mouse
> >> > moves on the menu items.  For example, if the mouse is on "Open" menu
> >> > item, I want to show some message like "Open a document" in the
status
> >> > bar.

> >> > How can it be done with VB?

> >> > Thanks in advance!

> >> > Joshua



Sun, 12 Sep 2004 01:06:00 GMT  
 Status bar text and Menu
On Tue, 26 Mar 2002 17:06:00 GMT, "Ivan Demkovitch"

Quote:

>J,

>This is status bar
>In MS Word (for example)

>You see Page 1 Sec 1...
>On a bottom of Form.

>This is status bar.

You reckon he means a Label at the bottom of a Form ?

We used to call that a 'Talker' - very useful for unobtrusive
assistance for users.

Definately a case for using the MouseMove event - it is a shame that
the standard controls do not have OnMouseEnter and OnMouseExit events.

Quote:



>> Do you mean a label ?


>> >I think it is called status bar.  if it is not status bar, what it is?
>> > It comes with MSCOMCTL.OCX and is used to display status message. For
>> >example, in IE, when you move the mouse over a link, the URL of the
>> >link will be displayed on "StatusBar".

>> >Hope this makes it clear,
>> >Joshua



>> >> Set the ToolTextTip in properties
>> >> Bill



>> >> > Hello,

>> >> > I was wondering how can I change the status bar text as the mouse
>> >> > moves on the menu items.  For example, if the mouse is on "Open" menu
>> >> > item, I want to show some message like "Open a document" in the
>status
>> >> > bar.

>> >> > How can it be done with VB?

>> >> > Thanks in advance!

>> >> > Joshua



Sun, 12 Sep 2004 16:11:20 GMT  
 Status bar text and Menu
I've just read the responses to this question and cannot believe how many
folks don't know what the status bar control is.  To set the text being
displayed by the status bar you say:

statusbar.SimpleText = "Open a document"

I don't know about how to do it when browsing through a menu though - you'll
have to check out all about menu bars first.


Quote:
> Hello,

> I was wondering how can I change the status bar text as the mouse
> moves on the menu items.  For example, if the mouse is on "Open" menu
> item, I want to show some message like "Open a document" in the status
> bar.

> How can it be done with VB?

> Thanks in advance!

> Joshua



Sun, 12 Sep 2004 17:26:55 GMT  
 Status bar text and Menu
<snip>
To use the StatusBar control in your application, you must add the
COMCTL32.OCX file to the project. When distributing your application,
install the COMCTL32.OCX file in the user's Microsoft Windows SYSTEM
directory. For more information on how to add a custom control to a
project, see the Programmer's Guide.
</snip>

I think the above might explain a bit

- personally I go through any number of hoops to avoid having to
distribute COMCTL32.OCX



Quote:
>I've just read the responses to this question and cannot believe how many
>folks don't know what the status bar control is.  To set the text being
>displayed by the status bar you say:

>statusbar.SimpleText = "Open a document"

>I don't know about how to do it when browsing through a menu though - you'll
>have to check out all about menu bars first.



>> Hello,

>> I was wondering how can I change the status bar text as the mouse
>> moves on the menu items.  For example, if the mouse is on "Open" menu
>> item, I want to show some message like "Open a document" in the status
>> bar.

>> How can it be done with VB?

>> Thanks in advance!

>> Joshua



Sun, 12 Sep 2004 18:53:36 GMT  
 Status bar text and Menu
Thanks to all of you for responding my question :)

I know how to set the StatusBar text.  However, what I don't know is
how can I detect the mouse is on a particular menu item.

Most windows applications have that feature, let me repeat, when the
mouse cursor is on "File > Open" menu item, a short description is
displayed on the status bar text area saying "Open a document in this
window".

I am wondering how did they do that.  I just don't have any clue :(.
I am thinking of putting this feature in my program but don't have any
clue yet.

I think this make clear my question!

Thanks!
Josh

Quote:

> <snip>
> To use the StatusBar control in your application, you must add the
> COMCTL32.OCX file to the project. When distributing your application,
> install the COMCTL32.OCX file in the user's Microsoft Windows SYSTEM
> directory. For more information on how to add a custom control to a
> project, see the Programmer's Guide.
> </snip>

> I think the above might explain a bit

> - personally I go through any number of hoops to avoid having to
> distribute COMCTL32.OCX



> >I've just read the responses to this question and cannot believe how many
> >folks don't know what the status bar control is.  To set the text being
> >displayed by the status bar you say:

> >statusbar.SimpleText = "Open a document"

> >I don't know about how to do it when browsing through a menu though - you'll
> >have to check out all about menu bars first.



> >> Hello,

> >> I was wondering how can I change the status bar text as the mouse
> >> moves on the menu items.  For example, if the mouse is on "Open" menu
> >> item, I want to show some message like "Open a document" in the status
> >> bar.

> >> How can it be done with VB?

> >> Thanks in advance!

> >> Joshua



Sun, 12 Sep 2004 22:09:33 GMT  
 Status bar text and Menu
I can't believe the responses to this either...

The solution is to subclass the window and process the WM_MENUSELECT
message.  VB provides no event for selecting menu items.  If you don't know
about subclassing or window messages, this might be a bit involved (and I
don't have the time to explain it all).

WM_MENUSELECT:
http://msdn.microsoft.com/library/en-us/winui/keybacel_4jp0.asp?frame...

I don't have a link for a good page about subclassing in VB offhand.  Sorry,
like I say, limited time...  Someone else may have something...


Quote:
> Thanks to all of you for responding my question :)

> I know how to set the StatusBar text.  However, what I don't know is
> how can I detect the mouse is on a particular menu item.

> Most windows applications have that feature, let me repeat, when the
> mouse cursor is on "File > Open" menu item, a short description is
> displayed on the status bar text area saying "Open a document in this
> window".

> I am wondering how did they do that.  I just don't have any clue :(.
> I am thinking of putting this feature in my program but don't have any
> clue yet.

> I think this make clear my question!

> Thanks!
> Josh




- Show quoted text -

Quote:
> > <snip>
> > To use the StatusBar control in your application, you must add the
> > COMCTL32.OCX file to the project. When distributing your application,
> > install the COMCTL32.OCX file in the user's Microsoft Windows SYSTEM
> > directory. For more information on how to add a custom control to a
> > project, see the Programmer's Guide.
> > </snip>

> > I think the above might explain a bit

> > - personally I go through any number of hoops to avoid having to
> > distribute COMCTL32.OCX



> > >I've just read the responses to this question and cannot believe how
many
> > >folks don't know what the status bar control is.  To set the text being
> > >displayed by the status bar you say:

> > >statusbar.SimpleText = "Open a document"

> > >I don't know about how to do it when browsing through a menu though -
you'll
> > >have to check out all about menu bars first.



> > >> Hello,

> > >> I was wondering how can I change the status bar text as the mouse
> > >> moves on the menu items.  For example, if the mouse is on "Open" menu
> > >> item, I want to show some message like "Open a document" in the
status
> > >> bar.

> > >> How can it be done with VB?

> > >> Thanks in advance!

> > >> Joshua



Sun, 12 Sep 2004 22:33:53 GMT  
 Status bar text and Menu
I haven't done this myself but from looking at other posts it seems
that you have to use subclassing.  Do a search for

status bar subclass

in clbv and you'll see what other people have answered to this
question in the past.

Quote:

> Hello,

> I was wondering how can I change the status bar text as the mouse
> moves on the menu items.



Sun, 12 Sep 2004 22:50:48 GMT  
 Status bar text and Menu

Quote:
>Thanks to all of you for responding my question :)

>I know how to set the StatusBar text.  However, what I don't know is
>how can I detect the mouse is on a particular menu item.

>Most windows applications have that feature, let me repeat, when the
>mouse cursor is on "File > Open" menu item, a short description is
>displayed on the status bar text area saying "Open a document in this
>window".

>I am wondering how did they do that.  I just don't have any clue :(.
>I am thinking of putting this feature in my program but don't have any
>clue yet.

>I think this make clear my question!

I believe for that you have to subclass your Form then use the
TrackPopUpMenu API which will send messages back to your window untila
selection is made.
 You then trap these messages and this is where i lose the clue.  :-/
You may have to use GetSystemMetrics to work out the menu height and
then calculate the position of the cursor which you would retrieve
with GetCursorPos and then you could update your statusBar..
Then again, you may get the WM_MOUSEMOVE message, with the MenuID in
wParam or lParam which of course would make life a bit easier..
Goad, i can't remember this stuff any more.. i'm getting de-skilled
even before i've got skilled !
Anayway, hope that helps.  Don't forget to save often. :)

Regards, Frank



Mon, 13 Sep 2004 01:01:09 GMT  
 Status bar text and Menu
After reading the other replies, I thought about throwing the following
example into the group.
Please read the comments in the code.

Create a new project, add some menu structure to the form. Make as many
menus and sub-menus as you want. Also put a StatusBar on the form.
Add a module to the project.

Paste the following code to the form's (General)(Declaration) section:
==================================================
Option Explicit

Private Sub Form_Load()
    StatusBar1.Style = sbrSimple

    gPrevWndProc = SubClass(Me.hWnd)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    UnSubClass Me.hWnd, gPrevWndProc
End Sub
==================================================

Paste the following code to the module's (General)(Declaration) section:
==================================================
Option Explicit

Public Const GWL_WNDPROC = (-4)
Public Const WM_MENUSELECT = &H11F
Public Const SC_RESTORE = &HF120&
Public Const SC_MOVE = &HF010&
Public Const SC_SIZE = &HF000&
Public Const SC_MINIMIZE = &HF020&
Public Const SC_MAXIMIZE = &HF030&
Public Const SC_CLOSE = &HF060&

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA"
(ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long

Public gPrevWndProc As Long

Public Function SubClass(hWnd As Long) As Long
    On Error GoTo SubClass_Error
'Use the Debug object to print some calculation that will rais an error.
'This way the program jumps to the SubClass_Error label,
'and the hWnd's object is NOT subclassed in te IDE
'
'Because the Debug object is ignored in the compiled (.exe) program,
'the hWnd's object IS subclassed in the .exe
'
'Comment-out the next line to subclass also in the IDE

    'Debug.Print 1 / 0

'
'NOTE: ------------------------------------------------------+
'Pausing or Stopping a subclassed form can result in         |
'unpredictable situations or even let VB crash               |
'------------------------------------------------------------+

    SubClass = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)

SubClass_Error:

End Function

Public Function UnSubClass(hWnd As Long, lpPrevWndProc As Long) As Long
    UnSubClass = SetWindowLong(hWnd, GWL_WNDPROC, lpPrevWndProc)
End Function

Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
Dim hSysMenu As Long
Dim sMenuText As String
Dim uFlags As Long
Dim uItem As Long

    Select Case uMsg
        Case WM_MENUSELECT
            uItem = wParam And &HFFFF&
            uFlags = wParam \ &H10000 And &HFFFF&
            Select Case uItem
                Case 0 ' No menu
                    sMenuText = ""
                'The following values are defined by Visual Basic
                'They always start from 1 and increment through each menu
item

                'The following prompts correspond to system menu commands
                Case SC_RESTORE
                    sMenuText = "Restore this window to it's previous size"
                Case SC_MOVE
                    sMenuText = "Move this window"
                Case SC_SIZE
                    sMenuText = "Size this window"
                Case SC_MINIMIZE
                    sMenuText = "Minimize this window to the taskbar"
                Case SC_MAXIMIZE
                    sMenuText = "Maximize this window"
                Case SC_CLOSE
                    sMenuText = "Close this window"
                Case Else
                    'This is where I need help also!!
*************************************
                    'The uItem seems to identify the menu item, but I don't
see any logic *
                    'The uFlags gives information about grayed, chacked etc.
*
                    'For this example, just show the values:
*****************************

_

            End Select
            Form1.StatusBar1.simpleText = sMenuText
            WindowProc = CallWindowProc(gPrevWndProc, hWnd, uMsg, wParam,
lParam)
        Case Else
            WindowProc = CallWindowProc(gPrevWndProc, hWnd, uMsg, wParam,
lParam)
    End Select
End Function
==================================================

*Save* and run the project. Browse through the menu (also the system-menu)
and try to find out the logic in the uItem-flag :-)

Johan.



Quote:
> Hello,

> I was wondering how can I change the status bar text as the mouse
> moves on the menu items.  For example, if the mouse is on "Open" menu
> item, I want to show some message like "Open a document" in the status
> bar.

> How can it be done with VB?

> Thanks in advance!

> Joshua



Mon, 13 Sep 2004 07:32:00 GMT  
 Status bar text and Menu
Thanks Johan!

It works beautifully :)  That's what I mean..  I need some time to
learn this code to be used with my menus though.

Thanks!
Josh

Quote:

> After reading the other replies, I thought about throwing the following
> example into the group.
> Please read the comments in the code.

> Create a new project, add some menu structure to the form. Make as many
> menus and sub-menus as you want. Also put a StatusBar on the form.
> Add a module to the project.

> Paste the following code to the form's (General)(Declaration) section:
> ==================================================
> Option Explicit

> Private Sub Form_Load()
>     StatusBar1.Style = sbrSimple

>     gPrevWndProc = SubClass(Me.hWnd)
> End Sub

> Private Sub Form_Unload(Cancel As Integer)
>     UnSubClass Me.hWnd, gPrevWndProc
> End Sub
> ==================================================

> Paste the following code to the module's (General)(Declaration) section:
> ==================================================
> Option Explicit

> Public Const GWL_WNDPROC = (-4)
> Public Const WM_MENUSELECT = &H11F
> Public Const SC_RESTORE = &HF120&
> Public Const SC_MOVE = &HF010&
> Public Const SC_SIZE = &HF000&
> Public Const SC_MINIMIZE = &HF020&
> Public Const SC_MAXIMIZE = &HF030&
> Public Const SC_CLOSE = &HF060&

> Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
> (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
> Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA"
> (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal
> wParam As Long, ByVal lParam As Long) As Long

> Public gPrevWndProc As Long

> Public Function SubClass(hWnd As Long) As Long
>     On Error GoTo SubClass_Error
> 'Use the Debug object to print some calculation that will rais an error.
> 'This way the program jumps to the SubClass_Error label,
> 'and the hWnd's object is NOT subclassed in te IDE
> '
> 'Because the Debug object is ignored in the compiled (.exe) program,
> 'the hWnd's object IS subclassed in the .exe
> '
> 'Comment-out the next line to subclass also in the IDE

>     'Debug.Print 1 / 0

> '
> 'NOTE: ------------------------------------------------------+
> 'Pausing or Stopping a subclassed form can result in         |
> 'unpredictable situations or even let VB crash               |
> '------------------------------------------------------------+

>     SubClass = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)

> SubClass_Error:

> End Function

> Public Function UnSubClass(hWnd As Long, lpPrevWndProc As Long) As Long
>     UnSubClass = SetWindowLong(hWnd, GWL_WNDPROC, lpPrevWndProc)
> End Function

> Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal
> wParam As Long, ByVal lParam As Long) As Long
> Dim hSysMenu As Long
> Dim sMenuText As String
> Dim uFlags As Long
> Dim uItem As Long

>     Select Case uMsg
>         Case WM_MENUSELECT
>             uItem = wParam And &HFFFF&
>             uFlags = wParam \ &H10000 And &HFFFF&
>             Select Case uItem
>                 Case 0 ' No menu
>                     sMenuText = ""
>                 'The following values are defined by Visual Basic
>                 'They always start from 1 and increment through each menu
> item

>                 'The following prompts correspond to system menu commands
>                 Case SC_RESTORE
>                     sMenuText = "Restore this window to it's previous size"
>                 Case SC_MOVE
>                     sMenuText = "Move this window"
>                 Case SC_SIZE
>                     sMenuText = "Size this window"
>                 Case SC_MINIMIZE
>                     sMenuText = "Minimize this window to the taskbar"
>                 Case SC_MAXIMIZE
>                     sMenuText = "Maximize this window"
>                 Case SC_CLOSE
>                     sMenuText = "Close this window"
>                 Case Else
>                     'This is where I need help also!!
> *************************************
>                     'The uItem seems to identify the menu item, but I don't
> see any logic *
>                     'The uFlags gives information about grayed, chacked etc.
> *
>                     'For this example, just show the values:
> *****************************

> _

>             End Select
>             Form1.StatusBar1.simpleText = sMenuText
>             WindowProc = CallWindowProc(gPrevWndProc, hWnd, uMsg, wParam,
> lParam)
>         Case Else
>             WindowProc = CallWindowProc(gPrevWndProc, hWnd, uMsg, wParam,
> lParam)
>     End Select
> End Function
> ==================================================

> *Save* and run the project. Browse through the menu (also the system-menu)
> and try to find out the logic in the uItem-flag :-)

> Johan.



> > Hello,

> > I was wondering how can I change the status bar text as the mouse
> > moves on the menu items.  For example, if the mouse is on "Open" menu
> > item, I want to show some message like "Open a document" in the status
> > bar.

> > How can it be done with VB?

> > Thanks in advance!

> > Joshua



Mon, 13 Sep 2004 10:01:24 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Status bar text for Menu items

2. Status Bar Text From Menu Position

3. Menus with Status Bar Text

4. Menu Help Text on the Status Bar Question

5. Displaying the highlightened menu item's text on the status bar

6. Status bar+ menu bar

7. Menu descriptions in a status bar...

8. Menu Commands and Status bar

9. Pulldown menu hints in status bar

10. Displaying info about menu items in a status bar

11. Help Tying a Menu and Status Bar Together

12. Showing menu item descriptions in the status bar?

 

 
Powered by phpBB® Forum Software