www.digitalmars.com         C & C++   DMDScript  

c++.stlsoft - resource_string

reply "Pablo Aguilar" <paguilarg hotmail.com> writes:
Is there or will there be a resource_string that's not dependant on MFC?
May 21 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
There's basic_resource_string in winstl_resource_string.h, which is in the
inprogress directory. I've been using this myself a lot recently (in the shell
extensions just updated at http://shellext.com) and will promote this to the
main
directory for 1.7.1.

It requires a base string to use, e.g. std::string, and you can supply an
exception policy type (otherwise it uses stlsoft::null_exception, which does not
throw, and the string is just empty on failure).

Beware that it does not yet work for UNICODE, but I will make this work before
1.7.1 (which I am hoping to release in the next few days ...).

Good reminder! :-)

"Pablo Aguilar" <paguilarg hotmail.com> wrote in message
news:c8lk6v$r7m$1 digitaldaemon.com...
 Is there or will there be a resource_string that's not dependant on MFC?

May 21 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
I've done it, and added in unit testing (and tested it!). Here's a sneak
preview.

Note: It does work with UNICODE. I was blowing hot air. ;)

"Matthew" <matthew.hat stlsoft.dot.org> wrote in message
news:c8lnhp$10ei$1 digitaldaemon.com...
 There's basic_resource_string in winstl_resource_string.h, which is in the
 inprogress directory. I've been using this myself a lot recently (in the shell
 extensions just updated at http://shellext.com) and will promote this to the

 directory for 1.7.1.

 It requires a base string to use, e.g. std::string, and you can supply an
 exception policy type (otherwise it uses stlsoft::null_exception, which does

 throw, and the string is just empty on failure).

 Beware that it does not yet work for UNICODE, but I will make this work before
 1.7.1 (which I am hoping to release in the next few days ...).

 Good reminder! :-)

 "Pablo Aguilar" <paguilarg hotmail.com> wrote in message
 news:c8lk6v$r7m$1 digitaldaemon.com...
 Is there or will there be a resource_string that's not dependant on MFC?


May 21 2004
parent reply "Pablo Aguilar" <paguilarg hotmail.com> writes:
Thanks!

I've just recently decided not to hard code strings anymore, and this is
coming in real handy...

 I've done it, and added in unit testing (and tested it!). Here's a sneak

 Note: It does work with UNICODE. I was blowing hot air. ;)

May 21 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
Pleasure. :)

"Pablo Aguilar" <paguilarg hotmail.com> wrote in message
news:c8ludf$1ar7$1 digitaldaemon.com...
 Thanks!

 I've just recently decided not to hard code strings anymore, and this is
 coming in real handy...

 I've done it, and added in unit testing (and tested it!). Here's a sneak

 Note: It does work with UNICODE. I was blowing hot air. ;)


May 21 2004
parent reply "Ryan Ginstrom" <ryan ginstrom.com> writes:
I have just starting using stlsoft, and I like it a lot.

A note about basic_resource_string, though.

The Unicode version uses LoadStringW, but that function does not work on
Win9x.

Below my sig is a method I use to ensure that retrieving resource strings as
Unicode works on Win9x platforms, adapted from an MSDN example.

-- 
Regards,
Ryan Ginstrom
ryang gol.com

// Function name : resource2wstring
// Description     : LoadStringW returns NULL on Win9x, so we need this
workaround
inline wstring resource2wstring( const UINT uid, const HINSTANCE instance )
{
 UINT block = (uid >> 4) + 1;   // Compute block number.
 UINT num = uid & 0xf;      // Compute offset into block.

 HRSRC hRC = FindResourceEx( instance,
  RT_STRING,
  MAKEINTRESOURCE(block),
  MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));

 if ( hRC == NULL )
  return wstring() ;

 HGLOBAL hgl = LoadResource(instance, hRC);

 if ( hgl == NULL )
  return wstring() ;

 LPWSTR res_str = (LPWSTR)LockResource(hgl);

 if ( res_str == NULL )
  return wstring() ;

 for ( UINT i = 0; i < num; i++)
 {
  res_str += *res_str + 1;
 }

 return wstring( res_str + 1,  *res_str );
}
Dec 11 2004
next sibling parent reply "Matthew" <admin stlsoft.dot.dot.dot.dot.org> writes:
"Ryan Ginstrom" <ryan ginstrom.com> wrote in message
news:cpgjpd$11ps$1 digitaldaemon.com...
 I have just starting using stlsoft, and I like it a lot.

Great! May I ask how/from whom you heard about it?
 A note about basic_resource_string, though.

 The Unicode version uses LoadStringW, but that function does not work

 Win9x.

 Below my sig is a method I use to ensure that retrieving resource

 Unicode works on Win9x platforms, adapted from an MSDN example.

Ok. I'll check it out, and have a think about it. Assuming it's the go, how would you feel about my incorporating this into a future release? Naturally your input would be suitably credited. Cheers Matthew
 Regards,
 Ryan Ginstrom
 ryang gol.com

 // Function name : resource2wstring
 // Description     : LoadStringW returns NULL on Win9x, so we need

 workaround
 inline wstring resource2wstring( const UINT uid, const HINSTANCE

 {
  UINT block = (uid >> 4) + 1;   // Compute block number.
  UINT num = uid & 0xf;      // Compute offset into block.

  HRSRC hRC = FindResourceEx( instance,
   RT_STRING,
   MAKEINTRESOURCE(block),
   MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));

  if ( hRC == NULL )
   return wstring() ;

  HGLOBAL hgl = LoadResource(instance, hRC);

  if ( hgl == NULL )
   return wstring() ;

  LPWSTR res_str = (LPWSTR)LockResource(hgl);

  if ( res_str == NULL )
   return wstring() ;

  for ( UINT i = 0; i < num; i++)
  {
   res_str += *res_str + 1;
  }

  return wstring( res_str + 1,  *res_str );
 }

