Connecting Tech Pros Worldwide Forums | Help | Site Map

Accelerator Resources

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#1: Apr 6 '07
Okay, so the tutorial I'm using is creating Accelerator (Keyboard shortcuts) resources using Visual C++. I'm using DevC++ and was unable to find a similar function in their resource editor. So what I did was copy that part of his resource file.
Expand|Select|Wrap|Line Numbers
  1. IDR_ACCELERATOR1 ACCELERATORS 
  2. BEGIN
  3.     VK_F4,          ID_ACC_F4,              VIRTKEY, NOINVERT
  4.     VK_RETURN,      ID_ACC_ENTER,           VIRTKEY, NOINVERT
  5. END
I'm getting a parse error for the line after BEGIN.

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#2: Apr 9 '07

re: Accelerator Resources


Just thought I'd give this a bump.
Member
 
Join Date: Apr 2007
Location: Malaysia
Posts: 55
#3: Apr 11 '07

re: Accelerator Resources


I don't understand what you doing here because i am a newbie. I would like to learn from you.

Thanks for oyur explanation.


Your help is greatly appreciated by me and others.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#4: Apr 12 '07

re: Accelerator Resources


I've been looking on google but I've yet to find anything useful.

I tried copying over the tutorial's source files but I had to remove a lot of the stuff in resouce file that he didn't include in his files. I still got a parse error on that line.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#5: Apr 16 '07

re: Accelerator Resources


Bumping the thread.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#6: Apr 18 '07

re: Accelerator Resources


I'm not sure if there's no replies because no one knows the answer or because everyone thinks I'm already getting helped because of how many replies there are.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#7: Apr 25 '07

re: Accelerator Resources


I'm gonna post another thread linking this one because I don't think anyone's actually looking at this thread.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#8: Apr 25 '07

re: Accelerator Resources


Accelerator Resources

The link is to a thread that I haven't received a response to. Thanks.
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,392
#9: Apr 26 '07

re: Accelerator Resources


I wasn't looking at this thread until I saw a double post! Shame, shame, Rabbit you should know better!

I suspect that DevC++ or whatever you are using doesn't know what VK_F4 is and that is your problem.
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,392
#10: Apr 26 '07

re: Accelerator Resources


Another thought occurs to me... have you compared the resource files of Visual Studio with the resource files of whatever you are looking at? Perhaps the syntax is slightly different. Or is Dev c++ strictly an IDE?
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#11: Apr 26 '07

re: Accelerator Resources


Quote:

Originally Posted by RedSon

I wasn't looking at this thread until I saw a double post! Shame, shame, Rabbit you should know better!

I suspect that DevC++ or whatever you are using doesn't know what VK_F4 is and that is your problem.

LOL, had to get attention for the unnoticed thread.

At least I waited half a month before double posting :)

I thought it may be that the syntax is different across the IDEs but I couldn't find an example for DevC++ so I really have no idea which part of the syntax is wrong.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#12: Apr 26 '07

re: Accelerator Resources


Quote:

Originally Posted by RedSon

Another thought occurs to me... have you compared the resource files of Visual Studio with the resource files of whatever you are looking at? Perhaps the syntax is slightly different. Or is Dev c++ strictly an IDE?

As far as I can tell, the syntax is the same for the most part, i.e. I copied the Visual C++ resource file and it likes most of it except for a couple of things.

1) The accerlerator syntax

2) There are some Includes in the Visual C++ Resource file that were not included in the tutorial package so I removed those, in which case everything works except for the Accelerators.

Only conclusion I can make is either the DevC++ syntax is different or those include files were Visual C++ only and were needed for the accelerators to work.

Edit: As far as I can tell from other examples I found online, they used the same syntax as the Visual C++. Unless of course all the examples were using Visual C++ lol.
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,392
#13: Apr 26 '07

re: Accelerator Resources


Quote:

Originally Posted by Rabbit

As far as I can tell, the syntax is the same for the most part, i.e. I copied the Visual C++ resource file and it likes most of it except for a couple of things.

1) The accerlerator syntax

2) There are some Includes in the Visual C++ Resource file that were not included in the tutorial package so I removed those, in which case everything works except for the Accelerators.

