|
-
Jul 7th, 2001, 03:31 AM
#1
Thread Starter
PowerPoster
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.
-
Jul 7th, 2001, 03:55 AM
#2
Try this:
Code:
SetMenuDefaultItem(hMenu, PositionOfItemToBeDefaulted, true);
-
Jul 7th, 2001, 03:57 AM
#3
Guru
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);
-
Jul 7th, 2001, 01:16 PM
#4
Thread Starter
PowerPoster
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.
-
Jul 7th, 2001, 01:48 PM
#5
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);
-
Jul 7th, 2001, 01:57 PM
#6
Thread Starter
PowerPoster
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|