Esempio n. 1
0
bool WdeCleanup( WdeResInfo *res_info, bool fatal_exit )
{
    /* clean up before we exit */
    if( WdeGetTestMode() ) {
        WdeHandleTestModeMenu( res_info );
    }

    // must be done before FMEDIT is shutdown
    if( FMPasteValid() ) {
        FMResetClipboard();
    }

    WdeSetOption( WdeOptIsCntlsTBarVisible, WdeControlsToolBarExists() );

    if( WdeQueryKillApp( fatal_exit ) ) {
        WdeFreeResList();
    } else {
        return( FALSE );
    }

    WdeFiniHints();
    WdeFreeAllCustLibs();

#ifndef __NT__
    WdeFreeCustRESProcs();
#endif

    WdeShutdownToolBars();

    WdeSetOption( WdeOptIsScreenMax, IsZoomed( hWinWdeMain ) );

    WdeOptsShutdown();
    WdeFreeControlIDs();
    WdeSetAppMenuToRes( FALSE );
    DestroyMenu( WdeResMenu );
    DestroyMenu( WdeDDEMenu );
    WdeFiniToolMenu();
    WdeShutdownControls();
    WdeDestroyRibbon();
    WdeShutdownRibbon();
    WdeFiniCreateTable();
    WdeFiniOrderStuff();

    /* get rid of all the child windows of the main application window */
    WdeDestroyInfoWindow();
    WdeInfoFini();
    WdeDestroyStatusLine();
    WdeFiniEditClass();
    WdeFiniResStrings();

    WdeFreeFontList();
    WdeCtl3DFini( hInstWde );
    WdeFreeFileFilter();
    JDialogFini();

    return( TRUE );
}
Esempio n. 2
0
void WdeHandleShowToolsMenu( void )
{
    if( WdeControls != NULL ) {
        WdeDestroyControls();
        WdeSetOption( WdeOptIsCntlsTBarVisible, FALSE );
    } else {
        WdeCreateControlsToolBar();
        WdeSetOption( WdeOptIsCntlsTBarVisible, TRUE );
    }
}
Esempio n. 3
0
void WdeShowRibbon( void )
{
    bool        created;
    char        *mtext;

    if( WdeRibbonHeight != 0 ) {
        ShowWindow( WdeRibbon->win, SW_HIDE );
        WdeRibbonHeight = 0;
        WdeResizeWindows();
        mtext = WdeAllocRCString( WDE_SHOWTOOLBAR );
    } else {
        if( WdeRibbon == NULL ) {
            WdeCreateRibbon( WdeGetMainWindowHandle() );
            created = TRUE;
        } else {
            created = FALSE;
        }
        if( !created ) {
            WdeRibbonHeight = 2 * WdeRibbonInfo->dinfo.border_size.y +
                              WdeRibbonInfo->dinfo.button_size.y +
                              2 * GetSystemMetrics( SM_CYBORDER );
            WdeResizeWindows();
        }
        mtext = WdeAllocRCString( WDE_HIDETOOLBAR );
        ShowWindow( WdeRibbon->win, SW_SHOW );
    }

    WdeSetOption( WdeOptIsRibbonVisible, WdeRibbonHeight != 0 );

    ModifyMenu( WdeGetInitialMenuHandle(), IDM_SHOW_RIBBON,
                MF_BYCOMMAND | MF_STRING, IDM_SHOW_RIBBON, mtext );
    ModifyMenu( WdeGetResMenuHandle(), IDM_SHOW_RIBBON,
                MF_BYCOMMAND | MF_STRING, IDM_SHOW_RIBBON, mtext );

    if( mtext != NULL ) {
        WdeFreeRCString( mtext );
    }
}
Esempio n. 4
0
WINEXPORT LRESULT CALLBACK WdeMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    HMENU       menu;
    LRESULT     ret;
    bool        pass_to_def;
    WdeResInfo  *res_info;
    WORD        wp;
    about_info  ai;

    if( WdeCleanupStarted ) {
        if( message == WM_DESTROY ) {
            PostQuitMessage( 0 );
        }
        return( DefFrameProc( hWnd, hWinWdeMDIClient, message, wParam, lParam ) );
    }

    pass_to_def = TRUE;
    ret = FALSE;
    res_info = WdeGetCurrentRes();
    menu = WdeGetMenuHandle();

    switch( message ) {
    case WM_INITMENU:
        handleInitMenu( menu );
        break;

    case WM_USER:
        WdeSetStatusByID( -1, WDE_ONLYONEINSTANCE );
        break;

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

    case WM_MEASUREITEM:
        WdeHandleMeasureItem( (MEASUREITEMSTRUCT *)lParam );
        ret = TRUE;
        pass_to_def = FALSE;
        break;

    case WM_DRAWITEM:
        WdeHandleDrawItem( (DRAWITEMSTRUCT *)lParam );
        ret = TRUE;
        pass_to_def = FALSE;
        break;

    case WM_MOVE:
        if( IsZoomed( hWnd ) ) {
            WdeSetOption( WdeOptIsScreenMax, TRUE );
        } else if( !IsIconic( hWnd ) ) {
            WdeUpdateScreenPosOpt();
            WdeSetOption( WdeOptIsScreenMax, FALSE );
        }
        break;

    case WM_SIZE:
        if( wParam == SIZE_MAXIMIZED ) {
            WdeSetOption( WdeOptIsScreenMax, TRUE );
        } else if( wParam != SIZE_MINIMIZED ) {
            WdeUpdateScreenPosOpt();
            WdeSetOption( WdeOptIsScreenMax, FALSE );
        }

        if( wParam != SIZE_MINIMIZED ) {
            WdeResizeWindows();
        }

        pass_to_def = FALSE;
        break;

    case WM_COMMAND:
        wp = LOWORD( wParam );
        if( !WdeIsMenuIDValid( menu, wp ) ) {
            break;
        }
        switch( wp ) {
        case IDM_SELECT_MODE:
        case IDM_DIALOG_TOOL:
        case IDM_PBUTTON_TOOL:
        case IDM_CBUTTON_TOOL:
        case IDM_RBUTTON_TOOL:
        case IDM_GBUTTON_TOOL:
        case IDM_FRAME_TOOL:
        case IDM_TEXT_TOOL:
        case IDM_ICON_TOOL:
        case IDM_EDIT_TOOL:
        case IDM_LISTBOX_TOOL:
        case IDM_COMBOBOX_TOOL:
        case IDM_HSCROLL_TOOL:
        case IDM_VSCROLL_TOOL:
        case IDM_SIZEBOX_TOOL:
        case IDM_STATUSBAR_TOOL:
        case IDM_LISTVIEW_TOOL:
        case IDM_TREEVIEW_TOOL:
        case IDM_TABCNTL_TOOL:
        case IDM_ANIMATE_TOOL:
        case IDM_UPDOWN_TOOL:
        case IDM_TRACKBAR_TOOL:
        case IDM_PROGRESS_TOOL:
        case IDM_HOTKEY_TOOL:
        case IDM_HEADER_TOOL:
        case IDM_CUSTOM1_TOOL:
        case IDM_CUSTOM2_TOOL:
            WdeSetBaseObject( wp );
            pass_to_def = FALSE;
            break;

        case IDM_STICKY_TOOLS:
            WdeToggleStickyTools();
            pass_to_def = FALSE;
            break;

        case IDM_FMLEFT:
        case IDM_FMRIGHT:
        case IDM_FMTOP:
        case IDM_FMBOTTOM:
        case IDM_FMVCENTRE:
        case IDM_FMHCENTRE:
        case IDM_ESCAPE:
        case IDM_DELETEOBJECT:
        case IDM_SPACE_HORZ:
        case IDM_SPACE_VERT:
            ret = WdePassToEdit( message, wParam, lParam );
            pass_to_def = FALSE;
            break;

        case IDM_SELECT_DIALOG:
            WdeSelectDialog( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_OPTIONS:
            WdeDisplayOptions ();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_RES:
            WdeCreateNewResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_DDE_CLEAR:
            WdeClearCurrentResource();
            pass_to_def = FALSE;
            break;

        case IDM_OPEN_RES:
            WdeOpenResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE_RES:
            WdeSaveResource( res_info, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_SAVEAS_RES:
            WdeSaveResource( res_info, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_DDE_UPDATE_PRJ:
            WdeUpdateDDEEditSession();
            break;

        case IDM_PASTEOBJECT:
            if( FMPasteValid() ) {
                ret = WdePassToEdit( message, wParam, lParam );
            }
            pass_to_def = FALSE;
            break;

        case IDM_CUTOBJECT:
        case IDM_COPYOBJECT:
            ret = WdePassToEdit( message, wParam, lParam );
            pass_to_def = FALSE;
            break;

        case IDM_SAME_WIDTH:
            WdeSameSize( R_RIGHT );
            pass_to_def = FALSE;
            break;

        case IDM_SAME_HEIGHT:
            WdeSameSize( R_BOTTOM );
            pass_to_def = FALSE;
            break;

        case IDM_SAME_SIZE:
            WdeSameSize( R_BOTTOM | R_RIGHT );
            pass_to_def = FALSE;
            break;

        case IDM_SIZETOTEXT:
            WdeHandleSizeToText();
            pass_to_def = FALSE;
            break;

        case IDM_GOTO_INFOBAR:
            WdeSetFocusToInfo();
            pass_to_def = FALSE;
            break;

        case IDM_GOTO_OBJECT:
            WdeHandleGotoCurrentObject();
            pass_to_def = FALSE;
            break;

        case IDM_DIALOG_RESTORE:
            WdeRestoreCurrentDialog();
            pass_to_def = FALSE;
            break;

        case IDM_TAB:
        case IDM_STAB:
            WdeHandleTabEvent( wp == IDM_TAB );
            pass_to_def = FALSE;
            break;

#if 0
        /* this strategy has been rejected in favor of the hide option */
        case IDM_REMOVE_DIALOG:
            WdeRemoveDialog( res_info );
            pass_to_def = FALSE;
            break;
#endif

        case IDM_HIDE_DIALOG:
            WdeHideCurrentDialog();
            pass_to_def = FALSE;
            break;

        case IDM_TEST_MODE:
            WdeHandleTestModeMenu( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_DIALOG_NEW:
            if( WdeCreateNewDialog( NULL, res_info->is32bit ) ) {
                WdeHandleGotoCurrentObject();
            }
            pass_to_def = FALSE;
            break;

        case IDM_DIALOG_SAVE:
        case IDM_DIALOG_SAVEAS:
        case IDM_DIALOG_SAVEINTO:
            WdeSaveCurrentDialog( wp );
            pass_to_def = FALSE;
            break;

        case IDM_SET_ORDER:
        case IDM_SET_TABS:
        case IDM_SET_GROUPS:
            WdeSetDialogMode( wp );
            pass_to_def = FALSE;
            break;

        case IDM_DEFINEOBJECT:
        case IDM_GEN_DEFINEOBJECT:
            if( !WdeDefineCurrentObject( wp ) ) {
                WdeWriteTrail( "WdeResWndProc: Define failed!" );
            }
            pass_to_def = FALSE;
            break;

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

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

        case IDM_SELCUST1:
        case IDM_SELCUST2:
            if( !WdeSetCurrentCustControl( wp - IDM_SELCUST1 ) ) {
                WdeWriteTrail( "WdeMainWndProc: WdeSetCurrentCustControl failed!" );
                WdeSetStatusByID( -1, WDE_SETFAILED );
            }
            pass_to_def = FALSE;
            break;

        case IDM_MS_CUSTOM:
            WdeLoadCustomLib( TRUE, FALSE );
            pass_to_def = FALSE;
            break;

#ifndef __NT__
        case IDM_BOR_CUSTOM:
            WdeLoadCustomLib( FALSE, FALSE );
            pass_to_def = FALSE;
            break;
#endif

        case IDM_LOADLIB:
            WdeLoadCustomLib( FALSE, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_WRITE_SYMBOLS:
            WdeResourceHashTableAction( res_info, WRITE_HASH );
            pass_to_def = FALSE;
            break;

        case IDM_LOAD_SYMBOLS:
            WdeResourceHashTableAction( res_info, LOAD_HASH );
            pass_to_def = FALSE;
            break;

        case IDM_VIEW_SYMBOLS:
            WdeResourceHashTableAction( res_info, VIEW_HASH );
            pass_to_def = FALSE;
            break;

        case IDM_SHOW_TOOLS:
            WdeHandleShowToolsMenu();
            pass_to_def = FALSE;
            break;

        case IDM_SHOW_RIBBON:
            WdeShowRibbon();
            pass_to_def = FALSE;
            break;

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

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

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

       case IDM_ABOUT:
            ai.owner = hWnd;
            ai.inst = hInstWde;
            ai.name = AllocRCString( WDE_ABOUT_NAME );
            ai.version = AllocRCString( WDE_ABOUT_VERSION );
            ai.first_cr_year = "1984";
            ai.title = AllocRCString( WDE_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.version );
            FreeRCString( ai.title );
            pass_to_def = FALSE;
            break;
        }
        break;

    case WM_DESTROY:
        WWinHelp( hWinWdeMain, "resdlg.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;

    case WDE_FATAL_EXIT:
        WdeFatalExit = TRUE;
        WdeQueryKillApp( TRUE );
        PostMessage( hWinWdeMain, WM_CLOSE, 0, 0 );
        break;

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

    case WM_QUERYENDSESSION:
        ret = WdeQueryKillApp( FALSE );
        if( ret ) {
            WdeFatalExit = TRUE;
            pass_to_def = FALSE;
        }
        break;

    case WM_CLOSE:
        // this prevents the user from closing the editor during
        // DDE initialization
        if( !wParam && !EnableMenuInput ) {
            return( 0 );
        }
        /* clean up before we exit */
        WdeCleanupStarted = TRUE;
        if( wParam ) {  // wParam is non-zero if the DDE connection died
            WdeFatalExit = TRUE;
            WdeQueryKillApp( TRUE );
            wParam = 0;
        }
        if( !WdeCleanup( res_info, WdeFatalExit ) ) {
            WdeCleanupStarted = FALSE;
            pass_to_def = FALSE;
        }
    }

    if( pass_to_def ) {
        ret = DefFrameProc( hWnd, hWinWdeMDIClient, message, wParam, lParam );
    }
    return( ret );
}
Esempio n. 5
0
static bool wdeControlsHook( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    MINMAXINFO          *minmax;
    WdeToolBar          *tbar;
    OBJ_ID              obj_id;
    WORD                id;
    char                *text;
    OBJPTR              obj;
    WdeOrderMode        mode;
    ctl_id              cid;
    bool                ignore_msg;
    bool                ret;

    ignore_msg = FALSE;

    if( WdeGetNumRes() && !WdeInCleanup() ) {
        obj = WdeGetCurrentDialog();
        if( obj != NULL && Forward( obj, GET_ORDER_MODE, &mode, NULL ) && mode != WdeSelect ) {
            ignore_msg = TRUE;
        }
    }

    if( !ignore_msg && WdeGetTestMode() ) {
        ignore_msg = TRUE;
    }

    if( ignore_msg ) {
        switch( msg ) {
        case WM_RBUTTONDOWN:
        case WM_RBUTTONDBLCLK:
        case WM_LBUTTONDOWN:
        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONUP:
        case WM_LBUTTONUP:
            return( true );
        }
    }

    if( (tbar = WdeControls) == NULL ) {
        if( msg == WM_GETMINMAXINFO ) {
            minmax = (MINMAXINFO *)lParam;
            minmax->ptMinTrackSize.x = 8;
        }
        return( false );
    }

    ret = false;

    switch( msg ) {
    case WM_USER:
        if( WdeGetNumRes() ) {
            obj_id = GetBaseObjType();
            id = WdeGetMenuFromOBJID( obj_id );
            if( id == wParam || (wParam == IDM_STICKY_TOOLS && WdeStickyMode) ) {
                lParam = !lParam;
            }
            WdeHandleStickyToolPress( tbar, wParam, lParam );
        }
        break;

    case WM_RBUTTONDOWN:
    case WM_RBUTTONDBLCLK:
    case WM_LBUTTONDOWN:
    case WM_LBUTTONDBLCLK:
        if( FindToolIDAtPoint( tbar->tbar, wParam, lParam, &cid ) ) {
            if( cid == IDM_CUSTOM1_TOOL ) {
                ret = !WdeIsCurrentCustControlSet( 0 );
            } else if( cid == IDM_CUSTOM2_TOOL ) {
                ret = !WdeIsCurrentCustControlSet( 1 );
            }
        }
        break;

    case WM_SIZE:
        if ( wParam != SIZE_MAXIMIZED && wParam != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &tbar->last_pos );
        }
        break;

    case WM_MOVE:
        if( !IsZoomed( hwnd ) ) {
            GetWindowRect( hwnd, &tbar->last_pos );
        }
        break;

    case WM_GETMINMAXINFO:
        if( GetModuleHandle( "COMCTL32.DLL" ) == NULL ) {
            minmax = (MINMAXINFO *)lParam;
            minmax->ptMinTrackSize.x =
                2 * GetSystemMetrics( SM_CXFRAME ) +
                tbar->info->dinfo.border_size.x +
                tbar->info->dinfo.button_size.x - 1;
            minmax->ptMinTrackSize.y =
                2 * GetSystemMetrics( SM_CYFRAME ) +
                GetSystemMetrics(SM_CYCAPTION) +
                tbar->info->dinfo.border_size.y +
                tbar->info->dinfo.button_size.y - 1;
            ret = true;
        }
        break;

    case WM_CLOSE:
        WdeDestroyControls();
        WdeSetOption ( WdeOptIsCntlsTBarVisible, FALSE );
        ret = true;
        break;

    case WM_DESTROY:
        WdeControls = NULL;
        WdeSetCntlTBarPosOption( &tbar->last_pos );
        text = WdeAllocRCString( WDE_SHOWTOOLBOX );
        ModifyMenu( WdeGetResMenuHandle(), IDM_SHOW_TOOLS,
                    MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
        ModifyMenu( WdeGetInitialMenuHandle(), IDM_SHOW_TOOLS,
                    MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        WdeCloseToolBar( tbar );
        break;

    }

    return( ret );
}