Ejemplo n.º 1
0
Bool WREDestroyResourceWindow( WREResInfo *res_info )
{
    if( res_info != NULL && WREQuerySaveResOnDeleteRes( res_info, FALSE ) &&
        WREQuerySaveSymOnDeleteRes( res_info, FALSE ) ) {
        return( WRERemoveResource( res_info ) );
    }
    return( FALSE );
}
Ejemplo n.º 2
0
LRESULT WINEXPORT WREMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    HMENU       menu;
    LRESULT     ret;
    Bool        pass_to_def;
    WREResInfo  *res_info;
    WORD        wp;
    about_info  ai;

    if( WRECleanupStarted && message != WM_CLOSE ) {
        if( message == WM_DESTROY ) {
            PostQuitMessage( 0 );
        }
        return( DefFrameProc( hWnd, WREMDIWin, message, wParam, lParam ) );
    }

    pass_to_def = TRUE;
    ret = FALSE;
    res_info = WREGetCurrentRes();
    menu = WREGetMenuHandle();

    switch( message ) {
    case WM_DESTROYCLIPBOARD:
        WRForgetBitmapName();
        break;

    case WM_INITMENU:
        if( wParam == (WPARAM)GetMenu( hWnd ) ) {
            WRESetCopyMenuItem( hWnd );
            WRESetPasteMenuItem( hWnd );
        }
        break;

    case WM_MENUSELECT:
        WREHandleMenuSelect( wParam, lParam );
        break;

    case WM_MOVE:
        if( IsZoomed( hWnd ) ) {
            WRESetOption( WREOptScreenMax, TRUE );
        } else if( !IsIconic( hWnd ) ) {
            WREUpdateScreenPosOpt();
            WRESetOption( WREOptScreenMax, FALSE );
        }
        break;

    case WM_SIZE:
        if( wParam == SIZE_MAXIMIZED ) {
            WRESetOption( WREOptScreenMax, TRUE );
        } else if( wParam == SIZE_MINIMIZED ) {
            WREHideSessions( FALSE );
            WREIsMinimized = TRUE;
        } else {
            WREUpdateScreenPosOpt();
            WRESetOption( WREOptScreenMax, FALSE );
        }
        if( wParam != SIZE_MINIMIZED && WREIsMinimized ) {
            WREHideSessions( TRUE );
            BringWindowToTop( hWnd );
            WREIsMinimized = FALSE;
        }
        WREResizeWindows();
        pass_to_def = FALSE;
        break;

    case ACCEL_I_HAVE_CLOSED:
        WREEndEditAccelResource( (WAccelHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case ACCEL_PLEASE_SAVEME:
        WRESaveEditAccelResource( (WAccelHandle)lParam );
        pass_to_def = FALSE;
        break;

    case MENU_I_HAVE_CLOSED:
        WREEndEditMenuResource( (WMenuHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case MENU_PLEASE_SAVEME:
        WRESaveEditMenuResource( (WMenuHandle)lParam );
        pass_to_def = FALSE;
        break;

    case STRING_I_HAVE_CLOSED:
        WREEndEditStringResource( (WStringHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case STRING_PLEASE_SAVEME:
        WRESaveEditStringResource( (WStringHandle)lParam );
        pass_to_def = FALSE;
        break;

    case ACCEL_PLEASE_OPENME:
    case MENU_PLEASE_OPENME:
    case STRING_PLEASE_OPENME:
        ret = pleaseOpenFile( message );
        pass_to_def = FALSE;
        break;

    case WM_COMMAND:
        wp = LOWORD( wParam );
        switch( wp ) {
        case IDM_OPTIONS:
            pass_to_def = FALSE;
            break;

        case IDM_LOAD_SYMBOLS:
            WRELoadResourceSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_EDIT_SYMBOLS:
            WREEditResourceSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE_SYMBOLS:
            WREResourceSaveSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_NEW:
            WRECreateNewResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_OPEN:
            WREOpenResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE:
            WRESaveResource( res_info, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_SAVEAS:
            WRESaveResource( res_info, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_DELETE:
            WREDeleteCurrResource( FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_PASTE:
            WREPasteResource( hWnd );
            pass_to_def = FALSE;
            break;

        case IDM_CUT:
            WREClipCurrentResource( hWnd, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_COPY:
            WREClipCurrentResource( hWnd, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_NEW_CURSOR:
            WRENewImageResource( CursorService, (uint_16)RT_GROUP_CURSOR );
            break;

        case IDM_NEW_BITMAP:
            WRENewImageResource( BitmapService, (uint_16)RT_BITMAP );
            break;

        case IDM_NEW_ICON:
            WRENewImageResource( IconService, (uint_16)RT_GROUP_ICON );
            break;

        case IDM_NEW_DIALOG:
            WRENewDialogResource();
            break;

        case IDM_NEW_FONT:
        case IDM_NEW_RCDATA:
            pass_to_def = FALSE;
            break;

        case IDM_NEW_ACCELERATOR:
            WRENewAccelResource();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_MENU:
            WRENewMenuResource();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_STRING:
            WRENewStringResource();
            pass_to_def = FALSE;
            break;

        case IDM_RES_SAVEAS:
        case IDM_RES_SAVE_INTO:
            if( res_info != NULL ) {
                if( res_info->current_type == (uint_16)RT_STRING ) {
                    SaveMultObjects( wp == IDM_RES_SAVE_INTO );
                } else {
                    SaveObject( wp == IDM_RES_SAVE_INTO );
                }
            }
            pass_to_def = FALSE;
            break;

        case IDM_RES_EDIT:
            WREHandleResEdit();
            pass_to_def = FALSE;
            break;

        case IDM_RES_MEM_FLAGS:
            WREChangeMemFlags();
            pass_to_def = FALSE;
            break;

        case IDM_RES_RENAME:
            WRERenameResource();
            pass_to_def = FALSE;
            break;

        case IDM_MDI_CASCADE:
        case IDM_MDI_TILEV:
        case IDM_MDI_TILEH:
        case IDM_MDI_ARRANGE:
            WREHandleMDIArrangeEvents( wp );
            pass_to_def = FALSE;
            break;

        case IDM_EXIT:
            /* clean up before we exit */
            PostMessage( WREMainWin, WM_CLOSE, 0, 0 );
            break;

        case IDM_SHOW_RIBBON:
            WREShowRibbon( menu );
            pass_to_def = FALSE;
            break;

        case IDM_HELP:
            WREHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_SEARCH:
            WREHelpSearchRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_ON_HELP:
            WREHelpOnHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_ABOUT:
            ai.owner = hWnd;
            ai.inst = WREInst;
            ai.name = AllocRCString( WRE_ABOUT_NAME );
            ai.version = banner1p2( _RESEDIT_VERSION_ );
            ai.first_cr_year = AllocRCString( WRE_ABOUT_COPYRIGHT_YEAR );
            ai.title = AllocRCString( WRE_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.first_cr_year );
            FreeRCString( ai.title );
            pass_to_def = FALSE;
            break;
        }
        break;

    case WM_DESTROY:
        WWinHelp( WREMainWin, "resedt.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;

    case WRE_FATAL_EXIT:
        WREFatalExit = TRUE;
        WREQueryKillApp( TRUE );
        PostMessage( WREMainWin, WM_CLOSE, 0, 0 );
        break;

    case WM_ENDSESSION:
        if( !wParam ) {
            WREFatalExit = FALSE;
        }
        break;

    case WM_QUERYENDSESSION:
        if( ret = WREQueryKillApp( FALSE ) ) {
            WREFatalExit = TRUE;
        }
        pass_to_def = FALSE;
        break;

    case WM_CLOSE:
        /* clean up before we exit */
        if( WRECleanupStarted ) {
            pass_to_def = FALSE;
            break;
        }
        WRECleanupStarted = TRUE;
        if( !WRECleanup( WREFatalExit ) ) {
            WRECleanupStarted = FALSE;
            pass_to_def = FALSE;
        }
    }

    if( pass_to_def ) {
        ret = DefFrameProc( hWnd, WREMDIWin, message, wParam, lParam );
    }
    return( ret );
}