I've seen plenty of examples of updating a resource using UpdateResource().
Has anyone actually used it to add a new resource? For example, a menu
resource. If so, how is it done? I'm not quit sure how to present the raw
data.

Signature
Gort, Klaatu, Barrada Nikto...
> I've seen plenty of examples of updating a resource using
> UpdateResource().
> Has anyone actually used it to add a new resource? For example, a menu
> resource. If so, how is it done? I'm not quit sure how to present the
> raw
> data.
I think you are about to step into one of the darker corners of Win32
programming. I don't want to sound like I am dissuading if you have decided
you must go this way ... but do you know that you can build menus at
runtime? It may be a better option.
If you want to go this route, take a look at this link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/Win
dowsUserInterface/Resources/IntroductiontoResources.asp
It contains this quip in the paragraph on the MENUHEADER structure:
<quote>
The MENUHEADER structure contains version information for the menu resource.
The structure definition provided here is for explanation only; it is not
present in any standard header file.
</quote>
The help entry for the UpdateResource() function points out that you must
pass a pointer to the "raw data" to be used in the update so I think that
you will first have to dump an existing menu resource, determine its binary
format by looking at the header and your resource script, get an idea of the
format, do the update, test and repeat until it works. :-(
Regards,
Will
Klaatu - 09 May 2005 13:56 GMT
William:
Thanks for the advice. Yes, I'm aware that I can create the menus
dynamically. Our current menu structure does just that. The real reason I
need to update resources is for translation issues. Since we don't have menu
resources, and our menu text comes from a string table, I have to provide
them for our language translators. Giving them menu resources provides
context and organization when they use a tool like visual localize.
> > I've seen plenty of examples of updating a resource using
> > UpdateResource().
[quoted text clipped - 28 lines]
> Regards,
> Will
Mihai N. - 10 May 2005 08:04 GMT
> Thanks for the advice. Yes, I'm aware that I can create the menus
> dynamically. Our current menu structure does just that. The real reason I
> need to update resources is for translation issues. Since we don't have menu
> resources, and our menu text comes from a string table, I have to provide
> them for our language translators. Giving them menu resources provides
> context and organization when they use a tool like visual localize.
Why not give the .rc file?
Plus, any localization company worth the name is able to deal with
resources in executables/dlls without you writing any extra tools.

Signature
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Klaatu - 10 May 2005 13:38 GMT
Nice idea, but, our menu resources don't live in the .rc file. They are
built dynamically from strings in the stringtable and an external function
table.
> > Thanks for the advice. Yes, I'm aware that I can create the menus
> > dynamically. Our current menu structure does just that. The real reason I
[quoted text clipped - 6 lines]
> Plus, any localization company worth the name is able to deal with
> resources in executables/dlls without you writing any extra tools.
Mihai N. - 13 May 2005 08:34 GMT
> Nice idea, but, our menu resources don't live in the .rc file. They are
> built dynamically from strings in the stringtable and an external function
> table.
Then you do not need UpdateResource. Just read it from the external file,
build it, and use it.
UpdateResource is to update the menu resource in the executable file.

Signature
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Although I did eventually work through the binary layout of the resources in
the dll, I decided to abandon this approach in favor of writing out an XML
file that contains the menu structure. This resolved my problem since the
translator tool will import xml files.
> I've seen plenty of examples of updating a resource using UpdateResource().
> Has anyone actually used it to add a new resource? For example, a menu
> resource. If so, how is it done? I'm not quit sure how to present the raw
> data.