Showing menu if value is true

This is a discussion on Showing menu if value is true within the Windows Programming forums, part of the Platform Specific Boards category; I have menu in my resource file, but I want for parts of menu (popups) to be visible and accessible ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Location
    Slovenia, Europe
    Posts
    115

    Showing menu if value is true

    I have menu in my resource file, but I want for parts of menu (popups) to be visible and accessible only if user is allowed to see (or for example, if the variable is true). How to do it?

    Thanks for all help!
    [C++]
    IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
    2nd compiler: g++ (GCC 3.4.3/4.0.0)
    3rd compiler: Borland 5.5
    [C#]
    IDE: Microsoft Visual C# Express 2005
    2nd IDE: SharpDevelop
    2nd compiler: csc in Command Prompt
    .NET Framework: 2.0
    [PHP]
    Core: 5.1.0 beta 3
    IDE: PHPEdit
    2nd IDE: Notepad
    Favourite extensions: exif,gd2,mysql
    Favourite PEAR packages: DB, XML_RSS, ID3
    Favourite databases: SQLite, MySQL

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    You can use the following functions to hide and show windows:
    Code:
    ShowWindow(hwnd,SW_SHOW); // show a window
    ShowWindow(hwnd,SW_HIDE);  // hide a window

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I used EnableMenu(), ModifyMenu() and DeleteMenu() to do this.

    Hooked a function to the dlgs init / create. Created the menu in full in the resource editor. Sent in the users access level and removed menu items based on that.

    Watch the by_position flag as an items position changes as you add / remove items.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Nov 2004
    Location
    Slovenia, Europe
    Posts
    115
    Thanks - i made it work like this..:

    Code:
    HMENU hMenu = GetMenu(hwnd);
    EnableMenuItem(hMenu, (UINT)MAKEINTRESOURCE(IDC_RESOURCE), MF_DISABLED | MF_GRAYED);
    [C++]
    IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
    2nd compiler: g++ (GCC 3.4.3/4.0.0)
    3rd compiler: Borland 5.5
    [C#]
    IDE: Microsoft Visual C# Express 2005
    2nd IDE: SharpDevelop
    2nd compiler: csc in Command Prompt
    .NET Framework: 2.0
    [PHP]
    Core: 5.1.0 beta 3
    IDE: PHPEdit
    2nd IDE: Notepad
    Favourite extensions: exif,gd2,mysql
    Favourite PEAR packages: DB, XML_RSS, ID3
    Favourite databases: SQLite, MySQL

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You may also be interested in the WM_MENUSELECT notification. This is posted when a menu is selected, enabling you to grey out menu items as needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu like file, edit, help, etc...
    By Livijn in forum Windows Programming
    Replies: 44
    Last Post: 01-23-2007, 04:49 PM
  2. Menu showing twice?
    By bconnor in forum C Programming
    Replies: 4
    Last Post: 10-17-2006, 05:58 AM
  3. Menu not showing
    By IdunnO in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2006, 01:29 AM
  4. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 10:06 PM
  5. Menu stuff
    By Shadow in forum C Programming
    Replies: 10
    Last Post: 04-28-2002, 09:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21