WdeResInfo *WdeLoadResource( const char *file_name ) { WdeResInfo *res_info; WRFileType file_type; bool ok; WdeSetWaitCursor( TRUE ); ok = ((res_info = WdeAllocResInfo()) != NULL); if( ok ) { file_type = WRIdentifyFile( file_name ); ok = (file_type != WR_INVALID_FILE); } if( ok ) { res_info->info = WRLoadResource( file_name, file_type ); ok = (res_info->info != NULL); } if( ok ) { res_info->dlg_entry = WdeFindTypeNode( res_info->info->dir, RESOURCE2INT( RT_DIALOG ), "DIALOG" ); } if( !ok ) { if( res_info != NULL ) { WdeFreeResInfo( res_info ); res_info = NULL; } } WdeSetWaitCursor( FALSE ); return( res_info ); }
// We really should not reread the file but, alas, time demands // something a little less pristine. int WRRelinkInfo( WRInfo *info ) { char fn_path[_MAX_PATH]; WRInfo *tinfo; int ok; tinfo = NULL; ok = (info != NULL); if( ok ) { if( info->internal_filename != NULL ) { WRGetInternalRESName( info->save_name, fn_path ); } else { strcpy( fn_path, info->save_name ); } ok = WRCopyFileToTemp( info, fn_path ); } if( ok ) { tinfo = WRLoadResource( fn_path, info->save_type ); ok = (tinfo != NULL); } if( ok ) { ok = WRRelinkDir( info->dir, tinfo->dir ); } if( tinfo != NULL ) { WRFreeWRInfo( tinfo ); } return( ok ); }
WREResInfo *WRELoadResource( const char *file_name ) { WRFileType file_type; WREResInfo *res_info; Bool ok; WRESetWaitCursor( TRUE ); ok = ((res_info = WREAllocResInfo()) != NULL); if( ok ) { file_type = WRIdentifyFile( file_name ); ok = (file_type != WR_INVALID_FILE); } if( ok ) { res_info->info = WRLoadResource( file_name, file_type ); ok = (res_info->info != NULL); } if( ok ) { file_type = res_info->info->file_type; if( res_info->info->internal_type != WR_DONT_KNOW ) { file_type = res_info->info->internal_type; } res_info->is32bit = WRIs32Bit( file_type ); } if( ok ) { res_info->symbol_table = WRInitHashTable(); ok = (res_info->symbol_table != NULL); } if( !ok ) { if( res_info != NULL ) { WREFreeResInfo( res_info ); res_info = NULL; } } WRESetWaitCursor( FALSE ); return( res_info ); }
/* * readInResourceFile */ static bool readInResourceFile( char *fullname ) { BYTE *data; uint_32 dsize; WRInfo *info; WRSelectImageInfo *sii; WPI_PROC cb; bool ok; info = NULL; sii = NULL; data = NULL; ok = (fullname != NULL); if( ok ) { info = WRLoadResource( fullname, WR_DONT_KNOW ); ok = (info != NULL); } if( ok ) { cb = _wpi_makeprocinstance( (WPI_PROC)IEHelpCallBack, Instance ); sii = WRSelectImage( HMainWindow, info, cb ); _wpi_freeprocinstance( cb ); ok = (sii != NULL && sii->lnode != NULL); } if( ok ) { if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) { imgType = BITMAP_IMG; data = WRCopyResData( info, sii->lnode ); dsize = sii->lnode->Info.Length; ok = (data != NULL); if( ok ) { ok = WRAddBitmapFileHeader( &data, &dsize ); } } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) { imgType = CURSOR_IMG; ok = WRCreateCursorData( info, sii->lnode, &data, &dsize ); } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) { imgType = ICON_IMG; ok = WRCreateIconData( info, sii->lnode, &data, &dsize ); } else { imgType = UNDEF_IMG; ok = false; } } if( ok ) { if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) { ok = ReadBitmapFromData( data, fullname, info, sii->lnode ); } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) { ok = ReadCursorFromData( data, fullname, info, sii->lnode ); } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) { ok = ReadIconFromData( data, fullname, info, sii->lnode ); } } if( sii != NULL ) { WRFreeSelectImageInfo( sii ); } if( data != NULL ) { MemFree( data ); } return( ok ); } /* readInResourceFile */
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow ) { int ret; int i; int ltype; int stype; bool backup; WRInfo *info; WRFileType ftype; uint_16 mflags; WRSelectImageInfo *sii; #if 0 bool dup; char *data; WResID type; WResID name; #endif hinstCurrent = hinstCurrent; hinstPrevious = hinstPrevious; lpszCmdLine = lpszCmdLine; nCmdShow = nCmdShow; info = NULL; ret = TRUE; WRInit(); if( _argc == 6 ) { ltype = atoi( _argv[2] ); stype = atoi( _argv[4] ); backup = (atoi( _argv[5] ) != 0); if( stype != 0 ) { info = WRLoadResource( _argv[1], ltype ); if( info != NULL ) { info->save_name = _argv[3]; info->save_type = stype; ret = WRSaveResource( info, backup ); } else { ret = FALSE; } } #if 0 } else if( _argc == 2 ) { ret = FALSE; data = WRMemAlloc( 32 ); if( data != NULL ) { for( i = 0; i < 32; i++ ) { data[i] = i; } type.IsName = name.IsName = FALSE; type.ID.Num = 10; name.ID.Num = 200; ret = WRSaveObjectAs( _argv[1], WR_WIN16M_RES, &type, &name, data, 32, 0 ); WRMemFree( data ); } } else if( _argc == 3 ) { ret = FALSE; data = WRMemAlloc( 32 ); if( data != NULL ) { for( i = 0; i < 32; i++ ) { data[i] = i; } type.IsName = name.IsName = FALSE; type.ID.Num = 10; name.ID.Num = 100; ret = WRSaveObjectInto( _argv[1], &type, &name, data, 32, 0, &dup ); WRMemFree( data ); } #endif } else { for( i = 1; i < _argc; i++ ) { WRSelectFileType( HWND_DESKTOP, _argv[i], FALSE, i % 2, NULL ); ftype = WRIdentifyFile( _argv[i] ); } ret = TRUE; } WRChangeMemFlags( HWND_DESKTOP, "test", &mflags, NULL ); if( info != NULL ) { info->save_name = NULL; WRFreeWRInfo( info ); } info = WRLoadResource( _argv[1], WR_DONT_KNOW ); sii = WRSelectImage( HWND_DESKTOP, info, NULL ); if( sii != NULL ) { WRFreeSelectImageInfo( sii ); } WRFreeWRInfo( info ); if( !ret ) { MessageBox( (HWND)NULL, "Error occurred!", "TEST WR", MB_ICONEXCLAMATION | MB_OK | MB_APPLMODAL ); } WRFini(); return( ret ); }