Archived

This topic is now archived and is closed to further replies.

Jamez

Stupid Windows Programming Question

Recommended Posts

I''m trying to make the simplest menu with Visual C++ 6.0. A "File" menu with one selection "New". I go to the "Project" menu in VC then select "Add to project" then "New...". Next I select "Resource Script". I then open the resource script and add my "File" menu then I add "New" to that menu as well. When I add the "New" menu item I specify an ID for the menu from the drop down list ID_FILE_NEW seems like a logical choice for this menu item so I accept it. The problem is when I compile my code the compiler complains that ID_FILE_NEW is not defined. Why does VC allow you to choose an ID from the drop down menu but then it doesn''t define it for you in resource.h? Anyone else have this problem!? I''m not using MFC by the way.

Share this post


Link to post
Share on other sites
It defines it automatically for me when I do a MFC app. I would think if it generates the .h file with the .rc file it would update them together. So it works after you manually edit the header file?

Share this post


Link to post
Share on other sites
Have you taken a look inside resource.h to be sure it isn''t defined? Furthermore, if you want to use that value in specifying a menu to either a WNDCLASSEX structure or to CreateWindow[Ex], be sure to use MAKEINTRESOURCE.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
Redemption:

Yes it works after I manually edit resource.h with ID_FILE_NEW or I can include "afxres.h" in resource.h and that works as well. There are many symbols like ID_FILE_NEW defined in that header. I think it was intended to be used with MFC primarily frustrating though.. shouldn''t have to edit resource.h for something so simple.

Oluseyi:

Yes I have looked in resource.h and it is not defined. I have also looked in resource.rc where the symbol ID_FILE_NEW is referred to but not defined. I have found that resource.rc includes a header called "afxres.h" which defines ID_FILE_NEW among many other common symbols but for some reason these definitions aren''t made visible to my .cpp code. The MSDN refers to these symbols as read-only but I don''t know what that means exactly. I have to manually include afxres.h in either my source code or the resource.h file for my code to compile. By the way I am using MAKEINTORESOURCE already. All the code is fine except for the reference to ID_FILE_NEW. It''s really been bugging me!

Share this post


Link to post
Share on other sites