LRESULT CALLBACK WREResInfoProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { WREResInfo *info; LRESULT ret; WORD wp; UINT cmd; ret = FALSE; switch( message ) { case WM_INITDIALOG: info = (WREResInfo *)lParam; info->info_win = hDlg; SET_DLGDATA( hDlg, (LONG_PTR)info ); if( !WREInitResourceWindow( info, 0 ) ) { DestroyWindow( hDlg ); } else { ret = TRUE; } break; case WM_SYSCOLORCHANGE: #if defined( __NT__ ) SET_HBRBACKGROUND( hDlg, (HBRUSH)(COLOR_BTNFACE + 1) ); #endif WRECtl3dColorChange(); break; case WM_COMMAND: wp = LOWORD( wParam ); switch( wp ) { case IDM_RNRES: cmd = GET_WM_COMMAND_CMD( wParam, lParam ); if( cmd == LBN_DBLCLK ) { WREHandleResEdit(); } break; case IDM_RNTYPE: info = (WREResInfo *)GET_DLGDATA( hDlg ); cmd = GET_WM_COMMAND_CMD( wParam, lParam ); if( cmd == LBN_SELCHANGE ) { WREAddResNames( info ); } break; } break; } return( ret ); }
bool WRENewResource( WRECurrentResInfo *curr, WResID *tname, WResID *rname, uint_16 memflags, uint_32 offset, uint_32 length, WResLangType *lang, bool *dup, uint_16 type, bool new_type ) { bool ok; ok = (curr != NULL && curr->info != NULL && tname != NULL && rname != NULL && lang != NULL); if( ok && ( curr->info->info->dir == NULL ) ) { ok = ((curr->info->info->dir = WResInitDir()) != NULL); } if( ok ) { ok = !WResAddResource( tname, rname, memflags, offset, length, curr->info->info->dir, lang, dup ); } if( ok ) { ok = (dup == NULL || (dup != NULL && !*dup)); } if( ok ) { if( new_type ) { curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, type ); } else { WRESetResNamesFromType( curr->info, type, TRUE, rname, 0 ); } } if( ok && new_type ) { curr->type = WREFindTypeNodeFromWResID( curr->info->info->dir, tname ); ok = (curr->type != NULL); } if( ok ) { curr->res = WREFindResNodeFromWResID( curr->type, rname ); ok = (curr->res != NULL); } if( ok ) { curr->lang = WREFindLangNodeFromLangType( curr->res, lang ); ok = (curr->lang != NULL); } return( ok ); }
bool WRERemoveEmptyResource( WRECurrentResInfo *curr ) { char *name; int type; bool ok; LRESULT index; HWND res_lbox; name = NULL; ok = true; if( ok ) { if( curr->type->Info.TypeName.IsName ) { type = 0; } else { type = curr->type->Info.TypeName.ID.Num; } name = WREGetResName( curr->res, type ); ok = (name != NULL); } if( ok ) { ok = WRRemoveLangNodeFromDir( curr->info->info->dir, &curr->type, &curr->res, &curr->lang ); curr->info->modified = true; } if( ok ) { if( !curr->type ) { curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, 0 ); } else { res_lbox = GetDlgItem( curr->info->info_win, IDM_RNRES ); index = SendMessage( res_lbox, LB_FINDSTRING, 0, (LPARAM)name ); if( index == LB_ERR ) { index = 0; } ok = WRESetResNamesFromType( curr->info, curr->info->current_type, TRUE, NULL, index ); } } if( name != NULL ) { WRMemFree( name ); } return( ok ); }
bool WREDeleteStringResources( WRECurrentResInfo *curr, bool removing ) { WResTypeNode *tnode; char *text; bool ok; ok = true; if( !removing ) { text = AllocRCString( WRE_ALLSTRINGS ); ok = WREQueryDeleteName( text ); if( text != NULL ) { FreeRCString( text ); } } if( ok ) { tnode = curr->type; if( tnode == NULL ) { tnode = WRFindTypeNode( curr->info->info->dir, RESOURCE2INT( RT_STRING ), NULL ); } if( tnode != NULL ) { curr->info->modified = true; ok = WRRemoveTypeNodeFromDir( curr->info->info->dir, tnode ); } } // nuke any edit sessions on these string resources if( ok ) { curr->type = NULL; if( !removing ) { WREEndResStringSessions( curr->info ); } curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, 0 ); } return( ok ); }
bool WREDeleteResource( WRECurrentResInfo *curr, bool force ) { char *name; int type; bool ok; LRESULT index; HWND res_lbox; WResLangNode *lnode; name = NULL; lnode = NULL; if( curr->info->current_type == RESOURCE2INT( RT_STRING ) ) { return( WREDeleteStringResources( curr, FALSE ) ); } ok = (curr->info != NULL && curr->res != NULL && curr->lang != NULL); if( ok ) { if( curr->type->Info.TypeName.IsName ) { type = 0; } else { type = curr->type->Info.TypeName.ID.Num; } name = WREGetResName( curr->res, type ); ok = (name != NULL); } if( ok && !force ) { ok = WREQueryDeleteName( name ); } // nuke any edit sessions on this resource if( ok ) { lnode = curr->lang; switch( type ) { case RT_MENU: WREEndLangMenuSession( lnode ); break; case RT_STRING: WREEndResStringSessions( curr->info ); break; case RT_ACCELERATOR: WREEndLangAccelSession( lnode ); break; case RT_DIALOG: WREEndLangDialogSession( lnode ); break; case RT_GROUP_CURSOR: case RT_GROUP_ICON: ok = WREDeleteGroupImages( curr, (uint_16)type ); /* fall through */ case RT_BITMAP: if( ok ) { WREEndLangImageSession( lnode ); } break; } } if( ok ) { ok = WRRemoveLangNodeFromDir( curr->info->info->dir, &curr->type, &curr->res, &curr->lang ); curr->info->modified = true; } if( ok ) { if( !curr->type ) { curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, 0 ); } else { res_lbox = GetDlgItem( curr->info->info_win, IDM_RNRES ); index = SendMessage( res_lbox, LB_FINDSTRING, 0, (LPARAM)name ); if( index == LB_ERR ) { index = 0; } ok = WRESetResNamesFromType( curr->info, curr->info->current_type, TRUE, NULL, index ); } } if( ok ) { WRESetTotalText( curr->info ); } if( name != NULL ) { WRMemFree( name ); } return( ok ); }