Bool WQuerySaveSym( WMenuEditInfo *einfo, Bool force_exit ) { int ret; UINT style; char *title; char *text; if( einfo == NULL || !einfo->info->stand_alone ) { return( TRUE ); } if( !WRIsHashTableDirty( einfo->info->symbol_table ) ) { return( TRUE ); } if( force_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } title = WCreateEditTitle( einfo ); text = WAllocRCString( W_UPDATEMODIFIEDSYM ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { WFreeRCString( text ); } if( title != NULL ) { WMemFree( title ); } if( ret == IDYES ) { if( einfo->info->symbol_file == NULL ) { char *fname; if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } einfo->info->symbol_file = WCreateSymName( fname ); } return( WSaveSymbols( einfo, einfo->info->symbol_table, &einfo->info->symbol_file, FALSE ) ); } else if( ret == IDCANCEL ) { return( FALSE ); } return( TRUE ); }
Bool WREQuerySaveSymOnDeleteRes( WREResInfo *res_info, Bool fatal_exit ) { int ret; UINT style; char *text; char *file; HWND frame; if( WRENoInterface ) { return( TRUE ); } if( res_info == NULL || res_info->symbol_table == NULL ) { return( TRUE ); } if( WRIsHashTableDirty( res_info->symbol_table ) ) { if( fatal_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } WRECheckIfActiveWindow(); frame = WREGetMDIWindowHandle(); SendMessage( frame, WM_MDIRESTORE, (WPARAM)res_info->res_win, 0 ); SendMessage( frame, WM_MDIACTIVATE, (WPARAM)res_info->res_win, 0 ); file = WREGetQueryName( res_info ); text = WREAllocRCString( WRE_SAVEMODIFIEDSYM ); ret = MessageBox( res_info->res_win, text, file, style ); if( text != NULL ) { WREFreeRCString( text ); } if( ret == IDYES ) { if( res_info->symbol_file == NULL ) { res_info->symbol_file = WRECreateSymName( file ); } if( !WRESaveSymbols( res_info->symbol_table, &res_info->symbol_file, FALSE ) ) { return( FALSE ); } } else if( ret == IDCANCEL ) { return( FALSE ); } } return( TRUE ); }
Bool WHandleWM_CLOSE( WMenuEditInfo *einfo, Bool force_exit ) { Bool ret; ret = TRUE; if( einfo != NULL ) { if( einfo->info->modified || WRIsHashTableDirty( einfo->info->symbol_table ) ) { ret = WQuerySave( einfo, force_exit ); } if( ret ) { SendMessage( einfo->info->parent, MENU_I_HAVE_CLOSED, 0, (LPARAM)einfo->hndl ); WUnRegisterEditSession( WGetEditSessionHandle( einfo ) ); } } return( ret ); }
Bool WRESaveResource( WREResInfo *res_info, Bool get_name ) { char *fn; WREGetFileStruct gf; int fn_offset; Bool got_name; Bool ok; fn_offset = 0; got_name = FALSE; ok = (res_info != NULL && res_info->info != NULL); if( ok ) { ok = (WRCountZeroLengthResources( res_info->info->dir ) == 0); if( !ok ) { WREDisplayErrorMsg( WRE_UPDATEBEFORESAVE ); } } if( ok ) { if( res_info->info->save_name != NULL ) { fn = res_info->info->save_name; } else { res_info->info->save_type = res_info->info->file_type; fn = WREStrDup( res_info->info->file_name ); got_name = TRUE; } if( get_name || fn == NULL || *fn == '\0' ) { gf.file_name = fn; gf.title = WREResSaveTitle; gf.filter = WREResFilter; gf.save_ext = TRUE; fn = WREGetSaveFileName( &gf ); got_name = TRUE; res_info->info->save_type = WR_DONT_KNOW; } ok = (fn != NULL && *fn != '\0'); } if( ok ) { if( got_name && res_info->info->save_name != NULL ) { WREMemFree( res_info->info->save_name ); } res_info->info->save_name = fn; if( res_info->info->save_type == WR_DONT_KNOW ) { res_info->info->save_type = WRESelectFileType( fn, res_info->is32bit ); } ok = (res_info->info->save_type != WR_DONT_KNOW); } if( ok ) { if( WRIsHashTableDirty( res_info->symbol_table ) ) { if( res_info->symbol_file == NULL ) { res_info->symbol_file = WRECreateSymName( fn ); } } } if( ok ) { WRECreateDLGInclude( &res_info->info->dir, res_info->symbol_file ); ok = WRESaveResourceToFile( res_info ); if( !ok ) { WREDisplayErrorMsg( WRE_SAVEFAILED ); } } if( ok ) { if( get_name || WRIsHashTableDirty( res_info->symbol_table ) ) { ok = WRESaveSymbols( res_info->symbol_table, &res_info->symbol_file, get_name ); } } if( ok ) { //fn_offset = WRFindFnOffset( fn ); SendMessage( res_info->res_win, WM_SETTEXT, 0, (LPARAM)(LPSTR)&fn[fn_offset] ); } return( ok ); }
bool WSaveObject( WAccelEditInfo *einfo, bool get_name, bool save_into ) { bool ok, data_saved; void *old_data; size_t old_size; data_saved = FALSE; WSetWaitCursor( einfo->win, TRUE ); ok = (einfo != NULL); if( ok ) { if( einfo->info->res_name == NULL ) { WDisplayErrorMsg( W_RESHASNONAME ); ok = false; } else { if( !WRIsDefaultHashTable( einfo->info->symbol_table ) && (get_name || WRIsHashTableDirty( einfo->info->symbol_table )) ) { if( einfo->info->symbol_file == NULL ) { char *fname; if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } einfo->info->symbol_file = WCreateSymName( fname ); } ok = WSaveSymbols( einfo, einfo->info->symbol_table, &einfo->info->symbol_file, get_name ); } if( ok ) { old_data = einfo->info->data; old_size = einfo->info->data_size; data_saved = TRUE; WMakeDataFromAccelTable( einfo->tbl, &einfo->info->data, &einfo->info->data_size ); ok = (einfo->info->data != NULL && einfo->info->data_size != 0); if( !ok ) { WDisplayErrorMsg( W_ACCELISEMPTY ); } else { if( save_into ) { ok = WSaveObjectInto( einfo ); } else { ok = WSaveObjectAs( get_name, einfo ); } if( einfo->info->data != NULL ) { WRMemFree( einfo->info->data ); einfo->info->data = NULL; einfo->info->data_size = 0; } } } } } if( ok && einfo->info->stand_alone ) { einfo->info->modified = false; } if( data_saved ) { einfo->info->data = old_data; einfo->info->data_size = old_size; } WSetWaitCursor( einfo->win, FALSE ); return( ok ); }