Dec 12 2004
parent reply "Ryan Ginstrom" <ryan ginstrom.com> writes:
"Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message
news:cpidmd$2sut$1 digitaldaemon.com...
 "Ryan Ginstrom" <ryan ginstrom.com> wrote in message
 I have just starting using stlsoft, and I like it a lot.

May I ask how/from whom you heard about it?

I actually heard about stlsoft a while ago (I have version 1.6.5 sitting on my hard disk), but just recently started using it after reading your description of it in your article on C# performance. That article spurred me to take a closer look at the library, and I'm very glad I did. There is lots of great stuff in there, and it actually works! <g>
 Below my sig is a method I use to ensure that retrieving resource

 Unicode works on Win9x platforms, adapted from an MSDN example.

Ok. I'll check it out, and have a think about it. Assuming it's the go, how would you feel about my incorporating this into a future release? Naturally your input would be suitably credited.

I don't mind all, but as I mentioned it is adapted from an MSDN example, not original. -- Regards, Ryan Ginstrom ryang gol.com
Dec 12 2004
parent reply "Matthew" <admin.hat stlsoft.dot.org> writes:
"Ryan Ginstrom" <ryan ginstrom.com> wrote in message
news:cpii35$30mp$1 digitaldaemon.com...
 "Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message
 news:cpidmd$2sut$1 digitaldaemon.com...
 "Ryan Ginstrom" <ryan ginstrom.com> wrote in message
 I have just starting using stlsoft, and I like it a lot.

May I ask how/from whom you heard about it?

I actually heard about stlsoft a while ago (I have version 1.6.5 sitting on my hard disk), but just recently started using it after reading your description of it in your article on C# performance. That article spurred me to take a closer look at the library, and I'm very glad I did. There is lots of great stuff in there, and it actually works! <g>

Well, that's because I use it a lot, I guess. It's a much easier task to create a library that works when its author uses it. ;-) The one Achilles heal for STLSoft is the lamentable documentation. I am hoping to get time to address that soon, but it's always dragging behind new components, and new sub-projects (of which I have three planned for release soon: ACESTL, DbSTL, XMLSTL)
 Below my sig is a method I use to ensure that retrieving resource

 Unicode works on Win9x platforms, adapted from an MSDN example.

Ok. I'll check it out, and have a think about it. Assuming it's the go, how would you feel about my incorporating this into a future release? Naturally your input would be suitably credited.

I don't mind all, but as I mentioned it is adapted from an MSDN example, not original.

Understood. Thanks again. Feel free to post requests/bugs/criticisms here, or email them to me directly. Cheers Matthew
Dec 12 2004
parent "Ryan Ginstrom" <ryan ginstrom.com> writes:
"Matthew" <admin.hat stlsoft.dot.org> wrote in message
news:cpin60$4mg$1 digitaldaemon.com...
 The one Achilles heal for STLSoft is the lamentable documentation. I am

 it's always dragging behind new components, and new sub-projects (of which

 ACESTL, DbSTL, XMLSTL)

Documentation would be nice (as would a good XML parser/writer). I am no one to talk though, being rather poor at writing documentation myself. Luckily though, the various classes can generally just be dropped in and used without too much fuss. I just checked out the resource_string implementation because I have been bitten by this problem before. -- Regards, Ryan Ginstrom ryang gol.com
Dec 12 2004
prev sibling parent "Matthew" <admin.hat stlsoft.dot.org> writes:
Ryan

I've finally incorporated this. Sorry for the delay.

It'll be in 1.8.3 beta5, which will probably be sometime this week or next.
When you get a chance, it'd be great if you 
can check it out on 9x. I've tested it by 'pretenting' to be 9x on XP, but some
finite doubt remains until it's tested 
on a real 9x system.

Thanks again for the insight. I've mentioned you in the
(winstl_resource_string.h) file header, and also in the Doxygen 
stuff. I've amended the copyright to now say:

 * Home:        http://stlsoft.org/
 *
 * Copyright 1994-2005, Matthew Wilson and Synesis Software
 * Copyright 2004-2005, Ryan Ginstrom


Cheers, and thanks again

Matthew


"Ryan Ginstrom" <ryan ginstrom.com> wrote in message
news:cpgjpd$11ps$1 digitaldaemon.com...
I have just starting using stlsoft, and I like it a lot.

 A note about basic_resource_string, though.

 The Unicode version uses LoadStringW, but that function does not work on
 Win9x.

 Below my sig is a method I use to ensure that retrieving resource strings as
 Unicode works on Win9x platforms, adapted from an MSDN example.

 -- 
 Regards,
 Ryan Ginstrom
 ryang gol.com

 // Function name : resource2wstring
 // Description     : LoadStringW returns NULL on Win9x, so we need this
 workaround
 inline wstring resource2wstring( const UINT uid, const HINSTANCE instance )
 {
 UINT block = (uid >> 4) + 1;   // Compute block number.
 UINT num = uid & 0xf;      // Compute offset into block.

 HRSRC hRC = FindResourceEx( instance,
  RT_STRING,
  MAKEINTRESOURCE(block),
  MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));

 if ( hRC == NULL )
  return wstring() ;

 HGLOBAL hgl = LoadResource(instance, hRC);

 if ( hgl == NULL )
  return wstring() ;

 LPWSTR res_str = (LPWSTR)LockResource(hgl);

 if ( res_str == NULL )
  return wstring() ;

 for ( UINT i = 0; i < num; i++)
 {
  res_str += *res_str + 1;
 }

 return wstring( res_str + 1,  *res_str );
 }
 

Mar 21 2005