FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour cRestoStr ( don“t work )
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
cRestoStr ( don“t work )
Posted: Thu Apr 01, 2010 05:00 AM

include "Fivewin.ch"

define RT_HTML MAKEINTRESOURCE(23)

function main()
msginfo( cResToStr("PAGE", RT_HTML ) )
return

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: cRestoStr ( don“t work )
Posted: Fri Apr 02, 2010 02:33 AM

up :roll:

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: cRestoStr ( don“t work )
Posted: Fri Apr 02, 2010 10:48 AM
Lailton,

FWH's cResToStr() source code is very simple so I suggest you to trace it :-)
Code (fw): Select all Collapse
HB_FUNC( CRESTOSTR )   // ( cnResName, cType ) --> cResourceBytes
{
   #ifndef UNICODE
      HRSRC  hRes = FindResource( ( HINSTANCE ) GetResources(),
                    ( LPCSTR ) IF( HB_ISNUM( 1 ), ( LPCSTR ) hb_parnl( 1 ), hb_parc( 1 ) ),
                    ( LPCSTR ) hb_parc( 2 ) );
      HGLOBAL hglb;
   #else
      LPWSTR pW = AnsiToWide( ( char * ) hb_parc( 1 ) );
      HRSRC  hRes = FindResource( ( HINSTANCE ) GetResources(),
                    ( LPWSTR ) IF( ISNUM( 1 ), ( LPWSTR ) hb_parnl( 1 ), pW ),
                    ( LPWSTR ) hb_parc( 2 ) );
      HANDLE hglb;
   
      _xfree( pW );
   #endif

   if( hRes )
   {
      hglb = LoadResource( ( HINSTANCE ) GetResources(), hRes );

      if( hglb ) // && ! ( GlobalFlags( hglb ) && GMEM_DISCARDED ) )
      {
         hb_retclen( ( LPSTR ) LockResource( hglb ), SizeofResource( GetResources(), hRes ) );
         #ifndef UNICODE
            UnlockResource( hglb );
         #endif
      }
      else
         hb_retc( "" );
   }
   else
      hb_retc( "" );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: cRestoStr ( don“t work )
Posted: Fri Apr 02, 2010 09:30 PM

i tryed more no work.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: cRestoStr ( don“t work )
Posted: Fri Apr 02, 2010 11:07 PM
Lailton,

Change it this way:
Code (fw): Select all Collapse
  if( hRes )
   {
      hglb = LoadResource( ( HINSTANCE ) GetResources(), hRes );

      if( hglb ) // && ! ( GlobalFlags( hglb ) && GMEM_DISCARDED ) )
      {
         hb_retclen( ( LPSTR ) LockResource( hglb ), SizeofResource( GetResources(), hRes ) );
         #ifndef UNICODE
            UnlockResource( hglb );
         #endif
      }
      else
      {
         MessageBox( 0, "Can't load resource", "error", 0 );
         hb_retc( "" );
      }
   }
   else
   {
      MessageBox( 0, "Can't find resource", "error", 0 );
      hb_retc( "" );
   }
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion