We have have enhanced that code, so you can manage it from PRG level and have full control on it:
rescheck.prg
- Code: Select all Expand view
static aResources := {}
//----------------------------------------------------------------------------//
function PalBmpFree( hBmp, hPal )
DeleteObject( hBmp )
DeleteObject( hPal )
return nil
//----------------------------------------------------------------------------//
function AddResource( nHResource, cType )
AAdd( aResources, { cType, nHResource, ProcName( 3 ), ProcLine( 3 ) } )
return nil
//----------------------------------------------------------------------------//
function DelResource( nHResource )
local nAt
if ( nAt := AScan( aResources, { | aRes | aRes[ 2 ] == nHResource } ) ) != 0
ADel( aResources, nAt )
ASize( aResources, Len( aResources ) - 1 )
endif
return nil
//----------------------------------------------------------------------------//
function CheckRes()
local cInfo := "", n
for n = 1 to Len( aResources )
cInfo += aResources[ n, 1 ] + "," + Chr( 9 ) + Str( aResources[ n, 2 ] ) + "," + Chr( 9 ) + ;
aResources[ n, 3 ] + "," + Chr( 9 ) + Str( aResources[ n, 4 ] ) + CRLF
next
MsgInfo( cInfo )
return nil
//----------------------------------------------------------------------------//
#pragma BEGINDUMP
#include <hbapi.h>
#include <hbapiitm.h>
#include <hbvm.h>
#include <windows.h>
void RegisterResource( HANDLE hRes, LPSTR szType )
{
PHB_ITEM pRet = hb_itemNew( hb_param( -1, HB_IT_ANY ) );
hb_vmPushSymbol( hb_dynsymGetSymbol( "ADDRESOURCE" ) );
hb_vmPushNil();
hb_vmPushLong( ( LONG ) hRes );
hb_vmPushString( szType, strlen( szType ) );
hb_vmFunction( 2 );
hb_itemReturnRelease( pRet );
}
void pascal DelResource( HANDLE hResource )
{
PHB_ITEM pRet = hb_itemNew( hb_param( -1, HB_IT_ANY ) );
hb_vmPushSymbol( hb_dynsymGetSymbol( "DELRESOURCE" ) );
hb_vmPushNil();
hb_vmPushLong( ( LONG ) hResource );
hb_vmFunction( 1 );
hb_itemReturnRelease( pRet );
}
#pragma ENDDUMP
To check consumed GDI objects in your app, add this function call at the beginning:
- Code: Select all Expand view
SetResDebug()
and when you want to check the GDI objects, simply call:
- Code: Select all Expand view
CheckRes()