Statusbar text

Started by
4 comments, last by Kryptus 19 years, 4 months ago
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"?
Advertisement
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.
- To learn, we share... Give some to take some -
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.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Sorry guys, I'm using C++ and Win32 API. Not MFC.
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 procedureLRESULT 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
Thanks for that! It seems so easy now!

This topic is closed to new replies.

Advertisement