コード例 #1
0
bool WdeRemoveResource( WdeResInfo *res_info )
{
    LIST *node;

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

    if( (node = ListFindElt( WdeResList, res_info )) != NULL ) {
        ListRemoveElt( &WdeResList, (void *)ListElement( node ) );
    } else {
        WdeWriteTrail( "WdeRemoveResource: res_info not found!" );
        return( FALSE );
    }

    if( WdeGetNumRes() == 1 ) {
        WdeOldStickyMode = WdeSetStickyMode( FALSE );
        WdeSetBaseObject( IDM_SELECT_MODE );
    }

    WdeFreeResInfo( res_info );

    if( WdeGetNumRes() == 1 ) {
        WdeSetAppMenuToRes( FALSE );
    }

    WdeDecNumRes();

    return( TRUE );
}
コード例 #2
0
ファイル: wdemain.c プロジェクト: ABratovic/open-watcom-v2
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 );
}
コード例 #3
0
ファイル: wdemain.c プロジェクト: ABratovic/open-watcom-v2
/* Function to initialize all instances of Wde */
bool WdeInitInst( HINSTANCE app_inst )
{
    RECT        rect, screen, t;
    char        *title;

    /* initialize global variables */

    WdeInitOpts();

    if( !JDialogInit() ) {
        return( FALSE );
    }

    if( !WdeInitResStrings() ) {
        return( FALSE );
    }

    if( !WdeInitCreateTable() ) {
        WdeDisplayErrorMsg( WDE_NOINITCONTROLOBJECTS );
        return( FALSE );
    }

    WdeCtl3DInit( app_inst );
    WdeGetScreenPosOption( &rect );

    /* load the accelerator table */
    WdeAccel = LoadAccelerators( app_inst, "WdeAccelTable");

    /* if the window could not be created return FALSE */
    if( WdeAccel == (HACCEL)NULL ) {
        WdeDisplayErrorMsg( WDE_LOADACCELFAILED );
        return( FALSE );
    }

    GetWindowRect( GetDesktopWindow(), &screen );

    if( !IntersectRect( &t, &screen, &rect ) ) {
        t.right = rect.right - rect.left;
        t.bottom = rect.bottom - rect.top;
        t.left = 0;
        if( screen.right - screen.left - t.right > 0 )
            t.left = ( screen.right - screen.left - t.right ) / 2;
        t.top = 0;
        if( screen.bottom - screen.top - t.bottom > 0 )
            t.top = ( screen.bottom - screen.top - t.bottom ) / 2;
        t.right += t.left;
        t.bottom += t.top;
    } else {
        t = rect;
    }

    title = WdeAllocRCString( WDE_APPTITLE );
    /* attempt to create the main application window */
    hWinWdeMain = CreateWindow( WdeMainClass, title, WS_OVERLAPPEDWINDOW,
                                t.left, t.top, t.right - t.left, t.bottom - t.top,
                                (HWND)NULL, (HMENU)NULL, app_inst, NULL );
    if( title != NULL ) {
        WdeFreeRCString( title );
    }

    /* if the window could not be created return FALSE */
    if( hWinWdeMain == NULL ) {
        WdeDisplayErrorMsg( WDE_NOCREATEMAINWINDOW );
        return( FALSE );
    }

    hWinWdeMDIClient = WdeCreateMDIClientWindow( hWinWdeMain, app_inst );

    /* attempt to create the main application info window */
    if( !WdeCreateInfoWindow( hWinWdeMain, app_inst ) ) {
        WdeDisplayErrorMsg( WDE_NOCREATEINFOWINDOW );
        return( FALSE );
    }

    if( !WdeCreateStatusLine( hWinWdeMain, app_inst ) ) {
        WdeDisplayErrorMsg( WDE_NOCREATESTATUSLINE );
        return( FALSE );
    }

    WdeInitialMenu = GetMenu( hWinWdeMain );
    WdeCurrentMenu = WdeInitialMenu;
    WdeResMenu = LoadMenu( app_inst, "WdeResMenu" );
    WdeDDEMenu = LoadMenu( app_inst, "WdeDDEMenu" );

    if( IsDDE ) {
        WdeSetAppMenuToRes( TRUE );
    }


    if( !WdeInitialMenu || !WdeResMenu ) {
        WdeDisplayErrorMsg( WDE_NOINITMENUS );
        return( FALSE );
    }

    if( !WdeInitHints() ) {
        WdeDisplayErrorMsg( WDE_NOINITHINTS );
        return( FALSE );
    }

    WdeInitRibbon( app_inst );

    if( WdeGetOption( WdeOptIsRibbonVisible ) ) {
        WdeShowRibbon();
    }

    /* if the window was created Show and Update it */
    if( WdeGetOption( WdeOptIsScreenMax ) ) {
        ShowWindow( hWinWdeMain, SW_SHOWMAXIMIZED );
    } else {
        ShowWindow( hWinWdeMain, SW_SHOWNORMAL );
    }
    UpdateWindow( hWinWdeMain );

    WdeSetFontList( hWinWdeMain );

    if( !IsDDE ) {
        WdeDisplaySplashScreen( hInstWde, hWinWdeMain, 1125 );
    }

    if( IsDDE ) {
        WdeInitToolMenu( app_inst, WdeDDEMenu );
    } else {
        WdeInitToolMenu( app_inst, WdeResMenu );
    }
    WdeInitControls( app_inst );

    if( WdeGetOption( WdeOptIsCntlsTBarVisible ) ) {
        if( !WdeCreateControlsToolBar ( ) ) {
            WdeDisplayErrorMsg( WDE_NOCREATETOOLBOX );
            return( FALSE );
        }
    }

    SetFocus( hWinWdeMain );

    return( TRUE );

}
コード例 #4
0
bool WdeCreateResourceWindow( WdeResInfo *res_info, int fn_offset, char *title )
{
    MDICREATESTRUCT     mdics;
    LRESULT             ret;
    HWND                win;
    bool                ok;
    bool                old;
    DWORD               style;
    RECT                r;
    HMENU               sys_menu;
    char                *win_title;
    int                 win_title_len;

    _wde_touch( fn_offset );

    WdeIncNumRes();

    style = 0;

    if( WdeGetNumRes() == 1 ) {
        WdeSetAppMenuToRes( TRUE );
        old = WdeSetStickyMode( WdeOldStickyMode );
        style = WS_MAXIMIZE;
    } else {
        if( WdeIsCurrentMDIWindowZoomed() ) {
            style = WS_MAXIMIZE;
        }
    }

    mdics.szClass = "WdeResClass";

    win_title = NULL;
    if( title == NULL ) {
        if( res_info->info->file_name ) {
            // perhaps make this an option
            //title = &res_info->info->file_name[fn_offset];
            mdics.szTitle = res_info->info->file_name;
        } else {
            WdeResCounter++;
            win_title_len = strlen( WdeResUntitled ) + 7;
            win_title = (char *)WRMemAlloc( win_title_len );
            sprintf( win_title, "%s.%d", WdeResUntitled, 0xffff & WdeResCounter );
            mdics.szTitle = win_title;
        }
    } else {
        mdics.szTitle = title;
    }

    win = WdeGetMDIWindowHandle();
    GetClientRect( win, &r );

    mdics.hOwner = WdeGetAppInstance();
    mdics.x = CW_USEDEFAULT;
    mdics.y = CW_USEDEFAULT;
    mdics.cx = CW_USEDEFAULT;
    mdics.cy = CW_USEDEFAULT;
    //mdics.cx = r.right - r.left;
    //mdics.cy = r.bottom - r.top;
    mdics.style = style;
    mdics.lParam = (LPARAM)res_info;

    ret = SendMessage( win, WM_MDICREATE, 0, (LPARAM)&mdics );

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

#ifdef __NT__
    win = (HWND)ret;
#else
    win = (HWND)LOWORD( ret );
#endif

    ok = (res_info->res_win != NULL && res_info->res_win == win);
    if( !ok ) {
        WdeWriteTrail( "WdeCreateResourceWindow: Bad window handle!" );
    }

    if( WdeIsDDE() ) {
        sys_menu = GetSystemMenu( win, FALSE );
        if( sys_menu != (HMENU)NULL ) {
            EnableMenuItem( sys_menu, SC_CLOSE, MF_GRAYED );
        }
    }

    if( ok ) {
        ok = WdeCreateEditWindows( res_info );
        if( !ok ) {
            WdeWriteTrail( "WdeCreateResourceWindow: Could not create edit windows!" );
        }
    }

    if( ok ) {
        OpenFormEdit( res_info->forms_win, WdeGetCreateTable(), MENU_NONE, SCROLL_NONE );
        WdeSetEditMode( res_info, TRUE );
        SetHorizontalInc( 1 );
        SetVerticalInc( 1 );
        InitState( res_info->forms_win );
        SetMouseRtn( res_info->forms_win, WdeMouseRtn );
        //MakeObjectCurrent( GetMainObject() );
    } else {
        if( WdeGetNumRes() == 1 ) {
            WdeSetAppMenuToRes( FALSE );
            WdeSetStickyMode( old );
        }
        WdeDecNumRes();
    }

    return( ok );
}