Results 1 to 6 of 6

Thread: a common error message please!

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    a common error message please!

    I get this message lots of time when I am playing around with the API functions:


    code]
    error C2664: 'SetMenuDefaultItem' : cannot convert parameter 2 from 'struct HMENU__ *' to 'unsigned int'
    This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    [/code]


    I get this error lots of times when I am working with the menus and backgrounds...stuff like that

    Here is an example of problem that I am having:;

    ----------------------------------------------------------------------------

    I want to make a menu item bold by first selecting a handle to the main menu and then getting a handle to the sub menu. I am using this code to do that but I am getting the above error message:

    SetMenuDefaultItem(hmenu, GetSubMenu(hmenu, 0), true);


    I have defined hemnu as HMENU (it is a global variable)

    Can you please tell me why it is happening and how do I get rid of that erroe message that I often get.
    Baaaaaaaaah

  2. #2
    denniswrenn
    Guest
    Try this:

    Code:
    SetMenuDefaultItem(hMenu, PositionOfItemToBeDefaulted, true);

  3. #3
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    It's because of something called strict mode.
    As the message says, you'll need to use cast.
    For example:
    Code:
    // Instead of:
    SelectObject(MyHDC, MyBrush);
    
    // Use:
    SelectObject(MyHDC, (HGDIOBJ)MyBrush);
    This might also occur on the return value:
    Code:
    // Instead of:
    OldBrush = SelectObject(MyHDC, (HGDIOBJ)MyBrush);
    
    // Use:
    OldBrush = (HBRUSH)SelectObject(MyHDC, (HGDIOBJ)MyBrush);

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    thanks but..

    Code:
    SetMenuDefaultItem(hMenu, PositionOfItemToBeDefaulted, true);
    [

    That does not worky properly. When I put 0, it makes the file menu (just the first header menu) bold. And when I try 1, it does not make the sub menu bold.
    Baaaaaaaaah

  5. #5
    denniswrenn
    Guest
    I've never used it before, so I'm not quite sure, but I think you have to do this.

    Code:
    SetMenuDefaultItem(hSubMenu, PositionOfItemToBeDefaulted, true);

  6. #6

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    It works now

    It works now.
    Just another question:

    How do I know the menuitem postion and the submenu item position when the mouse moves over it.
    Baaaaaaaaah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width