Sign in to follow this  
Kryptus

Statusbar text

Recommended Posts

How do I make it so the text of a statusbar changes when I put my mouse on a menu? Eg. When I put the mouse over File > New the statusbar will say "Create a new document" and when i put the mouse over File > Exit it will say "Exit to Windows"?

Share this post


Link to post
Share on other sites
by default, if u're using MFC or .NET forms, u can assign a description to the menu items. That description is automatically displayed onto the statusbar of ur application if one exists.
but to do it manually, would be as simple as assigning a mouse enter/leave handler that sets something like:
statusbar->text = "Something" OR
statusbar->text = menuitem->description

ok, do NOT take the stuff above literally. it is just a sample and .NET seems to do is as simple as that. thats my 2cents worth.

Share this post


Link to post
Share on other sites
Since you haven't told us what language youre using...
In Delphi you put some text after the vertical-bar character in the hint property of the menu item.

e.g.
menuFileNew.Hint := 'New|Create a new document';
menuFileExit.Hint := 'Exit|Exit to Windows';

Please give more details in future.

Share this post


Link to post
Share on other sites
With just bare Win32API you'll have to do it manually...

Like this:


#define IDC_FILE_NEW 1000
#define IDC_FILE_EXIT 1001

//...

//your window procedure
LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND statusBar; //handle of the status bar

switch (msg) {
//... init your window and create the statusBar

//
//menu selection message
//
case WM_MENUSELECT: {
switch (LOWORD (wParam)) { //loword of wParam is the identifier of the menu item
case WM_FILE_NEW:
//file->new selected
SetWindowText (statusBar, "Create new file");
return 0;

case WM_FILE_EXIT:
//file->exit selected
SetWindowText (statusBar, "Get the hell outta here!");
return 0;
}

break;
}
}

return DefWindowProc (hWnd, msg, wParam, lParam);
}



This should do it.

Oxyd

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this