Exemplo n.º 1
0
Bool WRERemoveResource( WREResInfo *res_info )
{
    LIST *node;

    if( WREResList == NULL ) {
        return( FALSE );
    }

    if( (node = ListFindElt( WREResList, res_info )) != NULL ) {
        ListRemoveElt( &WREResList, (void *)ListElement( node ) );
    } else {
        return( FALSE );
    }

    WREFreeResInfo( res_info );

    WREDecNumRes();

    if( !WREGetNumRes() ) {
        WRESetCurrentRes( NULL );
    }

    return( TRUE );
}
Exemplo n.º 2
0
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious,
                    LPSTR lpszCmdLine, int nCmdShow )
{
    extern char **_argv;
    extern int  _argc;
    MSG         msg;
    Bool        ret;

    /* touch unused vars to get rid of warning */
    _wre_touch( lpszCmdLine );
    _wre_touch( nCmdShow );
#ifdef __NT__
    _wre_touch( hinstPrevious );
#endif

    WRInit();
    WAccelInit();
    WMenuInit();
    WStringInit();
    WREInitDisplayError( hinstCurrent );

    /* store the handle to this instance of WRE in a static variable */
    WREInst = hinstCurrent;

    peekArgs( _argv, _argc );

    /* is this the first instance of the application? */
#ifndef __NT__
    if( hinstPrevious == NULL ) {
#endif
        /* if so call the routine to initialize the application */
        if( !WREInit( hinstCurrent ) ) {
            return( FALSE );
        }
#ifndef __NT__
    }
#endif

    if( !WREInitInst( hinstCurrent ) ) {
        WREDisplayErrorMsg( WRE_INITFAILED );
        return( FALSE );
    }

    if( !WREDDEStart( hinstCurrent ) ) {
        WREDisplayErrorMsg( WRE_DDEINITFAILED );
        return( FALSE );
    }

    ret = WREProcessArgs( _argv, _argc );

    startEditors();

    // create a new empty res if none have been created at this point
    if( ret && WREGetNumRes() == 0 ) {
        WRECreateNewResource( NULL );
    }

    /* create the message loop */
    while( GetMessage( &msg, (HWND)NULL, 0, 0 ) ) {
        if( !WREIsEditWindowDialogMessage( &msg ) &&
                !WREWasAcceleratorHandled( &msg ) &&
                !WREIsResInfoWinMsg( &msg ) &&
                !WRIsWRDialogMsg( &msg ) ) {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
    }

    WREDDEEnd();
    WStringFini();
    WMenuFini();
    WAccelFini();
    WRFini();

    return( msg.wParam );
}
Exemplo n.º 3
0
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 );
        }
    }
}
Exemplo n.º 4
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 );
}