示例#1
0
BOOL CResModule::ExtractResources(LPCTSTR lpszSrcLangDllPath, LPCTSTR lpszPoFilePath, BOOL bNoUpdate)
{
	m_hResDll = LoadLibrary(lpszSrcLangDllPath);
	if (m_hResDll == NULL)
		MYERROR;
	
	size_t nEntries = 0;
	// fill in the std::map with all translatable entries

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Extracting StringTable...."));
	EnumResourceNames(m_hResDll, RT_STRING,  EnumResNameCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d Strings\n"), m_StringEntries.size());
	nEntries = m_StringEntries.size();

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Extracting Dialogs........"));
	EnumResourceNames(m_hResDll, RT_DIALOG,  EnumResNameCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d Strings\n"), m_StringEntries.size()-nEntries);
	nEntries = m_StringEntries.size();

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Extracting Menus.........."));
	EnumResourceNames(m_hResDll, RT_MENU,    EnumResNameCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d Strings\n"), m_StringEntries.size()-nEntries);
	nEntries = m_StringEntries.size();

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Extracting Accelerators..."));
	EnumResourceNames(m_hResDll, RT_ACCELERATOR, EnumResNameCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d Accelerators\n"), m_StringEntries.size()-nEntries);
	nEntries = m_StringEntries.size();

	// parse a probably existing file and update the translations which are
	// already done
	m_StringEntries.ParseFile(lpszPoFilePath, !bNoUpdate);

	// at last, save the new file
	if (!m_StringEntries.SaveFile(lpszPoFilePath))
		goto DONE_ERROR;

	FreeLibrary(m_hResDll);
	return TRUE;

DONE_ERROR:
	if (m_hResDll)
		FreeLibrary(m_hResDll);
	return FALSE;
}
示例#2
0
BOOL CResModule::ExtractResources(std::vector<std::wstring> filelist, LPCTSTR lpszPOFilePath, BOOL bNoUpdate)
{
	BOOL bRet = TRUE;
	for (std::vector<std::wstring>::iterator I = filelist.begin(); I != filelist.end(); ++I)
	{
		m_hResDll = LoadLibrary(I->c_str());
		if (m_hResDll == NULL)
			MYERROR;

		size_t nEntries = m_StringEntries.size();
		// fill in the std::map with all translatable entries

		if (!m_bQuiet)
			_ftprintf(stdout, _T("Extracting StringTable...."));
		EnumResourceNames(m_hResDll, RT_STRING,  EnumResNameCallback, (long)this);
		if (!m_bQuiet)
			_ftprintf(stdout, _T("%4d Strings\n"), m_StringEntries.size()-nEntries);
		nEntries = m_StringEntries.size();

		if (!m_bQuiet)
			_ftprintf(stdout, _T("Extracting Dialogs........"));
		EnumResourceNames(m_hResDll, RT_DIALOG,  EnumResNameCallback, (long)this);
		if (!m_bQuiet)
			_ftprintf(stdout, _T("%4d Strings\n"), m_StringEntries.size()-nEntries);
		nEntries = m_StringEntries.size();

		if (!m_bQuiet)
			_ftprintf(stdout, _T("Extracting Menus.........."));
		EnumResourceNames(m_hResDll, RT_MENU,    EnumResNameCallback, (long)this);
		if (!m_bQuiet)
			_ftprintf(stdout, _T("%4d Strings\n"), m_StringEntries.size()-nEntries);
		nEntries = m_StringEntries.size();
		if (!m_bQuiet)
			_ftprintf(stdout, _T("Extracting Accelerators..."));
		EnumResourceNames(m_hResDll, RT_ACCELERATOR, EnumResNameCallback, (long)this);
		if (!m_bQuiet)
			_ftprintf(stdout, _T("%4d Accelerators\n"), m_StringEntries.size()-nEntries);
		nEntries = m_StringEntries.size();

		// parse a probably existing file and update the translations which are
		// already done
		m_StringEntries.ParseFile(lpszPOFilePath, !bNoUpdate);
		
		FreeLibrary(m_hResDll);
		continue;
	}
	
	// at last, save the new file
	if (bRet)
		return m_StringEntries.SaveFile(lpszPOFilePath);
	return FALSE;
}
示例#3
0
static BOOL CALLBACK FBALocaliseEnumResTypeProc(HMODULE /* hModule */, LPTSTR lpszType, LONG_PTR lParam)
{
	if (lpszType == RT_DIALOG) {
		EnumResourceNames(NULL, lpszType, &FBALocaliseEnumResourceNamesDialog, lParam);
	}
	if (lpszType == RT_MENU) {
		EnumResourceNames(NULL, lpszType, &FBALocaliseEnumResourceNamesMenu, lParam);
	}
	if (lpszType == RT_STRING) {
		EnumResourceNames(NULL, lpszType, &FBALocaliseEnumResourceNamesString, lParam);
	}

	return TRUE;
}
示例#4
0
void CIme::SetImeIcon()
{
	HICON hIcon = NULL;
	if( ImmIsIME( m_hCurKL ) )
	{
		char buf[256];
		ImmGetIMEFileName( m_hCurKL, buf, 256 );
		HMODULE hDll = LoadLibrary( buf );
		EnumResourceNames( hDll, RT_GROUP_ICON, (ENUMRESNAMEPROC)EnumResNameProc, (int32)(void*)&hIcon );
		FreeLibrary( hDll );
	}

	m_ImeImage.Release();
	if( hIcon )
	{
		IGraphic* pGraphic = CGraphic::GetInst();

		CFRect rt = CFRect( 0, 0, 16, 16 );
		m_ImeImage.AddImage( pGraphic, -1, NULL, &rt, CFPos(0.0f, 0.0f), 0xffffffff );
		pGraphic->CreateTexture( 16, 16, TF_UNKNOW, &m_ImeImage.GetImage(0).pTexture );

		ICONINFO Info; 
		GetIconInfo( hIcon, &Info );
		m_ImeImage.GetImage(0).pTexture->FillFromHBitmap( Info.hbmColor, Info.hbmMask );
		::DestroyIcon( hIcon );
	}

	OnImeChanged();
}
//****************************************************************************
//
// Function Name: RHeadlineProportionPage::OnInitDialog
//
// Description:   Handles dialog initialization
//
// Returns:       TRUE
//
// Exceptions:	   None
//
//****************************************************************************
BOOL RHeadlineProportionPage::OnInitDialog() 
{
	CDialog::OnInitDialog();

	try
	{
		if (!m_ilImageList.Create( (uWORD) m_uiResID, kImageWidth, kImageHeight, 0, CLR_NONE ))
		{
			throw kResource ;
		}

		//
		// Set up the image grid control
		//
		m_gcImageList.SetImageList( &m_ilImageList, kImageCount ) ;
		m_gcImageList.SizeCellsToClient( kNumRows, kNumCols ) ;

		EnumResourceNames( 
			AfxGetResourceHandle(),				// resource-module handling
			_T("HEADLINE_PROPORTION"),			// pointer to resource type 
			(ENUMRESNAMEPROC) SelectResItem,	// pointer to callback function 
			(LONG) this ) ; 						// application-defined parameter 
	}
	catch (...)
	{
		// End the dialog, and let who ever
		// created us handle any errors.
		EndDialog( IDCANCEL ) ;
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#6
0
bool Resources::EnumResources(LPCWSTR type, vector <wstring>& resources)
{
	HMODULE hInstance;

	hInstance = GetModuleHandle(NULL);
	return EnumResourceNames(hInstance, type, EnumResNameProcCallback, (LONG_PTR) &resources) == TRUE;	
}  
示例#7
0
文件: ui.cpp 项目: fengabe/winsparkle
wxIcon GetApplicationIcon()
{
    HMODULE hParentExe = GetModuleHandle(NULL);
    if ( !hParentExe )
        return wxNullIcon;

    LPTSTR iconName = 0;
    EnumResourceNames(hParentExe, RT_GROUP_ICON, GetFirstIconProc, (LONG_PTR)&iconName);

    if ( GetLastError() != ERROR_SUCCESS && GetLastError() != ERROR_RESOURCE_ENUM_USER_STOP )
        return wxNullIcon;

    HANDLE hIcon = LoadImage(hParentExe, iconName, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR);

    if ( !IS_INTRESOURCE(iconName) )
        free(iconName);

    if ( !hIcon )
        return wxNullIcon;

    wxIcon icon;
    icon.SetHICON(static_cast<WXHICON>(hIcon));
    icon.SetWidth(48);
    icon.SetHeight(48);

    return icon;
}
示例#8
0
BOOL CVersionInfo::LoadVersionInfoResource(const CString& strModulePath, CVersionInfoBuffer &viBuf, LPCTSTR lpszResourceId, WORD wLangId)
{
	HRSRC hResInfo; 

	HMODULE hModule = LoadLibraryEx(strModulePath, NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
	if (NULL == hModule)
		return FALSE;

	if ((NULL == lpszResourceId) && (wLangId == 0xFFFF))
	{
		//Load first RT_VERSION resource that will be found
		
		m_lpszResourceId = NULL;

		EnumResourceNames(hModule, RT_VERSION, (ENUMRESNAMEPROC)EnumResourceNamesFuncFindFirst, (LONG_PTR)this);
		
		if (NULL == m_lpszResourceId)
		{
			FreeLibrary(hModule);
			return FALSE;
		}
		
		// Now the m_lpszResourceId must be the name of the resource
		m_wLangId = 0xFFFF;
		EnumResourceLanguages(hModule, RT_VERSION, m_lpszResourceId, (ENUMRESLANGPROC)EnumResourceLangFuncFindFirst, (LONG_PTR)this);

		// Found resource, copy the ID's to local vars
		lpszResourceId = m_lpszResourceId;
		wLangId = m_wLangId;
	}

	hResInfo = FindResourceEx(hModule, RT_VERSION, lpszResourceId, wLangId); 
	// Write the resource language to the resource information file. 

	DWORD dwSize = SizeofResource(hModule, hResInfo);
	if (dwSize)
	{
		HGLOBAL hgRes = LoadResource(hModule, hResInfo);
		if (hgRes)
		{
			LPVOID lpMemory = LockResource(hgRes);
			if (lpMemory)
			{
				viBuf.Write(lpMemory,dwSize);
				
				UnlockResource(hgRes);
				FreeLibrary(hModule);
				return TRUE;
			}
		}
	}

	FreeLibrary(hModule);
	return FALSE;

}
示例#9
0
bool CheckResources()
{
	g_uTotalSize = 0;
	g_uResNumber = 0;
	EnumResourceNames(AfxGetInstanceHandle(), RT_GROUP_ICON, EnumResNameProc, 0);
	TRACE("RT_GROUP_ICON resources: %u (%u bytes)\n", g_uResNumber, g_uTotalSize);

	g_uTotalSize = 0;
	g_uResNumber = 0;
	EnumResourceNames(AfxGetInstanceHandle(), RT_ICON, EnumResNameProc, 0);
	TRACE("RT_ICON resources: %u (%u bytes)\n", g_uResNumber, g_uTotalSize);

	g_uTotalSize = 0;
	g_uResNumber = 0;
	EnumResourceNames(AfxGetInstanceHandle(), RT_BITMAP, EnumResNameProc, 0);
	TRACE("RT_BITMAP resources: %u (%u bytes)\n", g_uResNumber, g_uTotalSize);

	return true;
}
示例#10
0
BOOL CALLBACK
enum_types (HMODULE source,
	    LPTSTR  type,
	    LONG    param)
{
  if (EnumResourceNames (source, type, enum_names, param) == 0)
    fprintf (stderr, "EnumResourceNames() failed: %s\n",
	     g_win32_error_message (GetLastError ()));
  return TRUE;
}
示例#11
0
WORD getMaxIconId(TCHAR* lpFileName)
{
	WORD nMaxID = 0;
	HINSTANCE hLib = LoadLibraryEx(lpFileName,NULL,DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
	if(hLib == NULL) { _tprintf(_T("Unable to load library '%s'\n"), lpFileName); return 0xFFFF; }
	// Enumerate icon "names" (IDs) to get next available ID
	if(!EnumResourceNames(hLib, RT_ICON, (ENUMRESNAMEPROC)getMaxIconId_EnumNamesFunc,(LONG_PTR)&nMaxID)) { _tprintf(_T("Unable to enum icons\n")); return 0xFFFF; }	
	FreeLibrary(hLib);
	IFDEBUG( _tprintf(_T("MaxIcon=%d\n"), nMaxID); )
	return nMaxID;
示例#12
0
//    FUNCTION: EnumTypesFunc(HANDLE, LPSTR, LONG)
//
//    PURPOSE:  Resource type callback
BOOL EnumTypesFunc(
		HMODULE hModule,  // module handle
		LPTSTR lpType,    // address of resource type
		LONG lParam)      // extra parameter, could be
// used for error checking
{
	TCHAR szBuffer[80];  // print buffer for info file
	DWORD cbWritten;     // number of bytes written to resource info file
	size_t cbString;
	HRESULT hResult;

	// Write the resource type to a resource information file.
	// The type may be a string or an unsigned decimal
	// integer, so test before printing.
	if (!IS_INTRESOURCE(lpType))
	{
		hResult = StringCchPrintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), TEXT("Type: %s\r\n"), lpType);
		if (FAILED(hResult))
		{
			// Add code to fail as securely as possible.
			return FALSE;
		}
	}
	else
	{
		hResult = StringCchPrintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), TEXT("Type: %u\r\n"), (USHORT)lpType);
		if (FAILED(hResult))
		{
			// Add code to fail as securely as possible.
			return FALSE;
		}
	}

	hResult = StringCchLength(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), &cbString);
	if (FAILED(hResult))
	{
		// Add code to fail as securely as possible.
		return FALSE;
	}

	WriteFile(g_hFile, szBuffer, (DWORD) cbString, &cbWritten, NULL);
	// Find the names of all resources of type lpType.
	EnumResourceNames(hModule,
			lpType,
			(ENUMRESNAMEPROC)EnumNamesFunc,
			0);

	return TRUE;
}
示例#13
0
wxIcon GetApplicationIcon(int size)
{
    HMODULE hParentExe = GetModuleHandle(NULL);
    if ( !hParentExe )
        return wxNullIcon;

    LPTSTR iconName = 0;
    EnumResourceNames(hParentExe, RT_GROUP_ICON, GetFirstIconProc, (LONG_PTR)&iconName);

    if ( GetLastError() != ERROR_SUCCESS && GetLastError() != ERROR_RESOURCE_ENUM_USER_STOP )
        return wxNullIcon;

    wxIcon icon = LoadNamedIcon(hParentExe, iconName, size);

    if ( !IS_INTRESOURCE(iconName) )
        free(iconName);

    return icon;
}
示例#14
0
BOOL CALLBACK DlgMain_InstallFiles(HWND hWnd)
{
	HCURSOR hCursor = SetCursor(LoadCursor(0, IDC_WAIT));
	HINSTANCE hModule = GetModuleHandle(0);
	int count = SendDlgItemMessage(hWnd, 100, LB_GETCOUNT , 0, 0);
	int index = 0;
	TCHAR path[8 * MAX_PATH];
	int cchPath;
	if (IsDlgButtonChecked(hWnd, 201))
	{
		cchPath = GetSystemDirectory(path, 4 * MAX_PATH);
	}
	else
	{
		cchPath = GetDlgItemText(hWnd, 203, path, 5 * MAX_PATH);
		int cchName = PathGetTailLength(path);
		if (cchName < cchPath)
		{
			cchPath -= cchName;
		}
	}
	if (cchPath != 3 || path[1] != ':')
	{
		path[cchPath++] = '\\';
	}
	LPTSTR name = path + cchPath;
	while (index < count)
	{
		if (SendDlgItemMessage(hWnd, 100, LB_GETSEL, index, 0))
		{
			int cchName = SendDlgItemMessage(hWnd, 100, LB_GETTEXT, index, (LPARAM)name);
			InstallFile(hWnd, name, "Merge7z", path, cchPath);
		}
		++index;
	}
	if (IsDlgButtonChecked(hWnd, 205))
	{
		EnumResourceNames(GetModuleHandle(0), "7-ZIP", fnInstallFiles, (LONG)hWnd);
	}
	SetCursor(hCursor);
	return TRUE;
}
//****************************************************************************
//
// Function Name: ApplyData
//
// Description:   Applies an HeadlineDataStruct attribute data
//                to the Headline proportion controls
//
// Returns:       None
//
// Exceptions:	   None
//
//****************************************************************************
void RHeadlineProportionPage::ApplyData( RHeadlineInterface* pInterface )
{
	TpsAssert( pInterface, "Invalid Interface!" ) ;

	pInterface->GetScale1( m_uwScale1 ) ;
	pInterface->GetScale2( m_uwScale2 ) ;
	pInterface->GetScale3( m_uwScale3 ) ;

	UINT uiResID = m_uiResID ;
	m_uiResID    = IDB_HEADLINE_PROPORTION ;

	BOOLEAN fDistort ;
	pInterface->GetDistort( fDistort ) ;

	if (fDistort)
	{
		m_uiResID = IDB_HEADLINE_PROPORTION_DISTORT ;
	}

	if (GetSafeHwnd())
	{
		if (uiResID != m_uiResID)
		{
			if (!m_ilImageList.Create( (uWORD) m_uiResID, kImageWidth, kImageHeight, 0, CLR_NONE ))
			{
				// Let the user know there is
				// a reason there staring at
				// a blank page.
				RAlert rAlert ;
				rAlert.AlertUser( STRING_ERROR_ACC_OUT_OF_MEMORY ) ;
			}
		}

		// Set the image selection
		EnumResourceNames( 
			AfxGetResourceHandle(),				// resource-module handling
			_T("HEADLINE_PROPORTION"),			// pointer to resource type 
			(ENUMRESNAMEPROC) SelectResItem,	// pointer to callback function 
			(LONG) this ) ; 						// application-defined parameter 
	}
}
示例#16
0
/*
* supGetMainIcon
*
* Purpose:
*
* Extract main icon if it exists in executable image.
*
*/
HICON supGetMainIcon(
	_In_ LPWSTR lpFileName, 
	_In_ INT cx,
	_In_ INT cy
	)
{
	HMODULE hModule;
	ENUMICONINFO pin;

	pin.cx = cx;
	pin.cy = cy;
	pin.hIcon = 0;

	hModule = LoadLibraryEx(lpFileName, 0, LOAD_LIBRARY_AS_DATAFILE);
	if (hModule != NULL) {
		EnumResourceNames(hModule, RT_GROUP_ICON, (ENUMRESNAMEPROC)&supEnumIconCallback, 
			(LONG_PTR)&pin);
		FreeLibrary(hModule);
	}
	return pin.hIcon;
}
示例#17
0
void    IImportFON( HWND hWnd, const char *path )
{
    // FON files are really just resource modules
    IMakeNewFont();
    HMODULE file = LoadLibraryEx( path, nil, LOAD_LIBRARY_AS_DATAFILE | DONT_RESOLVE_DLL_REFERENCES );
    if( file == nil )
    {
        char msg[ 512 ], msg2[ 1024 ];

        FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 
                        nil, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)msg, sizeof( msg ), nil );

        sprintf( msg2, "Failure importing FON file: can't open as resource library (%s)", msg );
        MessageBox( hWnd, msg2, "Error", MB_OK | MB_ICONEXCLAMATION );
    }
    else
    {
        hsTArray<ResRecord *>   resList;
        
        if( EnumResourceNames( file, "Font", ResEnumProc, (LPARAM)&resList ) )
        {
            // Put up a list of the resources so the user can choose which one
            ResRecord *res = (ResRecord *)DialogBoxParam( gInstance, MAKEINTRESOURCE( IDD_FONCHOOSER ), hWnd, 
                                                            ResListWndProc, (LPARAM)&resList );
            if( res != nil )
            {
                // Load the resource into a ram stream
                hsRAMStream stream;

                HGLOBAL glob = LoadResource( file, res->fHandle );
                if( glob != nil )
                {
                    void *data = LockResource( glob );
                    if( data != nil )
                    {
                        stream.Write( SizeofResource( file, res->fHandle ), data );
                        stream.Rewind();

                        if( !gFont->LoadFromFNTStream( &stream ) )
                            MessageBox( hWnd, "Failure importing FON file: can't parse resource as FNT",
                                                "Error", MB_OK | MB_ICONEXCLAMATION );

                    }
                }
            }
        }
        else
        {
            char msg[ 512 ], msg2[ 1024 ];

            FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 
                            nil, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)msg, sizeof( msg ), nil );

            sprintf( msg2, "Failure importing FON file: can't enumerate resources (%s)", msg );
            MessageBox( hWnd, msg2, "Error", MB_OK | MB_ICONEXCLAMATION );
        }

        uint32_t i;
        for( i = 0; i < resList.GetCount(); i++ )
            delete resList[ i ];
        resList.Reset();

        FreeLibrary( file );
    }

    IUpdateInfo( hWnd );
}
示例#18
0
list<RsrcId> enum_rsrc_names(HMODULE h_module, LPCTSTR type) {
  list<RsrcId> result;
  EnumResourceNames(h_module, type, enum_names_proc, reinterpret_cast<LONG_PTR>(&result));
  return result;
}
示例#19
0
BOOL RHeadlineDepthPage::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	try
	{
		UINT uiDepthResId = IDB_HEADLINE_DEPTHS2;
		LONG nImageCount = 0;

		if (!fShadowTabSupported)
		{
			uiDepthResId  = IDB_HEADLINE_DEPTHS;
			cResourceType = _T("HEADLINE_DEPTH");  // Do NOT localize this string;
		}

		// Get the image count
		EnumResourceNames( 
			AfxGetResourceHandle(),				// resource-module handling
			cResourceType,							// pointer to resource type 
			(ENUMRESNAMEPROC) ResCount,		// pointer to callback function 
			(LONG) &nImageCount ) ; 			// application-defined parameter 

		if (nImageCount)
		{
			if (!m_ilImageList.Create( uiDepthResId, kImageWidth, kImageHeight, 0, CLR_NONE ))
			{
				throw kResource ;
			}


			//
			// Set up the image grid control
			//
			m_gcImageList.SetImageList( &m_ilImageList, nImageCount ) ;
			m_gcImageList.SizeCellsToClient( kNumRows, kNumCols ) ;

			EnumResourceNames( 
				AfxGetResourceHandle(),				// resource-module handling
				cResourceType,							// pointer to resource type 
				(ENUMRESNAMEPROC) SelectResItem,	// pointer to callback function 
				(LONG) this ) ; 						// application-defined parameter 
		}

		// Position the angle dialog
		////////////////////////////
		CRect rectAngle ;
		CWnd* pWnd = GetDlgItem( IDC_DEPTH_STATIC ) ;
		pWnd->GetWindowRect( rectAngle ) ;
		ScreenToClient( rectAngle ) ;

		CRect rect( 1, 8, 1, 3 ) ;
		MapDialogRect( rect ) ;
		rectAngle.DeflateRect( &rect ) ;

		if (!m_wndBlendAngle.Create( NULL, "", WS_CHILD | WS_TABSTOP, rectAngle, this, (UINT) -1 ))
		{
			throw kResource ;
		}

		m_wndBlendAngle.SetWindowPos( GetDlgItem( IDC_DEPTH_STATIC ), 
			0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW ) ;

		m_btnColor.EnableWindow( m_gcImageList.GetCurSel() != 0 ) ;
	}
	catch (...)
	{
		// End the dialog, and let who ever
		// created us handle any errors.
		EndDialog( IDCANCEL ) ;
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#20
0
文件: main.c 项目: howard5888/wineT
static char *
run_tests (char *logname)
{
    int nr_of_files = 0, nr_of_tests = 0, i;
    char *tempdir, *shorttempdir;
    int logfile;
    char *strres, *eol, *nextline;
    DWORD strsize;

    SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);

    if (!logname) {
        logname = tempnam (0, "res");
        if (!logname) report (R_FATAL, "Can't name logfile.");
    }
    report (R_OUT, logname);

    logfile = open (logname, O_WRONLY | O_CREAT | O_EXCL | O_APPEND,
                    0666);
    if (-1 == logfile) {
        if (EEXIST == errno)
            report (R_FATAL, "File %s already exists.", logname);
        else report (R_FATAL, "Could not open logfile: %d", errno);
    }
    if (-1 == dup2 (logfile, 1))
        report (R_FATAL, "Can't redirect stdout: %d", errno);
    close (logfile);

    tempdir = tempnam (0, "wct");
    if (!tempdir)
        report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
    shorttempdir = strdup (tempdir);
    if (shorttempdir) {         /* try stable path for ZoneAlarm */
        strstr (shorttempdir, "wct")[3] = 0;
        if (CreateDirectoryA (shorttempdir, NULL)) {
            free (tempdir);
            tempdir = shorttempdir;
        } else free (shorttempdir);
    }
    if (tempdir != shorttempdir && !CreateDirectoryA (tempdir, NULL))
        report (R_FATAL, "Could not create directory: %s", tempdir);
    report (R_DIR, tempdir);

    xprintf ("Version 3\n");
    strres = extract_rcdata (WINE_BUILD, STRINGRES, &strsize);
    xprintf ("Tests from build ");
    if (strres) xprintf ("%.*s", strsize, strres);
    else xprintf ("-\n");
    strres = extract_rcdata (TESTS_URL, STRINGRES, &strsize);
    xprintf ("Archive: ");
    if (strres) xprintf ("%.*s", strsize, strres);
    else xprintf ("-\n");
    xprintf ("Tag: %s\n", tag);
    xprintf ("Build info:\n");
    strres = extract_rcdata (BUILD_INFO, STRINGRES, &strsize);
    while (strres) {
        eol = memchr (strres, '\n', strsize);
        if (!eol) {
            nextline = NULL;
            eol = strres + strsize;
        } else {
            strsize -= eol - strres + 1;
            nextline = strsize?eol+1:NULL;
            if (eol > strres && *(eol-1) == '\r') eol--;
        }
        xprintf ("    %.*s\n", eol-strres, strres);
        strres = nextline;
    }
    xprintf ("Operating system version:\n");
    print_version ();
    xprintf ("Test output:\n" );

    report (R_STATUS, "Counting tests");
    if (!EnumResourceNames (NULL, MAKEINTRESOURCE(TESTRES),
                            EnumTestFileProc, (LPARAM)&nr_of_files))
        report (R_FATAL, "Can't enumerate test files: %d",
                GetLastError ());
    wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]);

    report (R_STATUS, "Extracting tests");
    report (R_PROGRESS, 0, nr_of_files);
    for (i = 0; i < nr_of_files; i++) {
        get_subtests (tempdir, wine_tests+i, i);
        nr_of_tests += wine_tests[i].subtest_count;
    }
    report (R_DELTA, 0, "Extracting: Done");

    report (R_STATUS, "Running tests");
    report (R_PROGRESS, 1, nr_of_tests);
    for (i = 0; i < nr_of_files; i++) {
        struct wine_test *test = wine_tests + i;
        int j;

	for (j = 0; j < test->subtest_count; j++) {
            report (R_STEP, "Running: %s:%s", test->name,
                    test->subtests[j]);
	    run_test (test, test->subtests[j]);
        }
    }
    report (R_DELTA, 0, "Running: Done");

    report (R_STATUS, "Cleaning up");
    close (1);
    remove_dir (tempdir);
    free (tempdir);
    free (wine_tests);

    return logname;
}
示例#21
0
BOOL CResModule::CreateTranslatedResources(LPCTSTR lpszSrcLangDllPath, LPCTSTR lpszDestLangDllPath, LPCTSTR lpszPOFilePath)
{
	if (!CopyFile(lpszSrcLangDllPath, lpszDestLangDllPath, FALSE))
		MYERROR;

	int count = 0;
	do
	{
		m_hResDll = LoadLibraryEx (lpszSrcLangDllPath, NULL, LOAD_LIBRARY_AS_DATAFILE|LOAD_IGNORE_CODE_AUTHZ_LEVEL);
		if (m_hResDll == NULL)
			Sleep(100);
		count++;
	} while ((m_hResDll == NULL)&&(count < 5));

	if (m_hResDll == NULL)
		MYERROR;

	sDestFile = std::wstring(lpszDestLangDllPath);

	// get all translated strings
	if (!m_StringEntries.ParseFile(lpszPOFilePath, FALSE))
		goto DONE_ERROR;
	m_bTranslatedStrings = 0;
	m_bDefaultStrings = 0;
	m_bTranslatedDialogStrings = 0;
	m_bDefaultDialogStrings = 0;
	m_bTranslatedMenuStrings = 0;
	m_bDefaultMenuStrings = 0;
	m_bTranslatedAcceleratorStrings = 0;
	m_bDefaultAcceleratorStrings = 0;

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Translating StringTable..."));
	EnumResourceNames(m_hResDll, RT_STRING, EnumResNameWriteCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d translated, %4d not translated\n"), m_bTranslatedStrings, m_bDefaultStrings);

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Translating Dialogs......."));
	EnumResourceNames(m_hResDll, RT_DIALOG, EnumResNameWriteCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d translated, %4d not translated\n"), m_bTranslatedDialogStrings, m_bDefaultDialogStrings);

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Translating Menus........."));
	EnumResourceNames(m_hResDll, RT_MENU, EnumResNameWriteCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d translated, %4d not translated\n"), m_bTranslatedMenuStrings, m_bDefaultMenuStrings);

	if (!m_bQuiet)
		_ftprintf(stdout, _T("Translating Accelerators.."));
	EnumResourceNames(m_hResDll, RT_ACCELERATOR, EnumResNameWriteCallback, (long)this);
	if (!m_bQuiet)
		_ftprintf(stdout, _T("%4d translated, %4d not translated\n"), m_bTranslatedAcceleratorStrings, m_bDefaultAcceleratorStrings);

	FreeLibrary(m_hResDll);
	return TRUE;
DONE_ERROR:
	if (m_hResDll)
		FreeLibrary(m_hResDll);
	return FALSE;
}
示例#22
0
//    FUNCTION: EnumTypesFunc(HANDLE, LPSTR, LONG)
//
//    PURPOSE:  Resource type callback
// ----------------------------------------------------------------------------------
BOOL EnumTypesFunc(HMODULE hModule, LPTSTR lpType, LONG lParam)
{
	// Find the names of all resources of type lpType.
  EnumResourceNames(hModule, lpType, (ENUMRESNAMEPROC)EnumNamesFunc, 0);
  return TRUE;
}
示例#23
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
  int               i;
  int               iArgC;
  char              szBuf[MAX_BUF];
  char              szArgVBuf[MAX_BUF];
  char              szFileFullPath[MAX_BUF];
  char              szSeaExe[MAX_BUF];
  char              szNsZipName[MAX_BUF];
  char              szAppName[MAX_BUF];
  char              szAppPath[MAX_BUF];

#ifdef SSU_DEBUG
  char              szOutputStr[MAX_BUF];
#endif

  WIN32_FIND_DATA   findFileData;
  HANDLE            hExe;
  HANDLE            hFindFile;
  BOOL              bSelfUpdate;

  if(GetModuleFileName(NULL, szAppName, sizeof(szAppName)) == 0L)
  {
    PrintError("GetModuleFileName() failed", ERROR_CODE_SHOW);
    exit(1);
  }
  ParsePath(szAppName, szBuf, sizeof(szBuf), PP_FILENAME_ONLY);
  ParsePath(szAppPath, szBuf, sizeof(szBuf), PP_PATH_ONLY);

  if(*lpszCmdLine == '\0')
  {
    ShowUsage(szBuf);
    exit(1);
  }

  iArgC = GetArgC(lpszCmdLine);
  bSelfUpdate = FALSE;

#ifdef SSU_DEBUG
  wsprintf(szOutputStr, "ArgC: %d\n", iArgC);
  for(i = 0; i < iArgC; i++)
  {
    GetArgV(lpszCmdLine, i, szArgVBuf, sizeof(szArgVBuf));
    itoa(i, szBuf, 10);
    lstrcat(szOutputStr, "    ");
    lstrcat(szOutputStr, szBuf);
    lstrcat(szOutputStr, ": ");
    lstrcat(szOutputStr, szArgVBuf);
    lstrcat(szOutputStr, "\n");
  }
  MessageBox(NULL, szOutputStr, "Output", MB_OK);
#endif

  /* Get the first parameter */
  GetArgV(lpszCmdLine, 0, szSeaExe, sizeof(szSeaExe));
  if(lstrcmpi(szSeaExe, "-g") == 0)
  {
    /* The first parameter is "-g".
     * Create a new nszip that contains nsinstall.exe in itself */

    GetArgV(lpszCmdLine, 1, szNsZipName, sizeof(szNsZipName));
    GetArgV(lpszCmdLine, 2, szSeaExe, sizeof(szSeaExe));
    if(!FileExists(szSeaExe))
    {
      wsprintf(szBuf, "file not found: %s", szSeaExe);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }

    if(GetModuleFileName(NULL, szAppName, sizeof(szAppName)) == 0L)
    {
      PrintError("GetModuleFileName() failed", ERROR_CODE_SHOW);
      exit(1);
    }
    if(!FileExists(szAppName))
    {
      wsprintf(szBuf, "File not found: %s", szAppName);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }

    if(CopyFile(szAppName, szNsZipName, FALSE) == FALSE)
    {
      wsprintf(szBuf, "Error creating %s", szNsZipName);
      PrintError(szBuf, ERROR_CODE_SHOW);
      exit(1);
    }

    hExe = InitResource(szNsZipName);
    AddFile(hExe, szSeaExe);
    DeInitResource(hExe);
    return(0);
  }
  else
  {
    /* The first parameter is not "-g".  Assume that it's the name of the
     * self-extracting .exe to be saved as.  So lets create it only if it does not exist. */

    if(!FileExists(szSeaExe))
    {
      EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)ExtractFilesProc, (LONG)szSeaExe);

      // if still does not exist, copy nsinstall.exe to szSeaExe
      if(!FileExists(szSeaExe))
      {
        if(FileExists(DEFAULT_SEA_FILE))
          CopyFile(DEFAULT_SEA_FILE, szSeaExe, FALSE);
        else
        {
          wsprintf(szBuf, "file not found: %s", DEFAULT_SEA_FILE);
          PrintError(szBuf, ERROR_CODE_HIDE);
          exit(1);
        }
      }
    }

    if(!FileExists(szSeaExe))
    {
      wsprintf(szBuf, "file not found: %s", szSeaExe);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }
  }

  hExe = InitResource(szSeaExe);
  for(i = 1; i < iArgC; i++)
  {
    GetArgV(lpszCmdLine, i, szArgVBuf, sizeof(szArgVBuf));
    GetFullPathName(szArgVBuf, sizeof(szFileFullPath), szFileFullPath, NULL);
    hFindFile = FindFirstFile(szFileFullPath, &findFileData);

    if(hFindFile == INVALID_HANDLE_VALUE)
    {
      wsprintf(szBuf, "file not found: %s", szArgVBuf);
      PrintError(szBuf, ERROR_CODE_HIDE);
      exit(1);
    }

    do
    {
      char szFile[MAX_BUF];

      if(!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
      {
        // We need to pass to AddFile() whatever kind of path we were passed,
        // e.g. simple, relative, full
        strcpy(szFile, szFileFullPath);
        strcpy(strrchr(szFile, '\\') + 1, findFileData.cFileName);
        AddFile(hExe, szFile);
      }
    } while(FindNextFile(hFindFile, &findFileData));

    FindClose(hFindFile);
  }

  DeInitResource(hExe);
  return(0);
}
示例#24
0
BOOL EnumTypesFunc(HANDLE hModule, LPTSTR lpType, LONG lParam)
{
	return EnumResourceNames((HMODULE) hModule, lpType, (ENUMRESNAMEPROC) EnumNamesFunc, lParam);
}
示例#25
0
BOOL CALLBACK DlgMain_InitDialog(HWND hWnd, LPARAM lParam)
{
	char date[] = __DATE__; // Compilation date "MMM DD YYYY"

	TCHAR path[5 * MAX_PATH];
	wsprintf(path + GetWindowText(hWnd, path, MAX_PATH),
		" (dllbuild %04lu, %s)", dwBuild, date);
	SetWindowText(hWnd, path);

	TCHAR fmt[MAX_PATH];
	GetDlgItemText(hWnd, 205, fmt, MAX_PATH);
	wsprintf(path, fmt, SHARPEN2(VERSION7Z));
	SetDlgItemText(hWnd, 205, path);

	date[6] = '#';
	st.wYear = FindAtom(&date[6]);
	date[6] = '\0';
	date[3] = '#';
	st.wDay = FindAtom(&date[3]);
	date[3] = '\0';
	st.wMonth = 1;
	const char *month = "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec";
	while (lstrcmpi(month, date))
	{
		++st.wMonth;
		month += 4;
	} 
	st.wHour = 12;

	EnumResourceNames(GetModuleHandle(0), "Merge7z", fnPopulateList, (LONG)hWnd);
	LONG lCount = SendDlgItemMessage(hWnd, 100, LB_GETCOUNT , 0, 0);
	SendDlgItemMessage(hWnd, 100, LB_SELITEMRANGEEX, 0, lCount - 1);
	CheckRadioButton(hWnd, 201, 202, 201);
	BOOL bCommit = FALSE;
	BOOL bSelect = FALSE;
	LPTSTR lpCmdLine = GetCommandLine();
	LPTSTR lpArgLower = ArgLower(lpCmdLine);
	LPTSTR lpArgUpper = ArgUpper(lpArgLower);
	while (*(lpArgLower = ArgLower(lpArgUpper)))
	{
		TCHAR cAhead = *(lpArgUpper = ArgUpper(lpArgLower));
		*lpArgUpper = '\0';
		if (0 == lstrcmpi(lpArgLower, "/standalone"))
		{
			CheckRadioButton(hWnd, 201, 202, 202);
			SendMessage(hWnd, WM_COMMAND, 202, 0);
			CheckDlgButton(hWnd, 205, 1);
			SendMessage(hWnd, WM_COMMAND, 205, 0);
		}
		else if (0 == lstrcmpi(lpArgLower, "/select"))
		{
			int lower = -1;
			int upper = -1;
			*lpArgUpper = cAhead;
			if (*(lpArgLower = ArgLower(lpArgUpper)))
			{
				cAhead = *(lpArgUpper = ArgUpper(lpArgLower));
				*lpArgUpper = '\0';
				lower = SendDlgItemMessage(hWnd, 100, LB_FINDSTRING, -1, (LPARAM)lpArgLower);
				if (lower == -1)
				{
					MessageBox(hWnd, lpArgLower, "No match", MB_ICONSTOP);
				}
			}
			*lpArgUpper = cAhead;
			if (*(lpArgLower = ArgLower(lpArgUpper)))
			{
				cAhead = *(lpArgUpper = ArgUpper(lpArgLower));
				*lpArgUpper = '\0';
				int ahead = -1;
				while ((ahead = SendDlgItemMessage(hWnd, 100, LB_FINDSTRING, ahead, (LPARAM)lpArgLower)) > upper)
				{
					upper = ahead;
				}
				if (upper == -1)
				{
					MessageBox(hWnd, lpArgLower, "No match", MB_ICONSTOP);
				}
			}
			if (lower >= 0 && upper >= 0)
			{
				if (!bSelect)
				{
					SendDlgItemMessage(hWnd, 100, LB_SETSEL, 0, -1);
					bSelect = TRUE;
				}
				SendDlgItemMessage(hWnd, 100, LB_SELITEMRANGEEX, lower, upper);
			}
		}
		else if (0 == lstrcmpi(lpArgLower, "/commit"))
		{
			bCommit = TRUE;
		}
		else
		{
			DWORD dwAttributes = GetFileAttributes(lpArgLower);
			if (dwAttributes != 0xFFFFFFFF && dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				lstrcpy(path, lpArgLower);
				if (PathGetTailLength(path) > 1)
				{
					lstrcat(path, "\\");
				}
				lstrcat(path, "*.exe");
				CheckRadioButton(hWnd, 201, 202, 202);
				SendMessage(hWnd, WM_COMMAND, 202, 0);
				SetDlgItemText(hWnd, 203, path);
			}
			else
			{
				MessageBox(hWnd, lpArgLower, "Not a directory", MB_ICONSTOP);
			}
		}
		*lpArgUpper = cAhead;
	}
	if (bCommit)
	{
		SendMessage(hWnd, WM_COMMAND, IDOK, 0);
	}
	return TRUE;
}
示例#26
0
/****************************************************************************
*
*     FUNCTION: ExtractDlgProc
*
*     PURPOSE:  Window Procedure for the Extract Dialog
*
*     PARAMS:   HWND hWnd     - This window handle
*               UINT Msg      - Which Message?
*               WPARAM wParam - message parameter
*               LPARAM lParam - message parameter
*
*     RETURNS:  BOOL - FALSE for cancel, TRUE for ok
*
* History:
*                July '95 - Created
*
\****************************************************************************/
BOOL CALLBACK ExtractDlgProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
    // Variable that holds info on this EXE/DLL
    static LPEXEDLLICONINFO lpEDII;

    switch( Msg )
    {
        // During Paint, we will draw the currently selected icon
        case WM_PAINT:
        {
            HDC                	hDC;
            PAINTSTRUCT        	ps;
            DWORD            	nIndex;
            LPTSTR            	lpIconID;

            hDC = BeginPaint( hWnd, &ps );
            // Get the current selection
            if( (nIndex = SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETCURSEL, 0, 0 )) != CB_ERR )
            {
                // Get the data associated with the current selection - its the icon name
                if( (lpIconID = (LPTSTR)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETITEMDATA, nIndex, 0 )) != (LPTSTR)CB_ERR )
                {
                    RECT        Rect, ButtonRect, DlgRect;
                    HWND        hWndButton;
                    HICON    	hIcon;
                    ICONINFO    IconInfo;
                    BITMAP    	bm;
                    POINT    	UpperLeft, LowerRight;

                    // Make an Icon
                    hIcon = GetIconFromInstance( lpEDII->hInstance, lpIconID );
                    // Locate the icon
                    GetIconInfo( hIcon, &IconInfo );
                    GetObject( IconInfo.hbmColor, sizeof(BITMAP), &bm );
                    hWndButton = GetDlgItem( hWnd, IDCANCEL );
                    GetWindowRect( hWndButton, &ButtonRect );
                    GetWindowRect( hWnd, &DlgRect );
                    UpperLeft.x = ButtonRect.left;
                    UpperLeft.y = ButtonRect.bottom;
                    LowerRight.x = ButtonRect.right;
                    LowerRight.y = DlgRect.bottom;
                    ScreenToClient( hWnd, &UpperLeft );
                    ScreenToClient( hWnd, &LowerRight );
                    SetRect( &Rect, UpperLeft.x, UpperLeft.y, LowerRight.x, LowerRight.y );
                    // Draw it
                    DrawIcon( hDC, Rect.left + ((Rect.right - Rect.left - bm.bmWidth)/2), 
                            Rect.top + ((Rect.bottom - Rect.top - bm.bmHeight)/2), hIcon );
                    // Kill it
                    DestroyIcon( hIcon );
                }
            }
            EndPaint( hWnd, &ps );
        }
        break; // End WM_PAINT

        // Dialog is being initialized
        case WM_INITDIALOG:
        {
            UINT    nCount;
            TCHAR	szBuffer[MAX_PATH], szFileTitle[MAX_PATH];

            // Are we being sent data about an EXE/DLL?
            if( (lpEDII = (LPEXEDLLICONINFO)lParam) != NULL )
            {
                // Set the title of the dialog to reflect the EXE/DLL filename
                GetFileTitle( lpEDII->szFileName, szFileTitle, MAX_PATH );
                wsprintf( szBuffer, "Extract Icon [%s]", szFileTitle );
                SetWindowText( hWnd, szBuffer );
                // Fill in the listbox with the icons available
                if( ! EnumResourceNames( lpEDII->hInstance, RT_GROUP_ICON, MyEnumProcedure, (LPARAM)hWnd ) )
                {
                    MessageBox( hWnd, "Error Enumerating Icons", "Error", MB_OK );
                    PostMessage( hWnd, WM_CLOSE, 0, 0 );
                }
                SendDlgItemMessage( hWnd, IDC_LIST1, LB_SETCURSEL, 0, 0 );
                // If we have <= 1, post an OK message
                if( (nCount = SendDlgItemMessage(hWnd, IDC_LIST1, LB_GETCOUNT, 0, 0)) == 1 )
                {
                    PostMessage( hWnd, WM_COMMAND, IDOK, 0 );
                }
                // If there were no icons, let the user know
                if( nCount == 0 )
                {
                    MessageBox( hWnd, "No Icons in this File", "Error", MB_OK );
                    PostMessage( hWnd, WM_CLOSE, 0, 0 );
                }
            }
            return FALSE;
        }
        break; // End WM_INITDIALOG

        // Shut 'er down
        case WM_CLOSE:
            PostMessage( hWnd, WM_COMMAND, IDCANCEL, 0l );
        break; // End WM_CLOSE

        // Children are sending messages
        case WM_COMMAND:
            switch( LOWORD(wParam) )
            {
                // Its the listbox, just redraw the icon
                case IDC_LIST1:
                    switch( HIWORD(wParam) )
                    {
                        case CBN_SELCHANGE:
                        case CBN_SELENDOK:
                            InvalidateRect( hWnd, NULL, TRUE );
                        break;
                    }
                break; // End IDC_LIST1

                // User has chosen an icon, shut it down
                case IDOK:
                {
                    LONG nIndex;

                    lpEDII->lpID = NULL;
                    if( (nIndex = SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETCURSEL, 0, 0 )) != LB_ERR )
                        lpEDII->lpID = (LPTSTR)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETITEMDATA, nIndex, 0 );
                    EndDialog( hWnd, TRUE );
                }
                break; // End IDOK

                // BAIL!
                case IDCANCEL:
                    EndDialog( hWnd, FALSE );
                break; // End IDCANCEL

            }
        break;
        default:
            return FALSE;
        break;
    }
    return TRUE;
}
示例#27
0
static int ImportStrings( const wchar_t *dllName, const wchar_t *csvName )
{
	HANDLE hCSV=CreateFile(csvName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
	if (hCSV==INVALID_HANDLE_VALUE)
	{
		Printf("Failed to read %S\n",csvName);
		return 1;
	}

	int size=SetFilePointer(hCSV,0,NULL,FILE_END)/2;
	SetFilePointer(hCSV,0,NULL,FILE_BEGIN);
	std::vector<wchar_t> buf(size+1);
	DWORD q;
	ReadFile(hCSV,&buf[0],size*2,&q,NULL);
	CloseHandle(hCSV);
	buf[size]=0;
	for (int i=0;i<size;i++)
		if (buf[i]=='\r' || buf[i]=='\n')
			buf[i]=0;

	std::map<int,const wchar_t*> lines;
	wchar_t *str=&buf[0];
	int min=100000, max=0;
	while (str<&buf[size])
	{
		int len=Strlen(str);
		wchar_t *next=str+len+1;
		wchar_t *tab=wcschr(str,'\t');
		if (tab)
		{
			*tab=0;
			int id=_wtol(str);
			bool bNumber=id>0;
			for (;*str;str++)
				if (*str<'0' || *str>'9')
				{
					bNumber=false;
					break;
				}
			if (bNumber)
			{
				tab=wcschr(tab+1,'\t');
				if (tab)
				{
					str=tab+1;
					tab=wcschr(str,'\t');
					if (tab) *tab=0;
					if (lines.find(id)!=lines.end())
					{
						Printf("Duplicate string ID %d\n",id);
						return 1;
					}
					UnsescapeString(str);
					lines[id]=str;
					if (min>id) min=id;
					if (max<id) max=id;
				}
			}
		}
		str=next;
	}

	HMODULE hDll=LoadLibraryEx(dllName,NULL,LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
	if (!hDll)
	{
		Printf("Failed to open %S (err: %d)\n",dllName,GetLastError());
		return 1;
	}

	std::vector<std::pair<int,WORD>> oldStrings;
	EnumResourceNames(hDll,RT_STRING,EnumResNameProc,(LONG_PTR)&oldStrings);
	FreeLibrary(hDll);

	HANDLE hUpdate=BeginUpdateResource(dllName,FALSE);
	if (!hUpdate)
	{
		Printf("Failed to open %S (err: %d)\n",dllName,GetLastError());
		return 1;
	}

	// delete all string resources
	for (int i=0;i<(int)oldStrings.size();i++)
	{
		UpdateResource(hUpdate,RT_STRING,MAKEINTRESOURCE(oldStrings[i].first),oldStrings[i].second,NULL,0);
	}

	// add new string lines
	max+=32;
	for (int i=min;i<max;i+=16)
	{
		int id=i/16;
		int idx=(id-1)*16;
		std::vector<wchar_t> res;
		for (int j=0;j<16;j++,idx++)
		{
			std::map<int,const wchar_t*>::const_iterator it=lines.find(idx);
			const wchar_t *str=L"";
			if (it!=lines.end())
				str=it->second;
			int len=Strlen(str);
			res.push_back((wchar_t)len);
			for (int c=0;c<len;c++)
				res.push_back(str[c]);
		}
		if (res.size()>16)
			UpdateResource(hUpdate,RT_STRING,MAKEINTRESOURCE(id),LANG_NEUTRAL,&res[0],res.size()*2);
	}

	if (!EndUpdateResource(hUpdate,FALSE))
	{
		Printf("Failed to update %S (err: %d)\n",dllName,GetLastError());
		return 1;
	}
	return 0;
}
示例#28
0
//****************************************************************************
//
// Function Name: ApplyData
//
// Description:   Applies HeadlineDataStruct effect's data
//                to the Headline depth controls
//
// Returns:       None
//
// Exceptions:	   None
//
//****************************************************************************
void RHeadlineDepthPage::ApplyData( RHeadlineInterface* pInterface, RComponentView* pComponentView )
{
	// Set the effects data
	//////////////////////////

	EProjectionEffects eProjEffects ;
	EShadowEffects eShadowEffects ;
	RIntPoint ptVanish ;
	RColor crFillColor ;
	int nNumStages ;


	pInterface->GetNumStages( nNumStages ) ;
	pInterface->GetProjectionEffect( eProjEffects ) ;
	pInterface->GetProjectionDepth( m_data.flDepth ) ;
	pInterface->GetShadowEffect( eShadowEffects ) ;
	pInterface->GetProjectionFillColor( crFillColor ) ;
	pInterface->GetProjectionVanishPoint( ptVanish ) ;

	if (eShadowEffects > kNoShadow)
	{
		// Currently these options are shared, but in
		// pre-existing data they may not be.
		pInterface->GetShadowFillColor( crFillColor ) ;
		pInterface->GetShadowVanishPoint( ptVanish ) ;
	}

	if (pComponentView->HasShadow())
	{
		RSoftShadowSettings settings;
		pComponentView->GetShadowSettings( settings );

		m_data.nDataType      = kShadowType;
		m_data.nOpacity       = ::Round( settings.m_fShadowOpacity * 100 );
		m_data.nEdgeSoftness  = ::Round( settings.m_fShadowEdgeSoftness * 100 );
		m_data.nOffset        = ::Round( settings.m_fShadowOffset * 65535 );

		m_wndBlendAngle.SetAngle( -settings.m_fShadowAngle );
		m_angle = m_wndBlendAngle.GetAngle();

		m_btnColor.SetColor( RColor( settings.m_fShadowColor ) ) ;
	}
	else
	{
		m_data.nDataType      = kDepthType ;
		m_data.nNumStages     = nNumStages ;
		m_data.nSelProjection = eProjEffects ;
		m_data.nSelShadow     = eShadowEffects ;
		m_data.fBlend			 = sWORD( RColor::kGradient == crFillColor.GetFillMethod() ) ;

		m_wndBlendAngle.SetAngle( atan2( YRealDimension( ptVanish.m_y ), 
			YRealDimension( ptVanish.m_x ) ) ) ;

		m_btnColor.SetColor( RColor(crFillColor.GetSolidColor()) ) ;

		m_angle = m_wndBlendAngle.GetAngle()  ;

		YAngle angle = fmod((double)m_angle, (double)(2.0 * kPI));
		if (angle < 0.0) angle += 2.0 * kPI;
		const YRealDimension kAngleDelta = 0.00001;
		
		if (::AreFloatsEqual(angle, kPI / 2.0, kAngleDelta) || ::AreFloatsEqual(angle, 3.0 * kPI / 2.0, kAngleDelta))
			m_data.nVanishPointX = 0;
		else
			m_data.nVanishPointX = ptVanish.m_x / cos( m_angle ) ;
		
		if (::AreFloatsEqual(angle, 0.0, kAngleDelta) || ::AreFloatsEqual(angle, kPI, kAngleDelta))
			m_data.nVanishPointY = 0;
		else
			m_data.nVanishPointY = ptVanish.m_y / sin( m_angle ) ;

/*		if (m_data.nSelShadow > kNoShadow)
		{
			pInterface->GetShadowDepth( m_data.flDepth ) ;

			m_data.nDataType      = kShadowType;
			m_data.nOpacity       = 100;
			m_data.nEdgeSoftness  = 0;
			m_data.nOffset        = 10; // TODO: determine from vanishing point

			FillData( pInterface, pComponentView );
		}
*/	}


	if (GetSafeHwnd())
	{
		// Set the image selection
		EnumResourceNames( 
			AfxGetResourceHandle(),				// resource-module handling
			cResourceType,							// pointer to resource type 
			(ENUMRESNAMEPROC) SelectResItem,	// pointer to callback function 
			(LONG) this ) ; 						// application-defined parameter 

		m_btnColor.EnableWindow( m_gcImageList.GetCurSel() != 0 ) ;
	}
}
示例#29
0
void CRuntime::UnpackDependencies()
{
	EnumResourceNames(NULL, "DEPENDENCIES", EnumResNameProc, (LONG_PTR)this);
}
示例#30
0
LRESULT VDUIBaseWindowW32::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) {
	switch(msg) {
		case WM_INITDIALOG:
			{
				RECT r;
				GetWindowRect(mhwnd, &r);
				MapWindowPoints(mhwnd, ::GetParent(mhwnd), (LPPOINT)&r, 2);
				mArea.left = r.left;
				mArea.top = r.top;
				mArea.right = r.right;
				mArea.bottom = r.bottom;

				DispatchEvent(this, mID, IVDUICallback::kEventCreate, 0);

				DWORD dwStyle = GetWindowLong(mhwnd, GWL_STYLE);

				if (dwStyle & WS_THICKFRAME) {
					EnumResourceNames(VDGetLocalModuleHandleW32(), RT_GROUP_ICON, SetApplicationIconOnDialog, (LONG_PTR)mhwnd);
				}

				if (!(dwStyle & DS_CONTROL))
					Relayout();

				ExecuteAllLinks();
			}
			return FALSE;
   
		case WM_GETMINMAXINFO:
			{
				MINMAXINFO *pmmi = (MINMAXINFO *)lParam;
   
				pmmi->ptMinTrackSize.x = mLayoutSpecs.minsize.w;
				pmmi->ptMinTrackSize.y = mLayoutSpecs.minsize.h;
   
				if ((mAlignX & nsVDUI::kAlignTypeMask) != nsVDUI::kFill)
					pmmi->ptMaxTrackSize.x = mLayoutSpecs.minsize.w;
   
				if ((mAlignY & nsVDUI::kAlignTypeMask) != nsVDUI::kFill)
					pmmi->ptMaxTrackSize.y = mLayoutSpecs.minsize.h;
			}
			return 0;

		case WM_SIZE:
			if (!(GetWindowLong(mhwnd, GWL_STYLE) & WS_CHILD)) {
				vduirect r(GetClientArea());

				if (r.size() != GetArea().size()) {
					r.left   += mInsets.left;
					r.top    += mInsets.top;
					r.right  -= mInsets.right;
					r.bottom -= mInsets.bottom;

					tChildren::iterator it(mChildren.begin()), itEnd(mChildren.end());

					for(; it!=itEnd; ++it) {
						IVDUIWindow *pWin = *it;

						pWin->PostLayout(r);
					}
				}
			}
			return 0;

		case WM_CLOSE:
			if (DispatchEvent(this, mID, IVDUICallback::kEventClose, 0))
				return 0;
			goto handle_cancel;

		case WM_NOTIFYFORMAT:
			return VDIsWindowsNT() ? NFR_UNICODE : NFR_ANSI;

		case WM_COMMAND:
			// special handling for commands that have have keyboard equivalents in
			// the dialog manager; we never assign these native IDs so it's safe to
			// shortcut them
			if (LOWORD(wParam) == IDOK) {
				DispatchEvent(this, 10, IVDUICallback::kEventSelect, 0);
				return 0;
			} else if (LOWORD(wParam) == IDCANCEL) {
handle_cancel:
				if (!DispatchEvent(this, 11, IVDUICallback::kEventSelect, 0)) {
					if (mpModal)
						EndModal(-1);
					else
						Shutdown();
				}
				return 0;
			} else if (!lParam) {
				// dispatch menu/accelerator commands
				DispatchEvent(this, LOWORD(wParam), IVDUICallback::kEventSelect, 0);
				return 0;
			}
			break;
	}

	return VDUICustomControlW32::WndProc(msg, wParam, lParam);
}