No announcement yet.

Refreshing Menu

  • Filter
  • Time
  • Show
Clear All
new posts

  • Refreshing Menu

    I have again a problem

    In an app I'm enabling and disabling (graying) menu items based on the state of the data (saved, dirty etc.). EnableMenuItem does this, but the menu does not get updated immediately- only after moving mouse on some menu item.

    So, after reading API docs, I came to conclusion that DrawMenuBar was the function to use to update the menu.

    The DrawMenuBar function redraws the menu bar of the specified window. If the menu bar changes after the system has created the window, this function must be called to draw the changed menu bar.

    BOOL DrawMenuBar(
    HWND hWnd // handle to window with menu bar to redraw
    There my problems started. Calling this function crashes my system (Win98 or NT 4) - no system resources left.

    I call this function in the main window procedure after END SELECT just before calling the default window procedure.

    In my systems I can demonstrate this by taking SKELETON.BAS sample program and making following modification in the end of WndProc function.

      DrawMenuBar hWnd ' <-- Add this line
      FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
    After running the program at least I have to point my finger to reset button, no other way.

    So, two questions:

    Can anybody tell me what I am doing wrong?

    How do I refresh the menu after enabling/disabling some items?


    Lasse Rantanen
    [email protected]

  • #2
    Please ignore this question. I feel . The place where I called DrawMenuBar was only for calling problems - endless loop

    In a rush I thought saving some typing (few seconds) and spent hours (rebooting).

    Lasse Rantanen
    [email protected]