Prev: cl options
Next: What is the share mode fopen() uses?
From: Ron Francis on 18 Nov 2009 07:22 "Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote in message news:OMDUCV3ZKHA.196(a)TK2MSFTNGP05.phx.gbl... > "Ron Francis" <ronfrancis(a)adam.com.au> ha scritto nel messaggio > news:O5u96E3ZKHA.5544(a)TK2MSFTNGP02.phx.gbl... > >> Added content at MSDN says: >> "The special behaviour when nBufferMax == 0 applies only to LoadStringW, and not to LoadStringA." >> I was compiling with ANSII. >> >> That's a pity as it would have made it simple. > > Ron: while I agree with you that a uniform behaviour for ANSI/MBCS and Unicode builds would be > better, you could explicitly call LoadStringW, and use CW2A conversion helper class (or similar > tools) to convert from Unicode to ANSI. > > Giovanni > Good thought. Thanks. Ron
From: Serge Wautier on 20 Nov 2009 07:36 I wrote LoadString wrappers based on CString. You should be able to easily adapt the code to std::string. http://www.codeproject.com/KB/string/stringtable.aspx These wrappers also include printf-like one-liners. FormatMessage-like one-liners to be more accurate: If you use the string table, it's probably because you have localization in mind. In most cases, LoadString() is used to load translatable string literals. Whether the wrapper is based on std::string, CString or anything else doesn't matter much since you're not going to manipulate the string anyway (as long as linking with the appropriate library is not an issue). Therefore I think you could use my wrappers without even caring how they are implemented under the hood. Well, not quite true: You have to know how to pass pointers to the raw string to Windows APIs. LPCTSTR(blah) in one case, blah.c_str() in the other case. HTH, Serge. http://www.apptranslator.com - Localization tool for your Windows applications "Ron Francis" <ronfranci(at)adam.com.au> wrote in message news:OvoXuM0YKHA.4148(a)TK2MSFTNGP04.phx.gbl... > I'm finally starting to use the string class rather than char* and I'm > wondering how I would load an LPSTR via LoadString( ) into a string > variable? > > Regards, > Ron Francis > www.RonaldFrancis.com > > >
From: Ron Francis on 21 Nov 2009 07:01
"Serge Wautier" <serge(a)wautier.nospam.net> wrote in message news:u5qsH4daKHA.1596(a)TK2MSFTNGP06.phx.gbl... >I wrote LoadString wrappers based on CString. You should be able to easily adapt the code to >std::string. > > http://www.codeproject.com/KB/string/stringtable.aspx > > These wrappers also include printf-like one-liners. FormatMessage-like one-liners to be more > accurate: If you use the string table, it's probably because you have localization in mind. > > In most cases, LoadString() is used to load translatable string literals. Whether the wrapper is > based on std::string, CString or anything else doesn't matter much since you're not going to > manipulate the string anyway (as long as linking with the appropriate library is not an issue). > Therefore I think you could use my wrappers without even caring how they are implemented under the > hood. Well, not quite true: You have to know how to pass pointers to the raw string to Windows > APIs. LPCTSTR(blah) in one case, blah.c_str() in the other case. > > HTH, > > Serge. > http://www.apptranslator.com - Localization tool for your Windows applications > That looks interesting. Thanks Serge. |