Subj : Re: RC file help To : borland.public.cpp.borlandcpp From : "Jeff Baker" Date : Thu Apr 15 2004 01:12 am Thanks Gary, I wasn't sure if I could do that or not. Thanks for the Version Block example. I think I'll try to figure out how to use the string table on my own before asking but thanks for the offer of an example, I reserve the right to ask later thought :) Best Regards, - Jeff "Gary Setter" wrote in message news:407d5156@newsgroups.borland.com... > > "JBaker0623" wrote in message > news:407c50c4@newsgroups.borland.com... > > I created a dialog box that has a static text field and I want that field > to > > contain a string that is stored in the string table. I would also like to > > use the VERSIONINFO BLOCK but I'll try to figure that out later. The > program > > will compile (so everything is defined properly in the resource.h file) > but > > the static box is empty when run. Here is what I have so far... > > > > IDE/Compiler: Borland C++ 5.02 > > > > IDD_TEST_DIALOG DIALOG 0, 0, 200, 200 > > STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | > > WS_CAPTION | WS_SYSMENU > > CAPTION "Testing Program Info and String table display" > > FONT 8,"Times New Roman" > > { > > CONTROL "Here is the data", IDC_GROUPBOX_01, "button", BS_GROUPBOX | > > BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 195, 195 > > > > CONTROL STRING_TABLE_101, STRING_TABLE_101, "static", SS_LEFT | WS_CHILD > | > > WS_VISIBLE, 10, 10, 180,180 > > } > > > > > > VERSIONINFO_1 VERSIONINFO > > FILEVERSION 1, 0, 0, 0 > > PRODUCTVERSION 1, 0, 0, 0 > > FILEOS VOS_NT_WINDOWS32 > > FILETYPE VFT_APP > > { > > BLOCK "StringFileInfo" > > { > > BLOCK "040904E4" > > { > > VALUE "CompanyName", "Me, Myself and I.\000\000" > > VALUE "FileDescription", "Test Program.\000" > > VALUE "FileVersion", "1.00\000\000" > > VALUE "InternalName", "DialogTest001\000" > > VALUE "LegalCopyright", "Copyright © None 2004\000\000" > > VALUE "OriginalFilename", "DialogTest001.exe\000" > > } > > > > } > > > > BLOCK "VarFileInfo" > > { > > VALUE "Translation", 0x409, 1252 > > } > > > > } > > > > STRINGTABLE > > { > > STRINGTABLE_101,"Hello World" > > } > > > > Any input to my oversight/ignorance? > > > > > 1) How to use a string resource as control text. > Usually, in the SetupWindow function, I load the string and set text of the > control. I don't think you can just put the string resource id into the > definition of the control. Do you need a sample? > > 2)How to use the VERSIONINFO BLOCK > > This is what I use: > class VersionInfoCls > { > public: > VersionInfoCls(); > ~VersionInfoCls(); > bool StringQuery(const char *key, char *& text); > > protected: > void *Block; > UINT Lang; //language code > UINT SubLang; //sub language > }; > > VersionInfoCls::VersionInfoCls() > : Block(0), Lang(0),SubLang(0) > { > UINT word; > DWORD param; > std::auto_ptr path(new char[_MAX_PATH]); > GetModuleFileName(0,path.get(),_MAX_PATH); > int size = GetFileVersionInfoSize(path.get(), ¶m); > if (size) { > Block = new char [size] ; > DWORD *langcodes = 0; //= LANG_USER_DEFAULT > if (GetFileVersionInfo(path.get(),param,size,Block)) { > if (!VerQueryValue(Block,"\\VarFileInfo\\Translation", > (void * *)&langcodes, &word)) > return; > if (!langcodes) > return; > Lang = LOWORD(*langcodes); > SubLang = HIWORD(*langcodes); > } > } > } > > VersionInfoCls::~VersionInfoCls() > { > if (Block) > delete [] Block; > } > > /* > Get a string from a VERSIONINFO block in the rc file. > Return true if successfull. > See the help for VerQueryValue for valid key values. > */ > bool VersionInfoCls::StringQuery(const char *key, char *& text) > { > if (!(Block && Lang && SubLang && key && key[0])) > return false; > UINT word; > char query[255]; > wsprintf(query,"\\StringFileInfo\\%04x%04x\\%s", > Lang,SubLang, key); > return VerQueryValue(Block,query,(void * *)&text, &word); > } > > Then in setup code for the the dialog, I do something like this: > > VersionInfoCls info; > if (info.StringQuery("FileVersion",text)) { > versionCtrl.SetText(text); > } > > Hope that helps, > Gary > .