EnableMenu api call does nothing


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: EnableMenu api call does nothing

  1. #1
    ron Guest

    EnableMenu api call does nothing


    For an MDI Child, I am trying to modify the system menu so that the "Next"
    menu command is disabled.

    I have the following code in a module:

    Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal
    hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long, ByVal uIDNewItem
    As Long, ByVal lpNewItem As String) As Long
    Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal
    bRevert As Long) As Long

    Const MF_BYCOMMAND = &H0&
    Const MF_GRAYED = &H1&
    Const SC_NEXTWINDOW = &HF040&


    in the command_click of of a button i have:


    hMenu = GetSystemMenu(Me.hwnd, 0)
    iRet = ModifyMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or MF_GRAYED, SC_NEXTWINDOW,
    "Nex&t" & Chr(9) & "Ctrl+F6")


    but this does nothing. I have no idea why. Any help is appreciated.

    Ron

  2. #2
    Eduardo A. Morcillo Guest

    Re: EnableMenu api call does nothing

    Use the EnableMenuItem api:

    Declare Function EnableMenuItem Lib "user32" ( _
    ByVal hMenu As Long, _
    ByVal uIDEnableItem As Long, _
    ByVal uEnable As Long) As Long


    ' Enable the item
    hMenu = GetSystemMenu(Me.hwnd, 0)
    EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    MF_ENABLED

    ' Disable the item
    hMenu = GetSystemMenu(Me.hwnd, 0)
    EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    MF_DISABLED

    HTH
    --
    Eduardo A. Morcillo
    http://www.domaindlx.com/e_morcillo
    "ron" <ron_nospam@ron.com> wrote in message news:3957b5e7$1@news.devx.com...
    >
    > For an MDI Child, I am trying to modify the system menu so that the "Next"
    > menu command is disabled.
    >
    > I have the following code in a module:
    >
    > Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal
    > hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long, ByVal

    uIDNewItem
    > As Long, ByVal lpNewItem As String) As Long
    > Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,

    ByVal
    > bRevert As Long) As Long
    >
    > Const MF_BYCOMMAND = &H0&
    > Const MF_GRAYED = &H1&
    > Const SC_NEXTWINDOW = &HF040&
    >
    >
    > in the command_click of of a button i have:
    >
    >
    > hMenu = GetSystemMenu(Me.hwnd, 0)
    > iRet = ModifyMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or MF_GRAYED,

    SC_NEXTWINDOW,
    > "Nex&t" & Chr(9) & "Ctrl+F6")
    >
    >
    > but this does nothing. I have no idea why. Any help is appreciated.
    >
    > Ron




  3. #3
    Eduardo A. Morcillo Guest

    Re: EnableMenu api call does nothing

    Use the EnableMenuItem api:

    Declare Function EnableMenuItem Lib "user32" ( _
    ByVal hMenu As Long, _
    ByVal uIDEnableItem As Long, _
    ByVal uEnable As Long) As Long


    ' Enable the item
    hMenu = GetSystemMenu(Me.hwnd, 0)
    EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    MF_ENABLED

    ' Disable the item
    hMenu = GetSystemMenu(Me.hwnd, 0)
    EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    MF_DISABLED

    HTH
    --
    Eduardo A. Morcillo
    http://www.domaindlx.com/e_morcillo
    "ron" <ron_nospam@ron.com> wrote in message news:3957b5e7$1@news.devx.com...
    >
    > For an MDI Child, I am trying to modify the system menu so that the "Next"
    > menu command is disabled.
    >
    > I have the following code in a module:
    >
    > Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal
    > hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long, ByVal

    uIDNewItem
    > As Long, ByVal lpNewItem As String) As Long
    > Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,

    ByVal
    > bRevert As Long) As Long
    >
    > Const MF_BYCOMMAND = &H0&
    > Const MF_GRAYED = &H1&
    > Const SC_NEXTWINDOW = &HF040&
    >
    >
    > in the command_click of of a button i have:
    >
    >
    > hMenu = GetSystemMenu(Me.hwnd, 0)
    > iRet = ModifyMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or MF_GRAYED,

    SC_NEXTWINDOW,
    > "Nex&t" & Chr(9) & "Ctrl+F6")
    >
    >
    > but this does nothing. I have no idea why. Any help is appreciated.
    >
    > Ron




  4. #4
    Ron Guest

    Re: EnableMenu api call does nothing


    I tried the following:

    const SC_MOVE = &HF010&

    and tried this with the Move command. It had no effect. Same with maximize,
    etc

    "Eduardo A. Morcillo" <e_morcillo@yahoo.com> wrote:
    >Use the EnableMenuItem api:
    >
    >Declare Function EnableMenuItem Lib "user32" ( _
    > ByVal hMenu As Long, _
    > ByVal uIDEnableItem As Long, _
    > ByVal uEnable As Long) As Long
    >
    >
    >' Enable the item
    >hMenu = GetSystemMenu(Me.hwnd, 0)
    >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > MF_ENABLED
    >
    >' Disable the item
    >hMenu = GetSystemMenu(Me.hwnd, 0)
    >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > MF_DISABLED
    >
    >HTH
    >--
    >Eduardo A. Morcillo
    >http://www.domaindlx.com/e_morcillo
    >"ron" <ron_nospam@ron.com> wrote in message news:3957b5e7$1@news.devx.com...
    >>
    >> For an MDI Child, I am trying to modify the system menu so that the "Next"
    >> menu command is disabled.
    >>
    >> I have the following code in a module:
    >>
    >> Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal
    >> hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long, ByVal

    >uIDNewItem
    >> As Long, ByVal lpNewItem As String) As Long
    >> Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,

    >ByVal
    >> bRevert As Long) As Long
    >>
    >> Const MF_BYCOMMAND = &H0&
    >> Const MF_GRAYED = &H1&
    >> Const SC_NEXTWINDOW = &HF040&
    >>
    >>
    >> in the command_click of of a button i have:
    >>
    >>
    >> hMenu = GetSystemMenu(Me.hwnd, 0)
    >> iRet = ModifyMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or MF_GRAYED,

    >SC_NEXTWINDOW,
    >> "Nex&t" & Chr(9) & "Ctrl+F6")
    >>
    >>
    >> but this does nothing. I have no idea why. Any help is appreciated.
    >>
    >> Ron

    >
    >



  5. #5
    Ron Guest

    Re: EnableMenu api call does nothing


    I tried the following:

    const SC_MOVE = &HF010&

    and tried this with the Move command. It had no effect. Same with maximize,
    etc

    "Eduardo A. Morcillo" <e_morcillo@yahoo.com> wrote:
    >Use the EnableMenuItem api:
    >
    >Declare Function EnableMenuItem Lib "user32" ( _
    > ByVal hMenu As Long, _
    > ByVal uIDEnableItem As Long, _
    > ByVal uEnable As Long) As Long
    >
    >
    >' Enable the item
    >hMenu = GetSystemMenu(Me.hwnd, 0)
    >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > MF_ENABLED
    >
    >' Disable the item
    >hMenu = GetSystemMenu(Me.hwnd, 0)
    >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > MF_DISABLED
    >
    >HTH
    >--
    >Eduardo A. Morcillo
    >http://www.domaindlx.com/e_morcillo
    >"ron" <ron_nospam@ron.com> wrote in message news:3957b5e7$1@news.devx.com...
    >>
    >> For an MDI Child, I am trying to modify the system menu so that the "Next"
    >> menu command is disabled.
    >>
    >> I have the following code in a module:
    >>
    >> Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal
    >> hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long, ByVal

    >uIDNewItem
    >> As Long, ByVal lpNewItem As String) As Long
    >> Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,

    >ByVal
    >> bRevert As Long) As Long
    >>
    >> Const MF_BYCOMMAND = &H0&
    >> Const MF_GRAYED = &H1&
    >> Const SC_NEXTWINDOW = &HF040&
    >>
    >>
    >> in the command_click of of a button i have:
    >>
    >>
    >> hMenu = GetSystemMenu(Me.hwnd, 0)
    >> iRet = ModifyMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or MF_GRAYED,

    >SC_NEXTWINDOW,
    >> "Nex&t" & Chr(9) & "Ctrl+F6")
    >>
    >>
    >> but this does nothing. I have no idea why. Any help is appreciated.
    >>
    >> Ron

    >
    >



  6. #6
    Eduardo A. Morcillo Guest

    Re: EnableMenu api call does nothing

    I didn't tried it. Maybe Windows is reseting the item when the menu is
    opened or the form is moved or resized. Did you try to remove the item
    instead of disable it?

    --
    Eduardo A. Morcillo
    http://www.domaindlx.com/e_morcillo
    "Ron" <ron_nospam@ron.com> wrote in message news:3958a155$1@news.devx.com...
    >
    > I tried the following:
    >
    > const SC_MOVE = &HF010&
    >
    > and tried this with the Move command. It had no effect. Same with

    maximize,
    > etc
    >
    > "Eduardo A. Morcillo" <e_morcillo@yahoo.com> wrote:
    > >Use the EnableMenuItem api:
    > >
    > >Declare Function EnableMenuItem Lib "user32" ( _
    > > ByVal hMenu As Long, _
    > > ByVal uIDEnableItem As Long, _
    > > ByVal uEnable As Long) As Long
    > >
    > >
    > >' Enable the item
    > >hMenu = GetSystemMenu(Me.hwnd, 0)
    > >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > > MF_ENABLED
    > >
    > >' Disable the item
    > >hMenu = GetSystemMenu(Me.hwnd, 0)
    > >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > > MF_DISABLED
    > >
    > >HTH
    > >--
    > >Eduardo A. Morcillo
    > >http://www.domaindlx.com/e_morcillo
    > >"ron" <ron_nospam@ron.com> wrote in message

    news:3957b5e7$1@news.devx.com...
    > >>
    > >> For an MDI Child, I am trying to modify the system menu so that the

    "Next"
    > >> menu command is disabled.
    > >>
    > >> I have the following code in a module:
    > >>
    > >> Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA"

    (ByVal
    > >> hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long, ByVal

    > >uIDNewItem
    > >> As Long, ByVal lpNewItem As String) As Long
    > >> Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,

    > >ByVal
    > >> bRevert As Long) As Long
    > >>
    > >> Const MF_BYCOMMAND = &H0&
    > >> Const MF_GRAYED = &H1&
    > >> Const SC_NEXTWINDOW = &HF040&
    > >>
    > >>
    > >> in the command_click of of a button i have:
    > >>
    > >>
    > >> hMenu = GetSystemMenu(Me.hwnd, 0)
    > >> iRet = ModifyMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or MF_GRAYED,

    > >SC_NEXTWINDOW,
    > >> "Nex&t" & Chr(9) & "Ctrl+F6")
    > >>
    > >>
    > >> but this does nothing. I have no idea why. Any help is appreciated.
    > >>
    > >> Ron

    > >
    > >

    >




  7. #7
    Eduardo A. Morcillo Guest

    Re: EnableMenu api call does nothing

    I didn't tried it. Maybe Windows is reseting the item when the menu is
    opened or the form is moved or resized. Did you try to remove the item
    instead of disable it?

    --
    Eduardo A. Morcillo
    http://www.domaindlx.com/e_morcillo
    "Ron" <ron_nospam@ron.com> wrote in message news:3958a155$1@news.devx.com...
    >
    > I tried the following:
    >
    > const SC_MOVE = &HF010&
    >
    > and tried this with the Move command. It had no effect. Same with

    maximize,
    > etc
    >
    > "Eduardo A. Morcillo" <e_morcillo@yahoo.com> wrote:
    > >Use the EnableMenuItem api:
    > >
    > >Declare Function EnableMenuItem Lib "user32" ( _
    > > ByVal hMenu As Long, _
    > > ByVal uIDEnableItem As Long, _
    > > ByVal uEnable As Long) As Long
    > >
    > >
    > >' Enable the item
    > >hMenu = GetSystemMenu(Me.hwnd, 0)
    > >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > > MF_ENABLED
    > >
    > >' Disable the item
    > >hMenu = GetSystemMenu(Me.hwnd, 0)
    > >EnableMenuItem hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or _
    > > MF_DISABLED
    > >
    > >HTH
    > >--
    > >Eduardo A. Morcillo
    > >http://www.domaindlx.com/e_morcillo
    > >"ron" <ron_nospam@ron.com> wrote in message

    news:3957b5e7$1@news.devx.com...
    > >>
    > >> For an MDI Child, I am trying to modify the system menu so that the

    "Next"
    > >> menu command is disabled.
    > >>
    > >> I have the following code in a module:
    > >>
    > >> Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA"

    (ByVal
    > >> hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long, ByVal

    > >uIDNewItem
    > >> As Long, ByVal lpNewItem As String) As Long
    > >> Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,

    > >ByVal
    > >> bRevert As Long) As Long
    > >>
    > >> Const MF_BYCOMMAND = &H0&
    > >> Const MF_GRAYED = &H1&
    > >> Const SC_NEXTWINDOW = &HF040&
    > >>
    > >>
    > >> in the command_click of of a button i have:
    > >>
    > >>
    > >> hMenu = GetSystemMenu(Me.hwnd, 0)
    > >> iRet = ModifyMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND Or MF_GRAYED,

    > >SC_NEXTWINDOW,
    > >> "Nex&t" & Chr(9) & "Ctrl+F6")
    > >>
    > >>
    > >> but this does nothing. I have no idea why. Any help is appreciated.
    > >>
    > >> Ron

    > >
    > >

    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center