/**
* Set some environment variablesSCI, and some others
*/
void SciEnvForWindows(void)
{
    char *SCIPathName = getScilabDirectory(TRUE);

    /* Correction Bug 1579 */
    if (!IsTheGoodShell())
    {
        if ( (!Set_Shell()) || (!IsTheGoodShell()))
        {
            MessageBox(NULL,
                       "Please modify ""ComSpec"" environment variable.\ncmd.exe on W2K and more.",
                       "Warning", MB_ICONWARNING | MB_OK);
        }
    }

    SetScilabEnvironmentVariables(SCIPathName);
    if (SCIPathName)
    {
        FREE(SCIPathName);
        SCIPathName = NULL;
    }
}
Exemplo n.º 2
0
/*--------------------------------------------------------------------------*/
static DWORD WINAPI ThreadSplashScreen(LPVOID lpParam)
{
    char *ScilabDirectory = NULL;
    char *ImageFilename = NULL;
    wchar_t *wImageFilename = NULL;

    size_t len = 0;
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;

    ULONG_PTR gdiplusToken = NULL;
    Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    HINSTANCE hInstanceThisDll = (HINSTANCE)GetModuleHandle("scilab_windows");

    ScilabDirectory = getScilabDirectory(TRUE);
    if (ScilabDirectory == NULL)
    {
        return 0;
    }

    len = strlen(FORMAT_FULLPATH_SPLASH_IMAGE) + strlen(ScilabDirectory) + 1;
    ImageFilename = (char*)MALLOC(sizeof(char) * len);
    if (ImageFilename == NULL)
    {
        return 0;
    }

    sprintf(ImageFilename, FORMAT_FULLPATH_SPLASH_IMAGE, ScilabDirectory);
    FREE(ScilabDirectory);
    ScilabDirectory = NULL;

    wImageFilename = to_wide_string(ImageFilename);
    FREE(ImageFilename);
    ImageFilename = NULL;
    if (wImageFilename == NULL)
    {
        return 0;
    }

    pImage = Gdiplus::Image::FromFile((const WCHAR *)wImageFilename);
    FREE(wImageFilename);
    wImageFilename = NULL;
    if (pImage == NULL)
    {
        return 0;
    }

    WNDCLASS wndcls = {0};

    wndcls.style = CS_HREDRAW | CS_VREDRAW;
    wndcls.lpfnWndProc = SplashWndProc;
    wndcls.hInstance = GetModuleHandle(NULL);
    wndcls.hCursor = LoadCursor(NULL, IDC_APPSTARTING);
    wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    wndcls.lpszClassName = SPLASH_WINDOW_CLASSNAME;
    wndcls.hIcon = LoadIcon(wndcls.hInstance, (char*)MAKEINTRESOURCE(IDI_APPLICATION));

    if (!RegisterClass(&wndcls))
    {
        if (GetLastError() != 0x00000582) // already registered
        {
            return 0;
        }
    }

    // try to find monitor where mouse was last time
    POINT point = {0};
    MONITORINFO mi = {sizeof(MONITORINFO), 0};
    HMONITOR hMonitor = 0;
    RECT rcArea = {0};

    ::GetCursorPos(&point);
    hMonitor = ::MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);
    if (::GetMonitorInfo(hMonitor, &mi))
    {
        rcArea.left = (mi.rcMonitor.right + mi.rcMonitor.left - pImage->GetWidth()) / 2;
        rcArea.top = (mi.rcMonitor.top + mi.rcMonitor.bottom - pImage->GetHeight()) / 2;
    }
    else
    {
        SystemParametersInfo(SPI_GETWORKAREA, NULL, &rcArea, NULL);
        rcArea.left = (rcArea.right + rcArea.left - pImage->GetWidth()) / 2;
        rcArea.top = (rcArea.top + rcArea.bottom - pImage->GetHeight()) / 2;
    }

    HWND hdlg = CreateWindowEx(WS_EX_TOOLWINDOW,
                               SPLASH_WINDOW_CLASSNAME,
                               SPLASH_WINDOW_CLASSNAME,
                               WS_CLIPCHILDREN | WS_POPUP,
                               rcArea.left,
                               rcArea.top,
                               pImage->GetWidth(),
                               pImage->GetHeight(),
                               NULL,
                               NULL,
                               wndcls.hInstance,
                               NULL);

    if (hdlg == NULL)
    {
        return 0;
    }

    ShowWindow(hdlg, SW_SHOWNORMAL);
    UpdateWindow(hdlg);
    SetWindowPos(hdlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);

    while (!stopSplashScreen(20, 1000))
    {
        Sleep(20);
    }

    DestroyWindow(hdlg);
    return 0;
}
Exemplo n.º 3
0
/*--------------------------------------------------------------------------*/ 
int Console_Main(int argc, char **argv)
{
    int iExitCode = 0;
    int argcount = 0, lpath = 0;
    InitScriptType pathtype = SCILAB_SCRIPT;
    char *path = NULL;
    char *ScilabDirectory = NULL;
    int i=0;

    my_argc = -1;

    forbiddenToUseScilab();

    setScilabMode(SCILAB_NW);

    setCommandLineArgs(argv, argc);

    for (i=0;i<argc;i++)
    {
        my_argv[i] = argv[i];
    }
    my_argc = argc;

    ScilabDirectory = getScilabDirectory(FALSE);

    if (ScilabDirectory == NULL)
    {
        // This message must never occur, but ...
        MessageBox (NULL, "ERROR" , "Cannot determine the Scilab directory (SCI).", MB_ICONSTOP | MB_OK);
        exit(1);
    }
    else
    {
        FREE(ScilabDirectory);
        ScilabDirectory = NULL;
    }

    argcount = my_argc;
    while (argcount > 0)
    {
        argcount--;
        if (_stricmp (my_argv[argcount], "-NS") == 0) startupf = 1;
        else if ( _stricmp(my_argv[argcount],"-NB") == 0) { sci_show_banner = 0; }
        else if (_stricmp (my_argv[argcount], "-NWNI") == 0)
        {
            setScilabMode(SCILAB_NWNI);
        }
        else if (_stricmp (my_argv[argcount], "-F") == 0 && argcount + 1 < my_argc)
        {
            path = my_argv[argcount + 1];
            lpath = (int) strlen (my_argv[argcount + 1]);
        }
        else if (_stricmp (my_argv[argcount], "-E") == 0 && argcount + 1 < my_argc)
        {
            path = my_argv[argcount + 1];
            lpath = (int) strlen (my_argv[argcount + 1]);
            pathtype = SCILAB_CODE;
        }
        else if ( _stricmp(my_argv[argcount],"-MEM") == 0 && argcount + 1 < my_argc)
        {
            memory = Max(atoi( my_argv[argcount + 1]),MIN_STACKSIZE );
        } 
        else if ( _stricmp(my_argv[argcount],"-TEXMACS") == 0 )
        {
            setScilabMode(SCILAB_NWNI);
            settexmacs();
        }
        else if ( _stricmp(my_argv[argcount],"-NOGUI") == 0 )
        {
            setScilabMode(SCILAB_NWNI);
        }
        else if ( (_stricmp (my_argv[argcount],"-VERSION")==0) ||
            (_stricmp (my_argv[argcount],"-VER")==0) )
        {
            disp_scilab_version();
            exit(1);
        }
        else if ( _stricmp(my_argv[argcount],"-L") == 0 && argcount + 1 < my_argc)
        {
            char *language = my_argv[argcount + 1];
            setLanguageFromCommandLine(language);
        }
        else if ( (_stricmp (my_argv[argcount],"-H")==0) ||
            (_stricmp (my_argv[argcount],"-?")==0) ||
            (_stricmp (my_argv[argcount],"-HELP")==0) )
        {
            printf("scilex <Options> : run Scilab.\n");
            printf("Arguments : passes Arguments to Scilab, This Arguments can be retreived\n  by the Scilab function sciargs.\n"); 
            printf("-e Instruction : execute the scilab instruction given in Instruction argument.\n"); 
            printf("-f File : execute the scilab script given in File argument.\n"); 
            printf("  '-e' and '-f' options are mutually exclusive.\n\n"); 
            printf("-l lang : it fixes the user language.\n\n" ); 
            printf("-mem N : set the initial stacksize.\n"); 
            printf("-ns : if this option is present the startup file scilab.start is not executed.\n"); 
            printf("-nb : if this option is present then scilab welcome banner is not displayed.\n"); 
            printf("-nouserstartup : don't execute user startup files SCIHOME/.scilab or SCIHOME/scilab.ini.\n"); 
            printf("-nw : start Scilab without specialized Scilab Window.\n"); 
            printf("-nwni : start Scilab without user interaction (batch mode).\n"); 
            printf("-nogui : start Scilab without GUI,tcl/tk and user interaction (batch mode).\n"); 
            printf("-texmacs : reserved for WinTeXMacs.\n"); 
            printf("-version : print product version and exit.\n"); 
            printf("\n");
            exit(1);
        }
    }

    if (!with_module("jvm")) 
    {
        /* no module jvm then we force NWNI mode */
        setScilabMode(SCILAB_NWNI);
    }

    if (getScilabMode() != SCILAB_NWNI) CreateScilabHiddenWndThread();

    if ( (getScilabMode() == SCILAB_NWNI) || (getScilabMode() == SCILAB_NW) )
    {
        SaveConsoleColors();
        if (getScilabMode() == SCILAB_NW)
        {
            RenameConsole();
            UpdateConsoleColors();
        }

        iExitCode = sci_windows_main (&startupf, path, (InitScriptType)pathtype, &lpath,memory);

    }
    else
    {
        MessageBox(NULL,"-nw or -nwni not found","ERROR",MB_ICONWARNING);
        iExitCode = 1;
    }
    return iExitCode;
}