Only conclusion I can make is either the DevC++ syntax is different or those include files were Visual C++ only and were needed for the accelerators to work.

Edit: As far as I can tell from other examples I found online, they used the same syntax as the Visual C++. Unless of course all the examples were using Visual C++ lol.

So does DevC++ have resource editors? If so can you make a new res and see what it looks like. Its gotta be that DevC++ doesnt understand what some of those constants are.
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,167
#14: Apr 26 '07

re: Accelerator Resources


I have merged the threads so that this thread has it's context.

lets start with the basics in the line

Expand|Select|Wrap|Line Numbers
  1.     VK_F4,          ID_ACC_F4,              VIRTKEY, NOINVERT
  2.     VK_RETURN,      ID_ACC_ENTER,           VIRTKEY, NOINVERT
  3.  
VK_F4 is defined in the windows headers (winuser.h) and VIRTKEY and NOINVERT are keywords used by the resource compiler.

ID_ACC_F4 is a symbol that must be #defined by you in a header somewhere.

So are you sure that you have defined ID_ACC_F4 somewhere and that that file is #included into the resource file?
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#15: Apr 26 '07

re: Accelerator Resources


Quote:

Originally Posted by RedSon

So does DevC++ have resource editors? If so can you make a new res and see what it looks like. Its gotta be that DevC++ doesnt understand what some of those constants are.

Yes DevC++ has a resource editor but it doesn't have an option to create an accelerator like Visual C++ does.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#16: Apr 26 '07

re: Accelerator Resources


The only difference from my source files and the tutorial's source files is the resource file and the resource.h file.

Below is the tutorials resource file. I #included "resource.h" in mines as well. I excluded everything after that until the the bitmap because 1) I have no idea what afxres.h was, it was never included in the tutorial files and the tutorial never went over it and 2) The same goes for all the APS Studio stuff.

I included everything from the bitmap to the accelerators. Everything after that doesn't seem to do anything anyways. Everything else works except for the accelerators.
Expand|Select|Wrap|Line Numbers
  1. // Microsoft Visual C++ generated resource script.
  2. //
  3. #include "resource.h"
  4.  
  5. #define APSTUDIO_READONLY_SYMBOLS
  6. /////////////////////////////////////////////////////////////////////////////
  7. //
  8. // Generated from the TEXTINCLUDE 2 resource.
  9. //
  10. #include "afxres.h"
  11.  
  12. /////////////////////////////////////////////////////////////////////////////
  13. #undef APSTUDIO_READONLY_SYMBOLS
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // English (U.S.) resources
  17.  
  18. #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
  19. #ifdef _WIN32
  20. LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
  21. #pragma code_page(1252)
  22. #endif //_WIN32
  23.  
  24. #ifdef APSTUDIO_INVOKED
  25. /////////////////////////////////////////////////////////////////////////////
  26. //
  27. // TEXTINCLUDE
  28. //
  29.  
  30. 1 TEXTINCLUDE 
  31. BEGIN
  32.     "resource.h\0"
  33. END
  34.  
  35. 2 TEXTINCLUDE 
  36. BEGIN
  37.     "#include ""afxres.h""\r\n"
  38.     "\0"
  39. END
  40.  
  41. 3 TEXTINCLUDE 
  42. BEGIN
  43.     "\r\n"
  44.     "\0"
  45. END
  46.  
  47. #endif    // APSTUDIO_INVOKED
  48.  
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. //
  52. // Bitmap
  53. //
  54.  
  55. IDB_BITMAP1             BITMAP                  "portscanskin.bmp"
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. //
  59. // Icon
  60. //
  61.  
  62. // Icon with lowest ID value placed first to ensure application icon
  63. // remains consistent on all systems.
  64. IDI_ICON1               ICON                    "icon1.ico"
  65. IDI_ICON2               ICON                    "icon2.ico"
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. //
  69. // Accelerator
  70. //
  71.  
  72. IDR_ACCELERATOR1 ACCELERATORS 
  73. BEGIN
  74.     VK_F4,          ID_ACC_F4,              VIRTKEY, NOINVERT
  75.     VK_RETURN,      ID_ACC_ENTER,           VIRTKEY, NOINVERT
  76. END
  77.  
  78. #endif    // English (U.S.) resources
  79. /////////////////////////////////////////////////////////////////////////////
  80.  
  81.  
  82.  
  83. #ifndef APSTUDIO_INVOKED
  84. /////////////////////////////////////////////////////////////////////////////
  85. //
  86. // Generated from the TEXTINCLUDE 3 resource.
  87. //
  88.  
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. #endif    // not APSTUDIO_INVOKED
  92.  
