Exemple #1
0
Bool WREGetAndAddIconImage( BYTE *data, WResDir dir,
                            ICONDIRENTRY *id, int ord )
{
    BYTE                *icon;
    int                 dup;
    WResID              *tname;
    WResID              *rname;
    WResLangType        lang;
    Bool                ok;

    dup = FALSE;
    lang.lang = DEF_LANG;
    lang.sublang = DEF_SUBLANG;
    tname = NULL;
    rname = NULL;

    ok = ( data && dir && id && id->dwBytesInRes );

    if ( ok ) {
        icon = (BYTE *)WREMemAlloc( id->dwBytesInRes );
        ok = ( icon != NULL );
    }

    if( ok ) {
        memcpy( icon, data + id->dwImageOffset, id->dwBytesInRes );
        tname = WResIDFromNum( (uint_16)RT_ICON );
        ok = ( tname != NULL );
    }

    if( ok ) {
        rname = WResIDFromNum( ord );
        ok = ( rname != NULL );
    }

    if ( ok ) {
        ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0,
                               id->dwBytesInRes, dir, &lang, &dup );
    }

    if( ok ) {
        ok = WRFindAndSetData( dir, tname, rname, &lang, icon );
    }

    if( !ok ) {
        if( icon != NULL ) {
            WREMemFree( icon );
        }
    }

    if( tname != NULL ) {
        WREMemFree( tname );
    }

    if( rname != NULL ) {
        WREMemFree( rname );
    }

    return( ok );
}
Exemple #2
0
void WREFreeToolBarInfo( WREToolBarInfo *info )
{
    if( info != NULL ) {
        if( info->items != NULL ) {
            WREMemFree( info->items );
        }
        if( info->dinfo.background != NULL ) {
            DeleteObject( info->dinfo.background );
        }
        WREMemFree( info );
    }
}
Exemple #3
0
void WREDisplayHint( int id )
{
    char        *buf;
    char        *mditext;
    WREHintItem *hint;

    if( id < WRE_MDI_FIRST ) {
        hint = WREGetHintItem ( id );
        if( hint ) {
            WRESetStatusByID( -1, hint->hint );
        }
    } else {
        mditext = WREAllocRCString( WRE_HINT_MDIMSG );
        if( mditext ) {
            buf = WREMemAlloc( strlen(mditext) + 20 + 1 );
            if( buf ) {
                sprintf( buf, mditext, WRE_MDI_FIRST + 1 - id );
                WRESetStatusText( NULL, buf, TRUE );
                WREMemFree( buf );
            }
            WREFreeRCString( mditext );
        }
    }

    return;
}
Exemple #4
0
Bool WREHData2Mem( HDDEDATA hData, void **data, uint_32 *size )
{
    DWORD   dde_size;

    if( data == NULL || size == NULL || hData == (HDDEDATA)NULL ) {
        return( FALSE );
    }

    *size = dde_size = DdeGetData( hData, NULL, 0, 0 );
    if( dde_size == 0 ) {
        return( FALSE );
    }

    *data = WREMemAlloc( dde_size );
    if( *data == NULL ) {
        return( FALSE );
    }

    if( dde_size != DdeGetData( hData, *data, dde_size, 0 ) ) {
        WREMemFree( *data );
        return( FALSE );
    }

    return( TRUE );
}
Exemple #5
0
void WREFiniHints ( void )
{
    LIST             *plist;
    WREPopupListItem *p;

    for ( plist = WREPopupList; plist; plist = ListConsume ( plist ) ) {
        p = (WREPopupListItem *) ListElement ( plist );
        WREMemFree ( p );
    }
}
Exemple #6
0
Bool WREOpenResource( char *fn )
{
    char                *name;
    WREResInfo          *res_info;
    WREGetFileStruct    gf;
    Bool                ok, got_name;

    res_info = NULL;
    name = NULL;
    got_name = FALSE;

    if( fn != NULL ) {
        if( WRFileExists( fn ) ) {
            ok = ((name = WREStrDup( fn )) != NULL);
        } else {
            ok = FALSE;
        }
    } else {
        gf.file_name = NULL;
        gf.title = WREResOpenTitle;
        gf.filter = WREResFilter;
        gf.save_ext = TRUE;
        ok = ((name = WREGetOpenFileName( &gf )) != NULL);
    }

    if( ok ) {
        got_name = TRUE;
        ok = ((res_info = WRELoadResource( name )) != NULL);
    }

    if( ok ) {
        WREFindAndLoadSymbols( res_info );
        ok = WRECreateResourceWindow( res_info );
    }

    if( ok ) {
        ListAddElt( &WREResList, (void *)res_info );
    } else {
        if( res_info != NULL ) {
            WREFreeResInfo( res_info );
            res_info = NULL;
        }
        if( got_name ) {
            WREDisplayErrorMsg( WRE_RESOURCESNOTLOADED );
        }
    }

    if( name != NULL ) {
        WREMemFree( name );
    }

    return( ok );
}
Exemple #7
0
void WREFreeResInfo ( WREResInfo *info )
{
    if ( info ) {
        if ( ( info->info_win != NULL ) && IsWindow ( info->info_win ) ) {
            DestroyWindow ( info->info_win );
        }
        if ( ( info->res_win != NULL ) && IsWindow ( info->res_win ) ) {
            WREDestroyMDIWindow ( info->res_win );
        }
        if ( info->info ) {
            WRFreeWRInfo ( info->info );
        }
        if( info->symbol_table ) {
            WRFreeHashTable( info->symbol_table );
        }
        if( info->symbol_file ) {
            WREMemFree( info->symbol_file );
        }
        WREMemFree ( info );
    }
}
Exemple #8
0
Bool WREChangeMemFlags( void )
{
    WRECurrentResInfo   curr;
    HWND                parent;
    char                *name;
    int                 type;
    uint_16             mflags;
    FARPROC             cb;
    Bool                ok;

    cb = NULL;
    name = NULL;
    mflags = 0;

    ok = WREGetCurrentResource( &curr );

    if( ok )  {
        if( curr.type->Info.TypeName.IsName ) {
            type = 0;
        } else {
            type = curr.type->Info.TypeName.ID.Num;
        }
        name   = WREGetResName( curr.res, type );
        parent = WREGetMainWindowHandle();
    }

    if( ok ) {
        cb = MakeProcInstance( (FARPROC)WREHelpRoutine, WREGetAppInstance() );
        ok = (cb != (FARPROC)NULL);
    }

    if( ok ) {
        mflags = curr.lang->Info.MemoryFlags;
        ok = WRChangeMemFlags( parent, name, &mflags, cb );
    }

    if( ok ) {
        curr.lang->Info.MemoryFlags = mflags;
    }

    if( cb != (FARPROC)NULL ) {
        FreeProcInstance( (FARPROC)cb );
    }

    if( name != NULL ) {
        WREMemFree( name );
    }

    return( ok );
}
Exemple #9
0
Bool WRECreateCursorResHeader( RESCURSORHEADER **rch, uint_32 *rchsize,
                               BYTE *data, uint_32 data_size )
{
    CURSORHEADER        *ch;
    uint_32             chsize;
    ICONHEADER          *ih;
    uint_32             ihsize;
    int                 i;
    Bool                ok;

    ih = NULL;

    ok = (rch != NULL && rchsize != NULL && data != NULL && data_size != 0);

    if( ok ) {
        *rch = NULL;
        *rchsize = 0;
        ch = (CURSORHEADER *)data;
        chsize = sizeof( CURSORHEADER );
        chsize += sizeof( CURSORDIRENTRY ) * (ch->cdCount - 1);
        ok = WRCreateIconHeader( data + chsize, data_size - chsize, 2,
                                 &ih, &ihsize );
    }

    if( ok ) {
        *rchsize = sizeof( RESCURSORHEADER );
        *rchsize += sizeof( RESCURSORDIRENTRY ) * (ih->idCount - 1);
        *rch = (RESCURSORHEADER *)WREMemAlloc( *rchsize );
        ok = (*rch != NULL);
    }

    if( ok ) {
        memcpy( *rch, ch, sizeof( WORD ) * 3 );
        for( i = 0; i < ih->idCount; i++ ) {
            (*rch)->cdEntries[i].bWidth = ih->idEntries[i].bWidth;
            (*rch)->cdEntries[i].bHeight = ih->idEntries[i].bHeight * 2;
            (*rch)->cdEntries[i].wPlanes = ih->idEntries[i].wPlanes;
            (*rch)->cdEntries[i].wBitCount = ih->idEntries[i].wBitCount;
            (*rch)->cdEntries[i].lBytesInRes = ih->idEntries[i].dwBytesInRes;
            (*rch)->cdEntries[i].wNameOrdinal = i + 1;
        }
    }

    if( ih != NULL ) {
        WREMemFree( ih );
    }

    return( ok );
}
Exemple #10
0
Bool WRECreateIconResHeader( RESICONHEADER **rih, uint_32 *rihsize,
                             BYTE *data, uint_32 data_size )
{
    ICONHEADER          *pih;
    uint_32             pihsize;
    ICONHEADER          *ih;
    uint_32             ihsize;
    int                 i;
    Bool                ok;

    ih = NULL;

    ok = (rih != NULL && rihsize != NULL && data != NULL && data_size != 0);

    if( ok ) {
        pih = (ICONHEADER *)data;
        pihsize = sizeof( ICONHEADER );
        pihsize += sizeof( ICONDIRENTRY ) * (pih->idCount - 1);
        ok = WRCreateIconHeader( data + pihsize, data_size - pihsize, 1,
                                 &ih, &ihsize );
    }

    if( ok ) {
        *rihsize = sizeof( RESICONHEADER );
        *rihsize += sizeof( RESICONDIRENTRY ) * (ih->idCount - 1);
        *rih = (RESICONHEADER *)WREMemAlloc( *rihsize );
        ok = (*rih != NULL);
    }

    if( ok ) {
        memcpy( *rih, pih, sizeof( WORD ) * 3 );
        for( i = 0; i < ih->idCount; i++ ) {
            (*rih)->idEntries[i].bWidth = ih->idEntries[i].bWidth;
            (*rih)->idEntries[i].bHeight = ih->idEntries[i].bHeight;
            (*rih)->idEntries[i].bColorCount = ih->idEntries[i].bColorCount;
            (*rih)->idEntries[i].bReserved = 0;
            (*rih)->idEntries[i].wPlanes = ih->idEntries[i].wPlanes;
            (*rih)->idEntries[i].wBitCount = ih->idEntries[i].wBitCount;
            (*rih)->idEntries[i].lBytesInRes = ih->idEntries[i].dwBytesInRes;
            (*rih)->idEntries[i].wNameOrdinal = i + 1;
        }
    }

    if( ih != NULL ) {
        WREMemFree( ih );
    }

    return( ok );
}
Exemple #11
0
WREToolBarInfo *WREAllocToolBarInfo( int num )
{
    WREToolBarInfo *info;

    info = (WREToolBarInfo *)WREMemAlloc( sizeof( WREToolBarInfo ) );

    if( info != NULL ) {
        memset( info, 0, sizeof( WREToolBarInfo ) );
        info->items = (TOOLITEMINFO *)WREMemAlloc( sizeof( TOOLITEMINFO ) * num );
        if( info->items != NULL ) {
            memset( info->items, 0, sizeof( TOOLITEMINFO ) * num );
            info->num_items = num;
        } else {
            WREMemFree( info );
            info = NULL;
        }
    }

    return( info );
}
Exemple #12
0
Bool WRECalcAndAddIconDirectory( BYTE **data, uint_32 *size, WORD type )
{
    ICONHEADER  *ih;
    uint_32     ihsize;

    if( !WRCreateIconHeader( *data, *size, type, &ih, &ihsize ) ) {
        return( FALSE );
    }

    *data = WREMemRealloc( *data, *size + ihsize );
    if( *data == NULL ) {
        return( FALSE );
    }
    memmove( *data + ihsize, *data, *size );
    memcpy( *data, ih, ihsize );
    *size += ihsize;

    WREMemFree( ih );

    return( TRUE );
}
Exemple #13
0
Bool WRECreateIconEntries( WRECurrentResInfo *curr,
                           void *data, uint_32 size )
{
    RESICONHEADER       *rih;
    ICONHEADER          *ih;
    uint_16             ord;
    uint_32             rihsize;
    int                 i;
    Bool                ok;

    ok = ( curr && curr->info && data && size );

    if( ok ) {
        if( curr->lang->data ) {
            WREMemFree( curr->lang->data );
            curr->lang->data = NULL;
        }
        curr->lang->Info.Length = 0;
        ok = WRECreateIconResHeader( &rih, &rihsize, data, size );
    }

    if( ok ) {
        curr->lang->data        = (void *)rih;
        curr->lang->Info.Length = rihsize;
        ord = 0;
        ih = (ICONHEADER *) data;
        for( i = 0; ok && i < rih->cwCount; i++ ) {
            ord = WREFindUnusedImageId( curr->info, ord );
            ok = ( ord != 0 );
            if( ok ) {
                rih->idEntries[i].wNameOrdinal = ord;
                ok = WREGetAndAddIconImage( data, curr->info->info->dir,
                                            &ih->idEntries[i], ord );
            }
        }
    }

    return( ok );
}
Exemple #14
0
Bool WRECreateCursorEntries( WRECurrentResInfo *curr,
                             void *data, uint_32 size )
{
    RESCURSORHEADER     *rch;
    CURSORHEADER        *ch;
    uint_16             ord;
    uint_32             rchsize;
    int                 i;
    Bool                ok;

    ok = ( curr && curr->info && data && size );

    if( ok ) {
        if( curr->lang->data ) {
            WREMemFree( curr->lang->data );
            curr->lang->data = NULL;
        }
        curr->lang->Info.Length = 0;
        ok = WRECreateCursorResHeader( &rch, &rchsize, data, size );
    }

    if( ok ) {
        curr->lang->data        = (void *)rch;
        curr->lang->Info.Length = rchsize;
        ord = 0;
        ch = (CURSORHEADER *) data;
        for( i = 0; ok && i < rch->cwCount; i++ ) {
            ord = WREFindUnusedImageId( curr->info, ord );
            ok = ( ord != 0 );
            if( ok ) {
                rch->cdEntries[i].wNameOrdinal = ord;
                ok = WREGetAndAddCursorImage( data, curr->info->info->dir,
                                              &ch->cdEntries[i], ord );
            }
        }
    }

    return( ok );
}
Exemple #15
0
Bool WRECreateWREPopupListItem ( int num, HMENU menu,
                                 WREPopupHintItem *hint_items )
{
    WREPopupListItem *p;

    p = (WREPopupListItem *) WREMemAlloc ( sizeof(WREPopupListItem) );

    if ( p ) {
        p->num        = num;
        p->menu       = menu;
        p->hint_items = hint_items;
        if ( WREInitHintItems ( num, menu, hint_items ) ) {
            ListAddElt ( &WREPopupList, p );
        } else {
            WREMemFree ( p );
            return ( FALSE );
        }
    } else {
        return ( FALSE );
    }

    return ( TRUE );
}
Exemple #16
0
void WRESetTotalText( WREResInfo *info )
{
    HWND        total;
    HWND        lbox;
    LRESULT     count;
    char        *buf;

    if( info == NULL || WRETotalText == NULL || WRETotalTextOne == NULL ||
        WRETotalTextNone == NULL ) {
        return;
    }

    lbox = GetDlgItem( info->info_win, IDM_RNRES );
    total = GetDlgItem( info->info_win, IDM_RNTOTALTEXT );
    if( lbox == (HWND)NULL || total == (HWND)NULL ) {
        return;
    }

    count = SendMessage( lbox, LB_GETCOUNT, 0, 0 );
    if( count == LB_ERR ) {
        count = 0;
    }

    if( count == 0 ) {
        SendMessage( total, WM_SETTEXT, 0, (LPARAM)(LPSTR)WRETotalTextNone );
    } else if( count == 1 ) {
        SendMessage( total, WM_SETTEXT, 0, (LPARAM)(LPSTR)WRETotalTextOne );
    } else {
        buf = WREMemAlloc( strlen( WRETotalText ) + 20 + 1 );
        if( buf != NULL ) {
            sprintf( buf, WRETotalText, count );
            SendMessage( total, WM_SETTEXT, 0, (LPARAM)(LPSTR)buf );
            WREMemFree( buf );
        }
    }
}
Exemple #17
0
Bool WREAddToTypeListBox( HWND lbox, WResTypeNode *tnode )
{
    char                *text;
    WRETypeName         *tn;
    Bool                ok;

    text = NULL;

    ok = (tnode != NULL && lbox != (HWND)NULL);

    if( ok ) {
        if( tnode->Info.TypeName.IsName ) {
            text = WResIDToStr( &tnode->Info.TypeName );
        } else {
            tn = WREGetTypeNameFromRT( (uint_16)tnode->Info.TypeName.ID.Num );
            if( tn != NULL && tn->name != -1 && !tn->exclude ) {
                text = tn->typeName;
            }
        }
        ok = (text != NULL);
    }

    if( ok ) {
        ok = WRESetLBoxWithStr( lbox, text, tnode );
    }

    if( text != NULL && tnode->Info.TypeName.IsName ) {
        WREMemFree( text );
    }

    if( !ok && tn != NULL && tn->exclude ) {
        return( TRUE );
    }

    return( ok );
}
Exemple #18
0
void WREFreeToolBar( WREToolBar *tbar )
{
    if( tbar != NULL ) {
        WREMemFree( tbar );
    }
}
Exemple #19
0
Bool WRECreateResourceWindow( WREResInfo *res_info )
{
    MDICREATESTRUCT     mdics;
    LRESULT             ret;
    HWND                win;
    Bool                ok;
    DWORD               style;
    int                 fn_offset;
    char                *win_title;
    int                 win_title_len;

    _wre_touch( fn_offset );

    win_title = NULL;

    ok = (res_info != NULL);

    if( ok ) {
        WREIncNumRes();
        if( res_info->info->file_name != NULL ) {
            //perhaps I should make this an option
            //fn_offset = WRFindFnOffset( res_info->info->file_name );
            //title = &res_info->info->file_name[fn_offset];
            mdics.szTitle = res_info->info->file_name;
        } else if( res_info->info->save_name != NULL ) {
            mdics.szTitle = res_info->info->save_name;
        } else {
            WREResCounter++;
            win_title_len = strlen( WREResUntitled ) + 7;
            win_title = (char *)WREMemAlloc( win_title_len );
            sprintf( win_title, "%s.%d", WREResUntitled, 0xffff & WREResCounter );
            mdics.szTitle = win_title;
        }
        style = 0;
        if( WREGetNumRes() != 1 && WREIsCurrentMDIWindowZoomed() ) {
            style = WS_MAXIMIZE;
        }
        mdics.szClass = WREResClass;
        mdics.hOwner = WREAppInst;
        mdics.x = CW_USEDEFAULT;
        mdics.y = CW_USEDEFAULT;
        mdics.cx = CW_USEDEFAULT;
        mdics.cy = CW_USEDEFAULT;
        mdics.style = style;
        mdics.lParam = (LPARAM)(LPVOID)res_info;

        ret = SendMessage( WREGetMDIWindowHandle(), WM_MDICREATE, 0, (LPARAM)(LPVOID)&mdics );
        ok = (ret != NULL);
    }

    if( ok ) {
#ifdef __NT__
        win = (HWND)ret;
#else
        win = (HWND)LOWORD( ret );
#endif
        ok = (res_info->res_win != NULL && res_info->res_win == win);
    }

    if( ok ) {
        ok = WRECreateResInfoWindow( res_info );
    }

    if( ok ) {
        WResizeInfoWindow( res_info );
        ShowWindow( res_info->info_win, SW_SHOW );
        SetFocus( res_info->info_win );
    }

    if( win_title != NULL ) {
        WREMemFree( win_title );
    }

    return( ok );
}
Exemple #20
0
Bool WREGetAndAddCursorImage( BYTE *data, WResDir dir, CURSORDIRENTRY *cd, int ord )
{
    BYTE                *cursor;
    int                 dup;
    uint_32             size;
    WResID              *tname;
    WResID              *rname;
    WResLangType        lang;
    CURSORHOTSPOT       hotspot;
    Bool                ok;

    dup = FALSE;
    lang.lang = DEF_LANG;
    lang.sublang = DEF_SUBLANG;
    tname = NULL;
    rname = NULL;

    ok = (data != NULL && dir != NULL && cd != NULL && cd->dwBytesInRes != 0);

    if ( ok ) {
        cursor = (BYTE *)WREMemAlloc( cd->dwBytesInRes );
        ok = (cursor != NULL);
    }

    if( ok ) {
        memcpy( cursor, data + cd->dwImageOffset, cd->dwBytesInRes );
        hotspot.xHotspot = cd->wXHotspot;
        hotspot.yHotspot = cd->wYHotspot;
        size = cd->dwBytesInRes;
        ok = WREAddCursorHotspot( &cursor, &size, &hotspot );
    }

    if( ok ) {
        tname = WResIDFromNum( (uint_16)RT_CURSOR );
        ok = (tname != NULL);
    }

    if( ok ) {
        rname = WResIDFromNum( ord );
        ok = (rname != NULL);
    }

    if( ok ) {
        ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0,
                               size, dir, &lang, &dup );
    }

    if( ok ) {
        ok = WRFindAndSetData( dir, tname, rname, &lang, cursor );
    }

    if( !ok ) {
        if( cursor != NULL ) {
            WREMemFree( cursor );
        }
    }

    if( tname != NULL ) {
        WREMemFree( tname );
    }

    if( rname != NULL ) {
        WREMemFree( rname );
    }

    return( ok );
}
Exemple #21
0
Bool WRECreateIconDataFromGroup( WRECurrentResInfo *group, BYTE **data, uint_32 *size )
{
    WResLangType        lt;
    WRECurrentResInfo   image;
    RESICONHEADER       *rih;
    ICONHEADER          *ih;
    uint_16             ord;
    uint_32             osize;
    int                 i;
    Bool                ok;

    ok = (group != NULL && group->info != NULL && group->info->info != NULL &&
          group->lang != NULL && data != NULL && size != NULL);

    if( ok ) {
        if( group->lang->data == NULL ) {
            group->lang->data = WREGetCurrentResData( group );
            ok = (group->lang->data != NULL);
        }
    }

    if( ok ) {
        image.info = group->info;
        rih = (RESICONHEADER *)group->lang->data;
        *size = sizeof( ICONHEADER );
        *size += sizeof( ICONDIRENTRY ) * (rih->cwCount - 1);
        *data = (BYTE *)WREMemAlloc( *size );
        ih = (ICONHEADER *)*data;
        ok = (*data != NULL);
    }

    if( ok ) {
        memcpy( ih, rih, sizeof( WORD ) * 3 );
    }

    if( ok ) {
        for( i = 0; ok && i < rih->cwCount; i++ ) {
            ord = (uint_16)rih->idEntries[i].wNameOrdinal;
            lt = group->lang->Info.lang;
            ok = WREFindImageId( &image, (uint_16)RT_ICON, ord, &lt );
            if( ok ) {
                osize = *size;
                ok = WREAddIconImageToData( &image, data, size );
                if( ok ) {
                    ih = (ICONHEADER *)*data;
                    ih->idEntries[i].bWidth = rih->idEntries[i].bWidth;
                    ih->idEntries[i].bHeight = rih->idEntries[i].bHeight;
                    ih->idEntries[i].bColorCount = rih->idEntries[i].bColorCount;
                    //ih->idEntries[i].wPlanes = rih->idEntries[i].wPlanes;
                    //ih->idEntries[i].wBitCount = rih->idEntries[i].wBitCount;
                    ih->idEntries[i].wPlanes = 0;
                    ih->idEntries[i].wBitCount = 0;
                    ih->idEntries[i].bReserved = 0;
                    ih->idEntries[i].dwBytesInRes = *size - osize;
                    ih->idEntries[i].dwImageOffset = osize;
                }
            }
        }
    }

    if( !ok ) {
        if( *data != NULL ) {
            WREMemFree( *data );
            *data = NULL;
        }
        *size = 0;
    }

    return( ok );
}
Exemple #22
0
Bool WRECreateCursorDataFromGroup( WRECurrentResInfo *group, BYTE **data, uint_32 *size )
{
    WRECurrentResInfo   image;
    WResLangType        lt;
    RESCURSORHEADER     *rch;
    CURSORHEADER        *ch;
    CURSORHOTSPOT       hotspot;
    uint_16             ord;
    uint_32             osize;
    int                 i;
    Bool                ok;

    ok = (group != NULL && group->info != NULL && group->info->info != NULL &&
          group->lang != NULL && data != NULL && size != NULL);

    if( ok ) {
        if( group->lang->data == NULL ) {
            group->lang->data = WREGetCurrentResData( group );
            ok = (group->lang->data != NULL);
        }
    }

    if( ok ) {
        image.info = group->info;
        rch = (RESCURSORHEADER *)group->lang->data;
        *size = sizeof( CURSORHEADER );
        *size += sizeof( CURSORDIRENTRY ) * (rch->cwCount - 1);
        *data = (BYTE *)WREMemAlloc( *size );
        ch = (CURSORHEADER *)*data;
        ok = (*data != NULL);
    }

    if( ok ) {
        memcpy( ch, rch, sizeof( WORD ) * 3 );
    }

    if( ok ) {
        for( i = 0; ok && i < rch->cwCount; i++ ) {
            ord = (uint_16)rch->cdEntries[i].wNameOrdinal;
            lt = group->lang->Info.lang;
            ok = WREFindImageId( &image, (uint_16)RT_CURSOR, ord, &lt );
            if( ok ) {
                osize = *size;
                ok = WREAddCursorImageToData( &image, data, size, &hotspot );
                if( ok ) {
                    ch = (CURSORHEADER *)*data;
                    ch->cdEntries[i].bWidth = rch->cdEntries[i].bWidth;
                    ch->cdEntries[i].bHeight = rch->cdEntries[i].bHeight / 2;
                    ch->cdEntries[i].bColorCount = 0;
                    ch->cdEntries[i].bReserved = 0;
                    ch->cdEntries[i].wXHotspot = hotspot.xHotspot;
                    ch->cdEntries[i].wYHotspot = hotspot.yHotspot;
                    ch->cdEntries[i].dwBytesInRes = *size - osize;
                    ch->cdEntries[i].dwImageOffset = osize;
                }
            }
        }
    }

    if( !ok ) {
        if( *data != NULL ) {
            WREMemFree( *data );
            *data = NULL;
        }
        *size = 0;
    }

    return( ok );
}
Exemple #23
0
void WREFreeFileFilter( void )
{
    if( LastFileFilter != NULL ) {
        WREMemFree( LastFileFilter );
    }
}
Exemple #24
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 );
}
Exemple #25
0
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 );
}
Exemple #26
0
HDDEDATA CALLBACK DdeCallBack( UINT wType, UINT wFmt, HCONV hConv,
                                HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
                                ULONG_PTR lData1, ULONG_PTR lData2 )
{
    HDDEDATA    ret;
    HSZPAIR     hszpair[2];
    HSZ         htopic;
    HCONV       htconv;
    void        *data;
    uint_32     size;
    Bool        ok;

    _wre_touch( hdata );
    _wre_touch( lData1 );
    _wre_touch( lData2 );

    ret = (HDDEDATA)FALSE;

    switch( wType ) {
    case XTYP_CONNECT:
    case XTYP_WILDCONNECT:
        if( PendingService == NoServicePending ) {
            htopic = (HSZ)NULL;
        } else {
            htopic = (HSZ)Topics[PendingService].htopic;
        }
        break;
    }

    switch( wType ) {
    case XTYP_CONNECT_CONFIRM:
        htconv = (HCONV)NULL;
        if( PendingService != NoServicePending ) {
                htconv = DdeConnect( IdInst, EditServers[PendingService].hservice,
                                     EditServers[PendingService].htopic, (LPVOID)NULL );
        }
        if( htconv != (HCONV)NULL ) {
            if( PendingService == DialogService ) {
                ok = WRECommitDialogSession( hConv, htconv );
            } else {
                ok = WRECommitImageSession( hConv, htconv );
            }
            if( !ok ) {
                DdeDisconnect( htconv );
                DdeDisconnect( hConv );
            }
        } else {
            DdeDisconnect( hConv );
        }
        break;

    case XTYP_DISCONNECT:
        if( !WREEndEditImageResource( hConv ) ) {
            WREEndEditDialogResource( hConv );
        }
        break;

    case XTYP_CONNECT:
        if( hsz1 == hDialogDump ) {
            WREDumpPendingDialogSession();
        } else if( hsz1 == hImageDump ) {
            WREDumpPendingImageSession();
        } else if( hsz1 == htopic ) {
            ret = (HDDEDATA)TRUE;
        }
        break;

    case XTYP_WILDCONNECT:
        if( hsz2 != hServiceName ) {
            break;
        }
        if( htopic == (HSZ)NULL ) {
            break;
        }
        hszpair[0].hszSvc = hServiceName;
        hszpair[0].hszTopic = htopic;
        hszpair[1].hszSvc = (HSZ)NULL;
        hszpair[1].hszTopic = (HSZ)NULL;
        ret = (HDDEDATA)DdeCreateDataHandle( IdInst, (LPBYTE)&hszpair[0], sizeof( hszpair ),
                                             0L, 0, CF_TEXT, 0 );
        break;

    case XTYP_REQUEST:
        data = NULL;
        size = 0;
        ok = FALSE;
        if( hsz1 == Topics[DialogService].htopic ) {
            if( hsz2 == hFileItem ) {
                ok = WREGetDlgSessionFileName( hConv, &data, &size );
            } else if( hsz2 == hDataItem ) {
                ok = WREGetDlgSessionData( hConv, &data, &size );
            } else if( hsz2 == hNameItem ) {
                ok = WREGetDlgSessionResName( hConv, &data, &size );
            } else if( hsz2 == hIs32BitItem ) {
                ok = WREGetDlgSessionIs32Bit( hConv, &data, &size );
            }
        } else if( hsz1 == Topics[BitmapService].htopic ||
                   hsz1 == Topics[CursorService].htopic ||
                   hsz1 == Topics[IconService].htopic ) {
            if( hsz2 == hFileItem ) {
                ok = WREGetImageSessionFileName( hConv, &data, &size );
            } else if( hsz2 == hDataItem ) {
                ok = WREGetImageSessionData( hConv, &data, &size );
            } else if( hsz2 == hNameItem ) {
                ok = WREGetImageSessionResName( hConv, &data, &size );
            }
        }
        if( data != NULL ) {
            if( ok ) {
                ret = DdeCreateDataHandle( IdInst, (LPBYTE)data, size, 0, hsz2, wFmt, 0 );
            }
            WREMemFree( data );
        }
        break;

    case XTYP_POKE:
        data = NULL;
        size = 0;
        ok = FALSE;
        ret = (HDDEDATA)DDE_FNOTPROCESSED;
        if( hsz1 == Topics[DialogService].htopic ) {
            if( hsz2 == hDataItem ) {
                ok = WRESetDlgSessionResData( hConv, hdata );
            } else if( hsz2 == hNameItem ) {
                ok = WRESetDlgSessionResName( hConv, hdata );
            }
        } else if( hsz1 == Topics[BitmapService].htopic ||
                   hsz1 == Topics[CursorService].htopic ||
                   hsz1 == Topics[IconService].htopic ) {
            if( hsz2 == hDataItem ) {
                ok = WRESetImageSessionResData( hConv, hdata );
            } else if( hsz2 == hNameItem ) {
                ok = WRESetImageSessionResName( hConv, hdata );
            }
        }
        ret = (HDDEDATA)DDE_FACK;
        break;
    }

    return( ret );
}
Exemple #27
0
Bool WRESetResNamesFromType( WREResInfo *info, uint_16 type, Bool force,
                             WResID *name, int index )
{
    HWND                resLbox;
    HWND                typeLbox;
    int                 typeIndex;
    WResTypeNode        *tnode;
    LRESULT             max_index;
    char                *str;
    Bool                ok;

    tnode = NULL;

    ok = (info != NULL);

    if( ok && type != 0 && info->current_type == type && !force ) {
        return( TRUE );
    }

    if( ok ) {
        resLbox = GetDlgItem( info->info_win, IDM_RNRES );
        typeLbox = GetDlgItem( info->info_win, IDM_RNTYPE );
        ok = (resLbox != (HWND)NULL && typeLbox != (HWND)NULL);
    }

    if( ok ) {
        WREResetListbox( resLbox );
        typeIndex = 0;
        if( type != 0 ) {
            typeIndex = WREFindTypeLBoxIndex( typeLbox, type, &tnode );
        } else {
            LRESULT count;
            count = SendMessage( typeLbox, LB_GETCOUNT, 0, 0 );
            if( count != 0 && count != LB_ERR ) {
                tnode = (WResTypeNode *)SendMessage( typeLbox, LB_GETITEMDATA,
                                                     (WPARAM)typeIndex, 0 );
            }
        }
        if( typeIndex == -1 ) {
            return( TRUE );
        }
        info->current_type = type;
        SendMessage( typeLbox, LB_SETCURSEL, (WPARAM)typeIndex, 0 );
    }

    if( ok ) {
        if( tnode != NULL ) {
            info->current_type = tnode->Info.TypeName.ID.Num;
            ok = WRESetResNamesFromTypeNode( resLbox, tnode );
        } else {
            info->current_type = 0;
        }
    }

    if( ok ) {
        if( name != NULL ) {
            index = LB_ERR;
            str = WResIDToStr( name );
            if( str != NULL ) {
                index = (int)SendMessage( resLbox, LB_FINDSTRING, 0, (LPARAM)str );
                WREMemFree( str );
            }
            if( index == LB_ERR ) {
                index = 0;
            }
        }
        max_index = SendMessage( resLbox, LB_GETCOUNT, 0, 0 );
        if( max_index == LB_ERR ) {
            max_index = 0;
        }
        index = min( index, max_index - 1 );
        SendMessage( resLbox, LB_SETCURSEL, (WPARAM)index, 0 );
        WRESetTotalText( info );
        if( GetActiveWindow() == WREGetMainWindowHandle() ) {
            SetFocus( resLbox );
        }
    }

    return( ok );
}