Пример #1
0
void PP_OutOfMemory( void )
{
    if( WdePopEnv( &Env ) ) {
        longjmp( Env, 1 );
    } else {
        WdeWriteTrail( "Wde PreProc: Fatal error!" );
        exit( -1 );
    }
}
Пример #2
0
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious,
                    LPSTR lpszCmdLine,  int nCmdShow )
{
    MSG         msg;
#ifndef __NT__
#if 0
    HWND        win;
    HWND        child;
#endif
#endif

    /* touch unused vars to get rid of warning */
    _wde_touch( lpszCmdLine );
    _wde_touch( nCmdShow );
#ifdef __NT__
    _wde_touch( hinstPrevious );
#endif
#if defined( __NT__ ) && !defined( __WATCOMC__ )
    _argc = __argc;
    _argv = __argv;
#endif

    WRInit();
    WdeInitDisplayError( hinstCurrent );

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

    //check we are running in DDE mode
    IsDDE = WdeIsDDEArgs( _argv, _argc );

    WdeFirstInst = (hinstPrevious == NULL);

    WdeInitEditClass();

    /* is this the first instance of the application? */
#ifndef __NT__
    if( WdeFirstInst ) {
#endif
        /* if so call the routine to initialize the application */
        if( !WdeInit( hinstCurrent ) ) {
            if( IsDDE ) {
                WdeDDEDumpConversation( hinstCurrent );
            }
            return( FALSE );
        }
#ifndef __NT__
    }
#if 0
    else if( IsDDE ) {
        WdeDisplayErrorMsg( WDE_NOMULTIPLEINSTANCES );
        WdeDDEDumpConversation( hinstCurrent );
        return( FALSE );
    } else {
        win = FindWindow( WdeMainClass, NULL );
        if( win != NULL ) {
            child = GetLastActivePopup( win );
            PostMessage( win, WM_USER, 0, 0 );
            BringWindowToTop( win );
            if( child != (HWND)NULL && child != win ) {
                BringWindowToTop( child );
            }
        } else {
            WdeDisplayErrorMsg( WDE_NOMULTIPLEINSTANCES );
        }
        return( FALSE );
    }
#endif
#endif

    if( !WdeInitInst( hinstCurrent ) ) {
        WdeDisplayErrorMsg( WDE_INITFAILED );
        if( IsDDE ) {
            WdeDDEDumpConversation( hinstCurrent );
        }
        return( FALSE );
    }

    if( IsDDE ) {
        if( WdeDDEStart( hinstCurrent ) ) {
            if( !WdeDDEStartConversation() ) {
                WdeDisplayErrorMsg( WDE_DDEINITFAILED );
                PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 );
            }
        } else {
            WdeDisplayErrorMsg( WDE_DDEINITFAILED );
            PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 );
        }
    }

    WdeEnableMenuInput( TRUE );

    if( setjmp( WdeEnv ) ) {
        PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 );
        if( setjmp( WdeEnv ) ) {
            WdeDisplayErrorMsg( WDE_EXCEPTIONDURINGABNORMALEXIT );
            exit( -1 );
        }
        WdePushEnv( &WdeEnv );
    } else {
        WdePushEnv( &WdeEnv );
        WdeProcessArgs( _argv, _argc );
    }

    if( !WdeGetNumRes() ) {
        WdeCreateNewResource( NULL );
    }

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

    if( IsDDE ) {
        WdeDDEEndConversation();
    }

    WdePopEnv( &WdeEnv );

    if( IsDDE ) {
        WdeDDEEnd();
    }

    WRFini();

    return( msg.wParam );
}