Bool WREGetCurrentResource( WRECurrentResInfo *current ) { WRETypeName *tn; Bool ok; HWND resLbox; LRESULT index; ok = (current != NULL); if( ok ) { current->type = NULL; current->res = NULL; current->lang = NULL; current->info = WREGetCurrentRes(); ok = (current->info != NULL && current->info->info != NULL && current->info->info->dir != NULL); } if( ok ) { tn = WREGetTypeNameFromRT( current->info->current_type ); ok = (tn != NULL); } if( ok ) { current->type = WREFindTypeNode( current->info->info->dir, tn->type, NULL ); ok = (current->type != NULL); } if( ok ) { resLbox = GetDlgItem( current->info->info_win, IDM_RNRES ); ok = (resLbox != (HWND)NULL); } if( ok ) { index = SendMessage( resLbox, LB_GETCURSEL, 0, 0 ); ok = (index != LB_ERR); } if( ok ) { current->lang = (WResLangNode *)SendMessage( resLbox, LB_GETITEMDATA, (WPARAM)index, 0 ); ok = (current->lang != NULL); } if( ok ) { current->res = WREFindResNodeFromLangNode( current->type, current->lang ); ok = (current->res != NULL); } return( ok ); }
static void startEditors( void ) { WRFileType ftype; WREResInfo *res_info; Bool editor_started; Bool ret; int num_types; uint_16 type; if( WREGetNumRes() != 1 ) { if( WRENoInterface ) { WREDisplayErrorMsg( WRE_INVALIDINPUTFILE ); PostMessage( WREMainWin, WM_CLOSE, 0, 0 ); } return; } editor_started = FALSE; num_types = 0; res_info = WREGetCurrentRes(); ftype = res_info->info->file_type; if( res_info->info->file_name == NULL ) { ftype = WRIdentifyFile( res_info->info->save_name ); } else { num_types = res_info->info->dir->NumTypes; } if( ftype != WR_WIN_RC_STR && ftype != WR_WIN_RC_MENU && ftype != WR_WIN_RC_ACCEL ) { if( WRENoInterface ) { if( !editor_started ) { WREDisplayErrorMsg( WRE_INVALIDINPUTFILE ); PostMessage( WREMainWin, WM_CLOSE, 0, 0 ); } } return; } if( num_types == 1 || num_types == 2 ) { ret = FALSE; type = 0; if( ftype == WR_WIN_RC_STR ) { type = (uint_16)RT_STRING; } else if( ftype == WR_WIN_RC_MENU ) { type = (uint_16)RT_MENU; } else if( ftype == WR_WIN_RC_ACCEL ) { type = (uint_16)RT_ACCELERATOR; } if( type != 0 && WREFindTypeNode( res_info->info->dir, type, NULL ) ) { ret = WRESetResNamesFromType( res_info, type, FALSE, NULL, 0 ); if( ret ) { editor_started = WREHandleResEdit(); } } } else if( num_types == 0 ) { if( ftype == WR_WIN_RC_STR ) { editor_started = WRENewStringResource(); } else if( ftype == WR_WIN_RC_MENU ) { editor_started = WRENewMenuResource(); } else if( ftype == WR_WIN_RC_ACCEL ) { editor_started = WRENewAccelResource(); } } if( WRENoInterface ) { if( !editor_started ) { WREDisplayErrorMsg( WRE_INVALIDINPUTFILE ); PostMessage( WREMainWin, WM_CLOSE, 0, 0 ); } } }
Bool pleaseOpenFile( UINT msg ) { char *filter; char *title; char *name; WREResInfo *res_info; WREResInfo *old_info; WREGetFileStruct gf; uint_16 type; Bool ok; old_info = WREGetCurrentRes(); res_info = NULL; filter = NULL; title = NULL; name = NULL; if( msg == ACCEL_PLEASE_OPENME ) { filter = WREAccelFilter; title = WREAllocRCString( WRE_OPENACCEL ); type = (uint_16)RT_ACCELERATOR; } else if( msg == MENU_PLEASE_OPENME ) { filter = WREMenuFilter; title = WREAllocRCString( WRE_OPENMENU ); type = (uint_16)RT_MENU; } else if( msg == STRING_PLEASE_OPENME ) { filter = WREStringFilter; title = WREAllocRCString( WRE_OPENSTRING ); type = (uint_16)RT_STRING; } ok = (filter != NULL && title != NULL); if( ok ) { gf.file_name = NULL; gf.title = title; gf.filter = filter; gf.save_ext = FALSE; ok = ((name = WREGetOpenFileName( &gf )) != NULL); } if( ok ) { ok = ((res_info = WRELoadResource( name )) != NULL); } if( ok ) { WREFindAndLoadSymbols( res_info ); ok = WRECreateResourceWindow( res_info ); } if( ok ) { ListAddElt( &WREResList, (void *)res_info ); } if( ok ) { ok = (WREFindTypeNode( res_info->info->dir, type, NULL ) != NULL); } if( ok ) { ok = WRESetResNamesFromType( res_info, type, FALSE, NULL, 0 ); } if( ok ) { ok = WREHandleResEdit(); } if( ok ) { SendMessage( old_info->res_win, WM_CLOSE, 0, 0 ); } if( !ok ) { if( res_info != NULL ) { WREFreeResInfo( res_info ); res_info = NULL; } } if( name != NULL ) { WREMemFree( name ); } if( title != NULL ) { WREFreeRCString( title ); } return( ok ); }