BOOL CPPageFileMediaInfo::OnInitDialog()
{
	__super::OnInitDialog();

	if (!m_pCFont) {
		m_pCFont = DNew CFont;
	}

	if (!m_pCFont) {
		return TRUE;
	}

	MediaInfo MI;

	MI.Option(_T("ParseSpeed"), _T("0"));
	MI.Option(_T("Language"), mi_get_lang_file());
	MI.Option(_T("Complete"));
	MI.Open(m_fn.GetString());
	MI_Text = MI.Inform().c_str();
	MI.Close();

	if (!MI_Text.Find(_T("Unable to load"))) {
		MI_Text.Empty();
	}

	LOGFONT lf;
	memset(&lf, 0, sizeof(lf));
	lf.lfPitchAndFamily = DEFAULT_PITCH | FF_MODERN;

	LPCTSTR fonts[] = {_T("Consolas"), _T("Lucida Console"), _T("Courier New"), _T("") };

	UINT i = 0;
	BOOL success;

	PAINTSTRUCT ps;
	CDC* cDC = m_mediainfo.BeginPaint(&ps);

	do {
		wcscpy_s(lf.lfFaceName, LF_FACESIZE, fonts[i]);
		lf.lfHeight = -MulDiv(8, cDC->GetDeviceCaps(LOGPIXELSY), 72);
		success = IsFontInstalled(fonts[i]) && m_pCFont->CreateFontIndirect(&lf);
		i++;
	} while (!success && i < _countof(fonts));

	m_mediainfo.SetFont(m_pCFont);
	m_mediainfo.SetWindowText(MI_Text);

	m_mediainfo.EndPaint(&ps);

	OldControlProc = (WNDPROC)SetWindowLongPtr(m_mediainfo.m_hWnd, GWLP_WNDPROC, (LONG_PTR)ControlProc);

	return TRUE;
}
Exemple #2
0
int Main( int argc, char argv[MAXARG][MAXARGLEN] )
{
    int   k;
    int   n;
    char* p;
    int   status;
    char* argp[MAXARG+1];
    char  buffer[8192];
    char  rootdir[MAX_PATH];
    char  our_cmd[MAX_PATH];
    char  console[MAX_PATH];
    char  unix_rootdir[MAX_PATH];




    // Get the Staden Package directory
    if( !::GetModuleFileName(0,rootdir,MAX_PATH) )
    {
        ::MessageBox(0,"Unable to get Staden Package directory!", "SPRUN.EXE Message", MB_OK );
        return -3;
    }
    _strlwr( rootdir );
    p = strstr( rootdir, "\\sprun.exe" );
   *p = 0;



   // Create a copy of root directory in unix format
   strcpy( unix_rootdir, rootdir );
   p = unix_rootdir;
   while( *p )
   {
      if( *p == '\\' )
        *p = '/';
      p++;
   }



#ifdef RUNTIME_FONT_INSTALL
    /* Install the pregap font if it isn't already installed */
    if( IsFontInstalled("Pregap") == false )
    {
        //MessageBox(0,"Installing pregap.ttf","Debug",MB_OK);
        strcpy( buffer, rootdir );
        strcat( buffer, "\\windows-bin\\pregap.ttf" );
        ::GetShortPathName( buffer, buffer, MAX_PATH );
        _strlwr( buffer );
        if( !AddFontResource(buffer) )
            ::MessageBox(0,"Warning: Failed to install font pregap.ttf.","SPRUN.EXE Message", MB_OK );
        else
            ::SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0 );
    }
#endif



    // Add Staden Package environment variables to current environment
    sprintf( buffer, "TK_LIBRARY=%s/lib/tk", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "TCL_LIBRARY=%s/lib/tcl", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "STADLIB=%s/lib", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "STADTABL=%s/tables", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "STADENROOT=%s", unix_rootdir );
    _putenv( buffer );
    _putenv( "MACHINE=windows" );



    // Prepend our paths to PATH environment variable. Normally this is done
    // automatically by the App Path registry entry for sprun.exe, however if
    // we want to run more a remote copy of gap4 then the App Path will be
    // invalid, so we need to do it here again just to be sure we pick up the
    // appropriate dlls.
    sprintf( buffer, "PATH=%s\\windows-bin;%s\\lib\\windows-binaries;", rootdir, rootdir );
    p = getenv( "PATH" );
    assert(p);
    strcat( buffer, p );
    _putenv( buffer );
    


    // Set default command to be winstash, don't use quotes otherwise execve
    // won't work properly, but quotes are required in argp[0]!
    strcpy( our_cmd, rootdir );
    strcat( our_cmd, "\\windows-bin\\wish.exe" );



	// Get command console
    p = getenv( "COMSPEC" );
    if(!p)
    {
        // Assume windows NT
        ::GetWindowsDirectory( console, MAX_PATH );
        strcat( console, "\\system32\\cmd.exe" );
    }
    else
    {
        // Console is specified by environment
        strcpy( console, p );
    }
    


    // Construct suitable argp array for execve
    k = 1;
    n = 1;
    while( n<argc )
    {
        // -c option runs the console with the staden environment intact
        // on windows NT platforms only. Command.com on win9x is crippled
        // in that it ignores the environment given to execve()
        if( (argv[n][0]=='-') && (argv[n][1]=='c') && !argv[n][2] )
            strcpy( our_cmd, console );
        else
        {
            argp[n] = &argv[n][0];
            k++;
        }
        n++;
    }
    argp[k] = 0;
    assert(k<(MAXARG+1));



    // Assemble argv[0], we must put quotes around this
    strcpy( buffer, "\"" );
    strcat( buffer, our_cmd );
    strcat( buffer, "\"" );
    argp[0] = buffer;



    // Execute the program
    status = _execve( our_cmd, argp, _environ );
    if( status == -1 )
    {
        sprintf( buffer, "Sorry: Unable to execute %s - (%d).", our_cmd, errno );
        ::MessageBox(0,buffer,"SPRUN.EXE Message", MB_OK );
    }
    return 0;
}