Пример #1
0
BOOL CMainFrame::OnMyToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
	ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);

	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	CString strTipText;

	UINT nID = pNMHDR->idFrom;

	if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
		pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
	{
		// idFrom is actually the HWND of the tool
		nID = ((UINT)(WORD)::GetDlgCtrlID( (HWND)nID ) );
	}

	if (nID != 0) // will be zero on a separator
	{
		// don't handle the message if no string resource found
        CUStringConvert strCnv;
        CUString strLangTipText = g_language.GetString( nID );

		if ( strLangTipText.IsEmpty() )
		{
			return FALSE;
		}	

		// this is the command id, not the button index
        AfxExtractSubString( strTipText, strCnv.ToT( strLangTipText ), 1, _T( '\n' ));
	}
#ifndef _UNICODE
	if (pNMHDR->code == TTN_NEEDTEXTA)
		lstrcpyn(pTTTA->szText, strTipText, _countof(pTTTA->szText) );
	else
		_mbstowcsz(pTTTW->szText, strTipText, _countof(pTTTW->szText) );
#else
	if (pNMHDR->code == TTN_NEEDTEXTA)
		_wcstombsz(pTTTA->szText, strTipText, _countof(pTTTA->szText));
	else
		lstrcpyn(pTTTW->szText, strTipText, _countof(pTTTW->szText));