The only difference between our resource.h files is that the tutorial has the following at the bottom of the file. Again I have no idea as to its function.
Expand|Select|Wrap|Line Numbers
  1. #ifdef APSTUDIO_INVOKED
  2. #ifndef APSTUDIO_READONLY_SYMBOLS
  3. #define _APS_NEXT_RESOURCE_VALUE        108
  4. #define _APS_NEXT_COMMAND_VALUE         40008
  5. #define _APS_NEXT_CONTROL_VALUE         1001
  6. #define _APS_NEXT_SYMED_VALUE           112
  7. #endif
  8. #endif
  9.  
Everything I removed already existed long before the tutorial started on Accelerators and I removed them at that time as well to no ill effect.

The tutorial files also have a couple of .ncb, .suo, .sln, and .aps files that I don't know the purpose of.
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,167
#17: Apr 26 '07

re: Accelerator Resources


Quote:

Originally Posted by Rabbit

The only difference between our resource.h files is that the tutorial has the following at the bottom of the file. Again I have no idea as to its function.

Expand|Select|Wrap|Line Numbers
  1. #ifdef APSTUDIO_INVOKED
  2. #ifndef APSTUDIO_READONLY_SYMBOLS
  3. #define _APS_NEXT_RESOURCE_VALUE        108
  4. #define _APS_NEXT_COMMAND_VALUE         40008
  5. #define _APS_NEXT_CONTROL_VALUE         1001
  6. #define _APS_NEXT_SYMED_VALUE           112
  7. #endif
  8. #endif
  9.  
Everything I removed already existed long before the tutorial started on Accelerators and I removed them at that time as well to no ill effect.

The tutorial files also have a couple of .ncb, .suo, .sln, and .aps files that I don't know the purpose of.

Humpff, I seem to remember talking to you about these #defines before, they should not be the problem.

The .ncb and .aps files are produced by MS DevStudio to hold the state of the project (which files are open, things like that) the .suo and .sln are the files that define the project (a bit like make files) so non of them should be required by Dev C++ which should have its own version of them.
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,167
#18: Apr 26 '07

re: Accelerator Resources


Just found this on SourceForge.net (although it is a bit old), seems you are not the only person to have had problems with the resource compiler (assuming you are using windres)

Quote:
Email Archive: mingw-users (read-only)

[Mingw-users] [mingw - Windows API] RE: windres can't parse my resource correctly
From: SourceForge.net <noreply@so...> - 2005-08-06 20:45
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=3283395
By: ross_ridge

> is any windres option to avoid this problem?

Not that I'm aware of. There's a lot of problems with windres and it's
internationalization support seems to be pretty much hopeless. I've had better
luck using Microsoft's resource compiler (included free in the Platform SDK)
and using windres to convert the compiled resource files (.RES) in to COFF object
files that the GNU linker can deal with.
Though that doesn't always work either.

Ross Ridge
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#19: Apr 26 '07

re: Accelerator Resources


Quote:

Originally Posted by Banfa

Humpff, I seem to remember talking to you about these #defines before, they should not be the problem.

The .ncb and .aps files are produced by MS DevStudio to hold the state of the project (which files are open, things like that) the .suo and .sln are the files that define the project (a bit like make files) so non of them should be required by Dev C++ which should have its own version of them.

Right, so everything I removed I had removed way before accelerators came into play. So I can only assume that the problem is either the syntax is different from Visual C++ and DevC++ or DevC++ does not support accelerators but they seem to be such an important part of window's that I can't really believe that's the issue. Maybe I'll have to contact the DevC++ team.
Reply