cRestoStr ( don´t work )

cRestoStr ( don´t work )

Postby lailton.webmaster » Thu Apr 01, 2010 5:00 am

#include "Fivewin.ch"
#define RT_HTML MAKEINTRESOURCE(23)
function main()
msginfo( cResToStr("PAGE", RT_HTML ) )
return
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: cRestoStr ( don´t work )

Postby lailton.webmaster » Fri Apr 02, 2010 2:33 am

up :roll:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: cRestoStr ( don´t work )

Postby Antonio Linares » Fri Apr 02, 2010 10:48 am

Lailton,

FWH's cResToStr() source code is very simple so I suggest you to trace it :-)
Code: Select all  Expand view  RUN

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: cRestoStr ( don´t work )

Postby lailton.webmaster » Fri Apr 02, 2010 9:30 pm

i tryed more no work.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: cRestoStr ( don´t work )

Postby Antonio Linares » Fri Apr 02, 2010 11:07 pm

Lailton,

Change it this way:
Code: Select all  Expand view  RUN

  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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 74 guests