#endif
	*pResult = 0;

	// bring the tooltip window above other popup windows
	::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,
		SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);

	return TRUE;    // message was handled
}
Пример #2
0
CUString	CLanguage::GetString( const DWORD nID ) const
{
    CUString strRet;

    DWORD	dwIndex;

    for ( dwIndex = 0; dwIndex < m_vStrings.size(); dwIndex++ )
    {
        if ( m_vStrings[ dwIndex ].nID == nID )
        {
            strRet = m_vStrings[ dwIndex ].strValue;
            break;
        }
    }
    if ( strRet.IsEmpty() )
    {
        CString strResource;
        strResource.LoadString( nID );
        strRet = CUString( strResource );
#ifdef _DEBUG
        ReportMissingID( nID, strRet, 0 );
#endif
    }
    else
    {
#ifdef _DEBUG
        CString strResource;
        strResource.LoadString( nID );

        if ( 0 != strRet.Compare( CUString( strResource ) ) )
        {
            ReportChangedID( nID, CUString( strResource ), strRet, 0 );
        }
#endif
    }


    return strRet;
}
Пример #3
0
BOOL CLanguage::InitDialogStrings( CDialog* pDialog, long lSection )
{
    short nCtrlID;
    CUString sText;
    CWnd* pWndCtrl;
    DWORD	nIndex = 0;
    CUStringConvert strCnv;

    CUString strLang = GetDialogString( MAKELPARAM( 0, lSection ) );

    if( !strLang.IsEmpty() )
    {
        pDialog->SetWindowText( strCnv.ToT( strLang ) );
    }
    else
    {
        CString strMissing;
        pDialog->GetWindowText( strMissing );
        ReportMissingID( MAKELPARAM( 0, lSection ), CUString( strMissing ), 2 );
    }

    // test if the dialog has child windows
    if( pWndCtrl = pDialog->GetWindow( GW_CHILD | GW_HWNDFIRST ) )
    {
        // lool through all controls (windows) and replace text
        do
        {
            nCtrlID = pWndCtrl->GetDlgCtrlID();


            if (	!pWndCtrl->IsKindOf( RUNTIME_CLASS( CEdit ) ) &&
                    !pWndCtrl->IsKindOf( RUNTIME_CLASS( CListCtrl ) ) &&
                    !pWndCtrl->IsKindOf( RUNTIME_CLASS( CSpinButtonCtrl) )
               )
            {

                if( nCtrlID > 0 )
                {
                    // check if the Id is in the range of common strings
                    if( (nCtrlID >= COMMON_IDMIN) && (nCtrlID <= COMMON_IDMAX) )
                    {
                        strLang = GetString( nCtrlID );
                    }
                    else
                    {
                        strLang = GetDialogString( MAKELPARAM( nCtrlID, lSection ) );
                    }

                    if( !strLang.IsEmpty() )
                    {

                        if ( pWndCtrl->IsKindOf( RUNTIME_CLASS( CComboBox ) ) )
                        {
                            CUString strAdd;
                            int		nPos = -1;

                            // remove old strings
                            ((CComboBox*)pWndCtrl)->ResetContent();

                            while ( ( nPos = strLang.Find( '\n' ) ) >= 0 )
                            {
                                ((CComboBox*)pWndCtrl)->AddString( strCnv.ToT( strLang.Left( nPos ) ) );
                                strLang = strLang.Mid( nPos + 1 );
                                nPos++;
                            }

                            if ( strLang.GetLength() > nPos )
                            {
                                ((CComboBox*)pWndCtrl)->AddString( strCnv.ToT( strLang.Mid( nPos ) ) );
                            }
                        }
                        else
                        {
                            pDialog->SetDlgItemText( nCtrlID, strCnv.ToT( strLang ) );
                        }
                    }
                    else
                    {
                        CString strMissing;

                        if ( pWndCtrl->IsKindOf( RUNTIME_CLASS( CComboBox ) ) )
                        {
                            int nIndex = 0;
                            int	nItems = ((CComboBox*)pWndCtrl)->GetCount();

                            for ( nIndex =0; nIndex < nItems; nIndex++ )
                            {
                                CString strTmp;

                                ((CComboBox*)pWndCtrl)->GetLBText( nIndex, strTmp );
                                strMissing += strTmp;

                                if ( nIndex < nItems - 1 )
                                {
                                    strMissing += _T( "\n" );
                                }
                            }
                        }
                        else
                        {
                            pDialog->GetDlgItemText( nCtrlID, strMissing );
                        }
                        if ( !strMissing.IsEmpty() )
                        {
                            ReportMissingID( MAKELPARAM( nCtrlID, lSection ), CUString( strMissing ), 2 );
                        }
                    }
                }
            }

            pWndCtrl = pWndCtrl->GetWindow( GW_HWNDNEXT );

        } while( (pWndCtrl != NULL) && (pWndCtrl != pDialog->GetWindow( GW_CHILD | GW_HWNDFIRST )) );
    }

    return TRUE;
}
Пример #4
0
BOOL CLanguage::TranslateMenu( CMenu* pMenu, const int nMenuID, BOOL bTopLevel )
{
    CMenu*			pChildMenu = NULL;
    static CUString	strMissing;
    BOOL			bReturn = TRUE;
    static int		nPopUpIdx = 0;

    if ( bTopLevel )
    {
        nPopUpIdx = MAKELPARAM( 0, nMenuID );
        strMissing = _T( "" );
    }

    DWORD i = pMenu->GetMenuItemCount();
    for( i = 0; i < pMenu->GetMenuItemCount(); i++ )
    {
        pChildMenu = pMenu->GetSubMenu( i );

        int nItemID = pMenu->GetMenuItemID( i );

        if ( MENU_SEPARARTOR != nItemID )
        {
            CUString strLang;

            if ( bTopLevel )
            {
                strLang = GetMainMenuItem( nMenuID, i );
            }
            else
            {
                if ( MENU_POPUP != nItemID )
                {
                    strLang = GetSubMenuItem( nItemID );
                }
                else
                {
                    strLang = GetSubMenuItem( nPopUpIdx );
                    nPopUpIdx++;
                }
            }

            if ( MENU_POPUP != nItemID )
            {
                CUStringConvert strCnv;

                if ( !strLang.IsEmpty() )
                {
                    pMenu->ModifyMenu( nItemID, MF_STRING, nItemID, strCnv.ToT( strLang ) );
                }
                else
                {
                    CString strTmp;
                    pMenu->GetMenuString( nItemID, strTmp, MF_BYCOMMAND );
                    ReportMissingID( nItemID, CUString( strTmp ), 1 );
                }
            }
            else
            {
                int nPosition = UINT( pChildMenu->m_hMenu );

                if ( !strLang.IsEmpty() )
                {
                    int nPosition = UINT( pChildMenu->m_hMenu );

                    CUStringConvert strCnv;

                    pMenu->ModifyMenu(	UINT( pChildMenu->m_hMenu ),
                                        MF_STRING | MF_POPUP,
                                        UINT( pChildMenu->m_hMenu ),
                                        strCnv.ToT( strLang ) );
                }
                else
                {

                    if ( bTopLevel )
                    {
                        CString strTmp;
                        pMenu->GetMenuString( i, strTmp, MF_BYPOSITION );
                        strMissing += _W( "#" ) + CUString( strTmp );
                    }
                    else
                    {
                        CString strTmp;
                        pMenu->GetMenuString( 0, strTmp, MF_BYPOSITION );
                        ReportMissingID( nItemID, CUString( strTmp ), 1 );
                    }
                }

                TranslateMenu( pMenu->GetSubMenu(i), -1, FALSE );
            }
        }
    }

    if ( bTopLevel )
    {
        if ( !strMissing.IsEmpty() )
        {
            ReportMissingID( nMenuID, strMissing + _W( "#" ), 1 );
        }
    }

    return bReturn;
}
Пример #5
0
void InitWinAmpPlugins( HWND hWnd )
{
	WINAMPPLUGINPROP	tmpProp;
    WIN32_FIND_DATA		sFF;
    HANDLE				hFind = NULL;
	CUString			strPluginDir( g_config.GetAppPath() + _W( "\\Plugins\\in_*.dll" ) );

	LTRACE2( _T( "Scanning for plugins using mask %s"), strPluginDir );

    CUStringConvert strCnv;

	hFind = FindFirstFile( strCnv.ToT( strPluginDir ), &sFF);

	g_strWinampExt = _W("");

	// setup the Output module Window Handle
	g_OutModule.hMainWindow = hWnd;

	// setup the Output Module Instance Handle
	g_OutModule.hDllInstance = NULL;

	while ( NULL != hFind &&
			hFind != INVALID_HANDLE_VALUE )
	{

		if ( ! ( sFF.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) 
		{

            CUStringConvert strCnv;
            CUString strFullName( g_config.GetAppPath() + _W( "\\Plugins\\" ) + CUString( sFF.cFileName ) );

            LTRACE2( _T( "Getting plugin %s" ), strFullName );

			tmpProp.hDll = NULL;
		
			tmpProp.hDll = CDexLoadLibrary( strFullName );

			if ( tmpProp.hDll )
			{


				WINAMPGETINMODULE2 pGetMod = (WINAMPGETINMODULE2)
					GetProcAddress(	tmpProp.hDll,
									"winampGetInModule2" );

				// call "winampGetInModule2" DLL function
				tmpProp.pModule = pGetMod();

				// set the file name
				tmpProp.strFileName = sFF.cFileName;

				// setup window handler
				tmpProp.pModule->hMainWindow = hWnd;
				tmpProp.pModule->hDllInstance = tmpProp.hDll;

				tmpProp.pModule->Init(  );
				tmpProp.strExt = CUString( tmpProp.pModule->FileExtensions, CP_UTF8 );
				
				
				if ( 0 != tmpProp.pModule->UsesOutputPlug )
				{
					if ( !g_strWinampExt.IsEmpty() )
						g_strWinampExt += _W( ";" );

					g_strWinampExt+= tmpProp.strExt;

					LTRACE2( _T( "Adding plugin %s to list" ), sFF.cFileName );

					gs_vWinAmpProps.push_back( tmpProp );
				}
				else
				{
					tmpProp.pModule->Quit(  );
					LTRACE2( _T( "Plugin (%s) NOT added, since it does not use the output plugin" ), sFF.cFileName );
				}
			}

			// scan for next file
            if ( NULL != hFind && !FindNextFile( hFind, &sFF) ) 
			{
                FindClose( hFind );
                hFind = NULL;
            }

		}
	}
}