Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Win98 GetMenuItemCount returns -1

Win98 GetMenuItemCount returns -1

Scheduled Pinned Locked Moved ATL / WTL / STL
databasewindows-admindebugginghelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ajitatif angajetor
    wrote on last edited by
    #1

    Hi everyone, I have a project with a menu on it and it notifies me by WM_MENUCOMMAND message.I had to do so,because my menu is dynamically created with values read from registry.Anyway,what I'm doing is theorically easy.This is the code for the WM_MENUCOMMAND event handler: HMENU menu = (HMENU)lParam; // m_SystemVersionInfo is got with GetVersionEx,no problem if (m_SystemVersionInfo.dwMajorVersion <= 4) // Windows Me or Lower index = (int)(wParam >> 16); else index = (int)wParam; int nItems = GetMenuItemCount(menu); if (index == nItems - 1) // last item on menu { // do something } else { // do some other thing } the code works fine on Win2K/XP but nItems shows -1 on Win98.the strange thing is GetLastError returns nothing.MSDN says you can not trust GetLastError on Win98 either,so I didn't bother to look up the eroor code (I am unable to debug on Win98). What could make GetMenuItemCount return -1 only on Win98?

    A 1 Reply Last reply
    0
    • A ajitatif angajetor

      Hi everyone, I have a project with a menu on it and it notifies me by WM_MENUCOMMAND message.I had to do so,because my menu is dynamically created with values read from registry.Anyway,what I'm doing is theorically easy.This is the code for the WM_MENUCOMMAND event handler: HMENU menu = (HMENU)lParam; // m_SystemVersionInfo is got with GetVersionEx,no problem if (m_SystemVersionInfo.dwMajorVersion <= 4) // Windows Me or Lower index = (int)(wParam >> 16); else index = (int)wParam; int nItems = GetMenuItemCount(menu); if (index == nItems - 1) // last item on menu { // do something } else { // do some other thing } the code works fine on Win2K/XP but nItems shows -1 on Win98.the strange thing is GetLastError returns nothing.MSDN says you can not trust GetLastError on Win98 either,so I didn't bother to look up the eroor code (I am unable to debug on Win98). What could make GetMenuItemCount return -1 only on Win98?

      A Offline
      A Offline
      ajitatif angajetor
      wrote on last edited by
      #2

      having tried the "excitinnnng" 'MessageBox Debugging' i've come to a conlcusion that the problem is lParam,which supposedly should carry the handle of the menu,does not carry the handle of the menu which it supposedly should carry... to get it clear: win98 can't give the correct menu handle for the message WM_MENUCOMMAND.i am unable to find which handle it shows but certainly it is not the right one. the problem should be that i am creating the menu at runtime,which changes the handle everytime the menu is opened,and dearest win98 can not update the handle.so any function that takes HMENU of the menu returns -1 with GetLastError 0. but i still need to use GetMenuItemInfo to take the string of the menu item at the correct index,but function also requires the HMENU (which win98 can't give correctly). any suggestions,anyone?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups