diff --git a/BrowseCtrl.cpp b/BrowseCtrl.cpp index dfbf623..bb8dedc 100644 --- a/BrowseCtrl.cpp +++ b/BrowseCtrl.cpp @@ -21,7 +21,6 @@ along with this program. If not, see . */ #include "stdafx.h" -#include "Polang.h" #include "BrowseCtrl.h" #ifdef _DEBUG @@ -54,6 +53,12 @@ void CBrowseCtrl::OnDropFiles( HDROP hDropInfo ) if ( DragQueryFile( hDropInfo, 0, szItem, _countof( szItem ) ) && ( GetFileAttributes( szItem ) & FILE_ATTRIBUTE_DIRECTORY ) == 0 ) { SetWindowText( szItem ); + + if ( auto pOwner = GetParent() ) + { + NMHDR hdr = { GetSafeHwnd(), (UINT_PTR)GetDlgCtrlID(), NM_DRAGDROP }; + pOwner->SendMessage( WM_NOTIFY, (WPARAM)hdr.idFrom, (LPARAM)&hdr ); + } } DragFinish( hDropInfo ); diff --git a/BrowseCtrl.h b/BrowseCtrl.h index a276bdd..677e5f9 100644 --- a/BrowseCtrl.h +++ b/BrowseCtrl.h @@ -44,3 +44,5 @@ class CBrowseCtrl : public CMFCEditBrowseCtrl DECLARE_MESSAGE_MAP() }; + +#define NM_DRAGDROP (NM_FIRST + 1) diff --git a/Polang.cpp b/Polang.cpp index 43b59e7..d0602f3 100644 --- a/Polang.cpp +++ b/Polang.cpp @@ -28,6 +28,10 @@ along with this program. If not, see . #define new DEBUG_NEW #endif +#define Classes _T("SOFTWARE\\Classes\\") +#define Verb _T("\\Shell") +#define Command _T("\\Command") + // CPolangApp BEGIN_MESSAGE_MAP(CPolangApp, CWinAppEx) @@ -51,13 +55,124 @@ BOOL CPolangApp::InitInstance() INITCOMMONCONTROLSEX InitCtrls = { sizeof( InitCtrls ), ICC_WIN95_CLASSES }; InitCommonControlsEx( &InitCtrls ); - CWinApp::InitInstance(); + __super::InitInstance(); // Activate "Windows Native" visual manager for enabling themes in MFC controls CMFCVisualManager::SetDefaultManager( RUNTIME_CLASS( CMFCVisualManagerWindows ) ); SetRegistryKey( AFX_IDS_COMPANY_NAME ); + int nRegister = 0; + int nArgs = 0; + if ( LPWSTR* szArglist = CommandLineToArgvW( GetCommandLineW(), &nArgs ) ) + { + for ( int i = 1; i < nArgs; ++i ) + { + if ( _tcsicmp( szArglist[ i ] + 1, _T("RegServer") ) == 0 ) + { + nRegister = 1; + } + else if ( _tcsicmp( szArglist[ i ] + 1, _T( "UnRegServer" ) ) == 0 ) + { + nRegister = -1; + } + } + LocalFree( szArglist ); + } + + CString sPath; + GetModuleFileName( NULL, sPath.GetBuffer( MAX_PATH ), MAX_PATH ); + sPath.ReleaseBuffer(); + sPath = CString( _T("\"") ) + sPath + _T("\" \"%1\""); + + const CString sApp = AfxGetAppName(); + const CString sName = LoadString( IDS_VERB_NAME ); + const CString sType = LoadString( IDS_TYPE ); + + static const LPCTSTR szExts[] = { _T(".po"), _T(".pot"), _T(".lang") }; + for ( int i = 0; i < 3; ++i ) + { + for ( auto & szExt : szExts ) + { + const CString sDefaultProgId = sApp + szExt; + + CString sProgId; + DWORD nSize = 64; + DWORD nType = 0; + LSTATUS res = SHGetValue( HKEY_CLASSES_ROOT, szExt, NULL, &nType, sProgId.GetBuffer( nSize + 1 ), &nSize ); + sProgId.ReleaseBuffer(); + if ( res == ERROR_SUCCESS && nSize && nType == REG_SZ ) + { + // OK + } + else + { + // Own extension key + sProgId = sDefaultProgId; + + if ( nRegister >= 0 ) + { + res = SHRegSetUSValue( CString( Classes ) + szExt, NULL, REG_SZ, + sProgId, sProgId.GetLength() * sizeof( TCHAR ), SHREGSET_HKCU ); + res = SHRegSetUSValue( CString( Classes ) + szExt, NULL, REG_SZ, + sProgId, sProgId.GetLength() * sizeof( TCHAR ), SHREGSET_HKLM ); + + res = SHRegSetUSValue( CString( Classes ) + sProgId, NULL, REG_SZ, + sType, sType.GetLength() * sizeof( TCHAR ), SHREGSET_HKCU ); + res = SHRegSetUSValue( CString( Classes ) + sProgId, NULL, REG_SZ, + sType, sType.GetLength() * sizeof( TCHAR ), SHREGSET_HKLM ); + } + } + + if ( nRegister >= 0 ) + { + res = SHRegSetUSValue( CString( Classes ) + sProgId + Verb + _T("\\") + sApp, NULL, REG_SZ, + sName, sName.GetLength() * sizeof( TCHAR ), SHREGSET_HKCU ); + res = SHRegSetUSValue( CString( Classes ) + sProgId + Verb + _T( "\\" ) + sApp, NULL, REG_SZ, + sName, sName.GetLength() * sizeof( TCHAR ), SHREGSET_HKLM ); + + res = SHRegSetUSValue( CString( Classes ) + sProgId + Verb + _T("\\") + sApp + Command, NULL, REG_SZ, + sPath, sPath.GetLength() * sizeof( TCHAR ), SHREGSET_HKCU ); + res = SHRegSetUSValue( CString( Classes ) + sProgId + Verb + _T( "\\" ) + sApp + Command, NULL, REG_SZ, + sPath, sPath.GetLength() * sizeof( TCHAR ), SHREGSET_HKLM ); + } + else + { + SHDeleteValue( HKEY_CLASSES_ROOT, sProgId + Verb + _T("\\") + sApp + Command, NULL ); + SHDeleteEmptyKey( HKEY_CLASSES_ROOT, sProgId + Verb + _T("\\") + sApp + Command ); + + SHDeleteValue( HKEY_CLASSES_ROOT, sProgId + Verb + _T("\\") + sApp, NULL ); + SHDeleteEmptyKey( HKEY_CLASSES_ROOT, sProgId + Verb + _T("\\") + sApp ); + + SHDeleteValue( HKEY_CLASSES_ROOT, sProgId + Verb, NULL ); + SHDeleteEmptyKey( HKEY_CLASSES_ROOT, sProgId + Verb ); + + // Own extension key? + if ( sProgId == sDefaultProgId ) + { + SHDeleteValue( HKEY_CLASSES_ROOT, sProgId, NULL ); + + SHDeleteEmptyKey( HKEY_CLASSES_ROOT, sProgId ); + + // Check for ProgID existence + res = SHDeleteEmptyKey( HKEY_CLASSES_ROOT, sProgId ); + if ( res == ERROR_FILE_NOT_FOUND ) + { + SHDeleteValue( HKEY_CLASSES_ROOT, szExt, NULL ); + SHDeleteEmptyKey( HKEY_CLASSES_ROOT, szExt ); + } + } + else + { + SHDeleteEmptyKey( HKEY_CLASSES_ROOT, sProgId ); + } + } + } + } + if ( nRegister != 0 ) + // Registration only + return FALSE; + CPolangDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); diff --git a/Polang.h b/Polang.h index 5858d1d..2e283a6 100644 --- a/Polang.h +++ b/Polang.h @@ -35,13 +35,14 @@ class CPolangApp : public CWinAppEx CPolangApp(); protected: - virtual BOOL InitInstance(); + virtual BOOL InitInstance() override; DECLARE_MESSAGE_MAP() }; extern CPolangApp theApp; +// Load string from resources inline CString LoadString(UINT nId) { CString str; @@ -49,6 +50,7 @@ inline CString LoadString(UINT nId) return str; } +// Cut off file extension (i.e. extract path + filename only) inline CString TrimExtension(LPCTSTR szFilename) { if ( ! szFilename || ! *szFilename ) @@ -56,6 +58,7 @@ inline CString TrimExtension(LPCTSTR szFilename) return CString( szFilename, (int)( PathFindExtension( szFilename ) - szFilename ) ); } +// Cut off file name from path (i.e. extract path only) inline CString TrimFileName(LPCTSTR szFilename) { if ( ! szFilename || ! *szFilename ) @@ -63,6 +66,7 @@ inline CString TrimFileName(LPCTSTR szFilename) return CString( szFilename, (int)( PathFindFileName( szFilename ) - szFilename ) ); } +// Check if this is a real file on disk inline bool IsFileName(LPCTSTR szFilename) { if ( ! szFilename || ! *szFilename ) diff --git a/Polang.rc b/Polang.rc index d9d70c8..ecdb94e 100644 Binary files a/Polang.rc and b/Polang.rc differ diff --git a/PolangDlg.cpp b/PolangDlg.cpp index ed6799a..adb6415 100644 --- a/PolangDlg.cpp +++ b/PolangDlg.cpp @@ -39,10 +39,17 @@ along with this program. If not, see . #define VAL_PRESERVE _T("Preserve") #define VAL_FUZZY _T("Fuzzy") +#define Ext_pot _T(".pot") +#define Ext_po _T(".po") +#define Ext_lang _T(".lang") + +#define en_US_lang _T("en_US.lang") +#define en_US_pot _T("en_US.pot") + // CPolangDlg dialog CPolangDlg::CPolangDlg(CWnd* pParent /*=NULL*/) - : CDialogEx ( IDD_POLANG_DIALOG, pParent ) + : CDialogEx ( IDD, pParent ) , m_hIcon ( theApp.LoadIcon( IDR_MAINFRAME ) ) , m_nOptions ( theApp.GetProfileInt( SETTINGS, VAL_OPTIONS, OPT_POT ) ) , m_nOptionsLast ( OPT_NULL ) @@ -118,20 +125,20 @@ void CPolangDlg::UpdateInterface(int nOptions) case OPT_POT: s1Filename = theApp.GetProfileString( SETTINGS, VAL_ENGLISH ); s2Filename = theApp.GetProfileString( SETTINGS, VAL_POT ); - if ( s2Filename.IsEmpty() && IsFileName( s1Filename ) ) - s2Filename = TrimExtension( s1Filename ) + _T( ".pot" ); - if ( s1Filename.IsEmpty() && IsFileName( s2Filename ) ) - s1Filename = TrimExtension( s2Filename ) + _T( ".lang" ); + if ( s2Filename.IsEmpty() && ! s1Filename.IsEmpty() ) + s2Filename = TrimExtension( s1Filename ) + Ext_pot; + if ( s1Filename.IsEmpty() && ! s2Filename.IsEmpty() ) + s1Filename = TrimExtension( s2Filename ) + Ext_lang; // Input m_wnd1Title.SetWindowText( LoadString( IDS_ENGLISH_TITLE ) ); m_wnd1File.EnableFileBrowseButton( _T("lang"), LoadString( IDS_LANG_FILES ), OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ); m_wnd1File.SetWindowText( s1Filename ); - m_wnd1File.SetCueBanner( _T("en_US.lang") ); + m_wnd1File.SetCueBanner( en_US_lang ); // Output m_wnd2Title.SetWindowText( LoadString( IDS_POT_TITLE ) ); m_wnd2File.EnableFileBrowseButton( _T("pot"), LoadString( IDS_POEDIT_FILES ), OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT ); m_wnd2File.SetWindowText( s2Filename ); - m_wnd2File.SetCueBanner( _T("en_US.pot") ); + m_wnd2File.SetCueBanner( en_US_pot ); m_wnd12Set.EnableWindow(); m_wndFuzzy.EnableWindow( FALSE ); // Disabled @@ -148,17 +155,17 @@ void CPolangDlg::UpdateInterface(int nOptions) s1Filename = theApp.GetProfileString( SETTINGS, VAL_ENGLISH ); s2Filename = theApp.GetProfileString( SETTINGS, VAL_LANG ); s3Filename = theApp.GetProfileString( SETTINGS, VAL_PO ); - if ( s3Filename.IsEmpty() && IsFileName( s2Filename ) ) - s3Filename = TrimExtension( s2Filename ) + _T( ".po" ); - if ( s2Filename.IsEmpty() && IsFileName( s3Filename ) ) - s2Filename = TrimExtension( s3Filename ) + _T( ".lang" ); - if ( s1Filename.IsEmpty() && IsFileName( s2Filename ) ) - s1Filename = TrimFileName( s2Filename ) + _T( "en_US.lang" ); + if ( s3Filename.IsEmpty() && ! s2Filename.IsEmpty() ) + s3Filename = TrimExtension( s2Filename ) + Ext_po; + if ( s2Filename.IsEmpty() && ! s3Filename.IsEmpty() ) + s2Filename = TrimExtension( s3Filename ) + Ext_lang; + if ( s1Filename.IsEmpty() && ! s2Filename.IsEmpty() ) + s1Filename = TrimFileName( s2Filename ) + en_US_lang; // Input m_wnd1Title.SetWindowText( LoadString( IDS_ENGLISH_TITLE ) ); m_wnd1File.EnableFileBrowseButton( _T("lang"), LoadString( IDS_LANG_FILES ), OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ); m_wnd1File.SetWindowText( s1Filename ); - m_wnd1File.SetCueBanner( _T("en_US.lang") ); + m_wnd1File.SetCueBanner( en_US_lang ); // Input m_wnd2Title.SetWindowText( LoadString( IDS_LANG_TITLE ) ); m_wnd2File.EnableFileBrowseButton( _T("lang"), LoadString( IDS_LANG_FILES ), OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ); @@ -181,17 +188,17 @@ void CPolangDlg::UpdateInterface(int nOptions) s1Filename = theApp.GetProfileString( SETTINGS, VAL_ENGLISH ); s2Filename = theApp.GetProfileString( SETTINGS, VAL_PO ); s3Filename = theApp.GetProfileString( SETTINGS, VAL_LANG ); - if ( s3Filename.IsEmpty() && IsFileName( s2Filename ) ) - s3Filename = TrimExtension( s2Filename ) + _T( ".lang" ); - if ( s2Filename.IsEmpty() && IsFileName( s3Filename ) ) - s2Filename = TrimExtension( s3Filename ) + _T( ".po" ); - if ( s1Filename.IsEmpty() && IsFileName( s2Filename ) ) - s1Filename = TrimFileName( s2Filename ) + _T( "en_US.lang" ); + if ( s3Filename.IsEmpty() && ! s2Filename.IsEmpty() ) + s3Filename = TrimExtension( s2Filename ) + Ext_lang; + if ( s2Filename.IsEmpty() && ! s3Filename.IsEmpty() ) + s2Filename = TrimExtension( s3Filename ) + Ext_po; + if ( s1Filename.IsEmpty() && ! s2Filename.IsEmpty() ) + s1Filename = TrimFileName( s2Filename ) + en_US_lang; // Input m_wnd1Title.SetWindowText( LoadString( IDS_ENGLISH_TITLE ) ); m_wnd1File.EnableFileBrowseButton( _T( "lang" ), LoadString( IDS_LANG_FILES ), OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ); m_wnd1File.SetWindowText( s1Filename ); - m_wnd1File.SetCueBanner( _T( "en_US.lang" ) ); + m_wnd1File.SetCueBanner( en_US_lang ); m_wnd1File.EnableWindow( m_bPreserve ); m_wnd1Open.EnableWindow( m_bPreserve ); // Input @@ -245,6 +252,9 @@ BEGIN_MESSAGE_MAP(CPolangDlg, CDialogEx) ON_BN_CLICKED( IDC_1_2_SET, &CPolangDlg::OnBnClicked12Set ) ON_BN_CLICKED( IDC_2_3_SET, &CPolangDlg::OnBnClicked23Set ) ON_BN_CLICKED( IDC_FORMAT, &CPolangDlg::OnBnClickedFormat ) + ON_NOTIFY( NM_DRAGDROP, IDC_1_FILE, &CPolangDlg::OnDragDropFile ) + ON_NOTIFY( NM_DRAGDROP, IDC_2_FILE, &CPolangDlg::OnDragDropFile ) + ON_NOTIFY( NM_DRAGDROP, IDC_3_FILE, &CPolangDlg::OnDragDropFile ) END_MESSAGE_MAP() // CPolangDlg message handlers @@ -253,7 +263,7 @@ BOOL CPolangDlg::OnInitDialog() { __super::OnInitDialog(); - SetWindowText( theApp.m_pszAppName ); + SetWindowText( AfxGetAppName() ); GetWindowRect( m_rcInitial ); @@ -264,10 +274,10 @@ BOOL CPolangDlg::OnInitDialog() m_pTips.Activate( TRUE ); m_pTips.SetMaxTipWidth( 300 ); - static CWnd* wnds[] = { &m_wnd1Open, &m_wnd2Open, &m_wnd3Open, &m_wnd12Set, &m_wnd23Set }; - for ( int i = 0; i < _countof( wnds ); ++i ) + static CWnd* const wnds[] = { &m_wnd1Open, &m_wnd2Open, &m_wnd3Open, &m_wnd12Set, &m_wnd23Set }; + for (auto & wnd : wnds) { - m_pTips.AddTool( wnds[ i ], LoadString( wnds[ i ]->GetDlgCtrlID() ) ); + m_pTips.AddTool( wnd, LoadString( wnd->GetDlgCtrlID() ) ); } m_wnd1Open.SetIcon( ( HICON )LoadImage( AfxGetResourceHandle(), MAKEINTRESOURCE( IDI_RUN ), IMAGE_ICON, 16, 16, LR_SHARED ) ); @@ -276,16 +286,65 @@ BOOL CPolangDlg::OnInitDialog() m_wnd12Set.SetIcon( ( HICON )LoadImage( AfxGetResourceHandle(), MAKEINTRESOURCE( IDI_DOWN ), IMAGE_ICON, 16, 16, LR_SHARED ) ); m_wnd23Set.SetIcon( ( HICON )LoadImage( AfxGetResourceHandle(), MAKEINTRESOURCE( IDI_DOWN ), IMAGE_ICON, 16, 16, LR_SHARED ) ); - UpdateInterface( m_nOptions ); - + // Restore window size and position CAutoVectorPtr< WINDOWPLACEMENT> pl; UINT len = 0; - theApp.GetProfileBinary( SETTINGS, VAL_WINDOW, (LPBYTE*)&pl, &len ); - if ( len == sizeof( WINDOWPLACEMENT ) ) + if ( theApp.GetProfileBinary( SETTINGS, VAL_WINDOW, (LPBYTE*)&pl.m_p, &len ) && + len == sizeof( WINDOWPLACEMENT ) && pl.m_p->length == sizeof( WINDOWPLACEMENT ) ) { SetWindowPlacement( pl ); } + // Parse command-line options + CString sStartupFile; + int nArgs = 0; + if ( LPWSTR* szArglist = CommandLineToArgvW( GetCommandLineW(), &nArgs ) ) + { + if ( nArgs > 1 ) + { + sStartupFile = szArglist[ 1 ]; + } + LocalFree( szArglist ); + } + + LPCTSTR szStartupExt = PathFindExtension( sStartupFile ); + LPCTSTR szStartupName = PathFindFileName( sStartupFile ); + if ( _tcsicmp( szStartupExt, Ext_lang ) == 0 ) + { + if ( _tcsicmp( szStartupName, en_US_lang ) == 0 ) + { + m_nOptions = OPT_POT; + theApp.WriteProfileString( SETTINGS, VAL_ENGLISH, sStartupFile ); + theApp.WriteProfileString( SETTINGS, VAL_POT, TrimFileName( sStartupFile ) + en_US_pot ); + } + else + { + m_nOptions = OPT_PO; + theApp.WriteProfileString( SETTINGS, VAL_ENGLISH, TrimFileName( sStartupFile ) + en_US_lang ); + theApp.WriteProfileString( SETTINGS, VAL_POT, TrimFileName( sStartupFile ) + en_US_pot ); + theApp.WriteProfileString( SETTINGS, VAL_PO, TrimExtension( sStartupFile ) + Ext_po ); + theApp.WriteProfileString( SETTINGS, VAL_LANG, sStartupFile ); + } + } + else if ( _tcsicmp( szStartupExt, Ext_pot ) == 0 ) + { + m_nOptions = OPT_POT; + theApp.WriteProfileString( SETTINGS, VAL_ENGLISH, TrimFileName( sStartupFile ) + en_US_lang ); + theApp.WriteProfileString( SETTINGS, VAL_POT, sStartupFile ); + } + else if ( _tcsicmp( szStartupExt, Ext_po ) == 0 ) + { + m_nOptions = OPT_LANG; + theApp.WriteProfileString( SETTINGS, VAL_ENGLISH, TrimFileName( sStartupFile ) + en_US_lang ); + theApp.WriteProfileString( SETTINGS, VAL_POT, TrimFileName( sStartupFile ) + en_US_pot ); + theApp.WriteProfileString( SETTINGS, VAL_PO, sStartupFile ); + theApp.WriteProfileString( SETTINGS, VAL_LANG, TrimExtension( sStartupFile ) + Ext_lang ); + } + + UpdateData( FALSE ); + + UpdateInterface( m_nOptions ); + return TRUE; // return TRUE unless you set the focus to a control } @@ -457,9 +516,12 @@ void CPolangDlg::OnDestroy() { UpdateInterface( OPT_NULL ); + // Save window size and position WINDOWPLACEMENT pl = { sizeof( WINDOWPLACEMENT ) }; - GetWindowPlacement( &pl ); - theApp.WriteProfileBinary( SETTINGS, VAL_WINDOW, (LPBYTE)&pl, sizeof( WINDOWPLACEMENT ) ); + if ( GetWindowPlacement( &pl ) ) + { + theApp.WriteProfileBinary( SETTINGS, VAL_WINDOW, (LPBYTE)&pl, sizeof( WINDOWPLACEMENT ) ); + } __super::OnDestroy(); } @@ -535,3 +597,83 @@ void CPolangDlg::OnBnClickedFormat() UpdateInterface( m_nOptions ); } + +void CPolangDlg::OnDragDropFile(NMHDR *pNMHDR, LRESULT *pResult) +{ + UpdateData(); + + CString s1Filename, s2Filename, s3Filename; + m_wnd1File.GetWindowText( s1Filename ); + m_wnd2File.GetWindowText( s2Filename ); + m_wnd3File.GetWindowText( s3Filename ); + + CString sUpdated; + switch ( pNMHDR->idFrom ) + { + case IDC_1_FILE: + sUpdated = s1Filename; + break; + + case IDC_2_FILE: + sUpdated = s2Filename; + break; + + case IDC_3_FILE: + sUpdated = s3Filename; + break; + } + const CString sDir = TrimFileName( sUpdated ); + LPCTSTR szExt = PathFindExtension( sUpdated ); + const bool bAuto = ( _tcsicmp( szExt, Ext_pot ) == 0 ) || ( _tcsicmp( szExt, Ext_po ) == 0 ) || ( _tcsicmp( szExt, Ext_lang ) == 0 ); + + if ( bAuto ) + { + switch ( m_nOptions ) + { + case OPT_POT: + m_wnd1File.SetWindowText( TrimExtension( sUpdated ) + Ext_lang ); + m_wnd2File.SetWindowText( TrimExtension( sUpdated ) + Ext_pot ); + break; + + case OPT_PO: + switch ( pNMHDR->idFrom ) + { + case IDC_1_FILE: + m_wnd1File.SetWindowText( TrimExtension( sUpdated ) + Ext_lang ); + m_wnd2File.SetWindowText( TrimExtension( sDir + PathFindFileName( s2Filename ) ) + Ext_lang ); + m_wnd3File.SetWindowText( TrimExtension( sDir + PathFindFileName( s3Filename ) ) + Ext_po ); + break; + + case IDC_2_FILE: + case IDC_3_FILE: + m_wnd1File.SetWindowText( TrimExtension( sDir + PathFindFileName( s1Filename ) ) + Ext_lang ); + m_wnd2File.SetWindowText( TrimExtension( sUpdated ) + Ext_lang ); + m_wnd3File.SetWindowText( TrimExtension( sUpdated ) + Ext_po ); + break; + } + break; + + case OPT_LANG: + switch ( pNMHDR->idFrom ) + { + case IDC_1_FILE: + m_wnd1File.SetWindowText( TrimExtension( sUpdated ) + Ext_lang ); + m_wnd2File.SetWindowText( TrimExtension( sDir + PathFindFileName( s2Filename ) ) + Ext_po ); + m_wnd3File.SetWindowText( TrimExtension( sDir + PathFindFileName( s3Filename ) ) + Ext_lang ); + break; + + case IDC_2_FILE: + case IDC_3_FILE: + m_wnd1File.SetWindowText( TrimExtension( sDir + PathFindFileName( s1Filename ) ) + Ext_lang ); + m_wnd2File.SetWindowText( TrimExtension( sUpdated ) + Ext_po ); + m_wnd3File.SetWindowText( TrimExtension( sUpdated ) + Ext_lang ); + break; + } + break; + } + + UpdateInterface( m_nOptions ); + } + + *pResult = 0; +} diff --git a/PolangDlg.h b/PolangDlg.h index c25454f..02193cd 100644 --- a/PolangDlg.h +++ b/PolangDlg.h @@ -21,20 +21,15 @@ along with this program. If not, see . #pragma once #include "BrowseCtrl.h" -#include "afxwin.h" - // CPolangDlg dialog class CPolangDlg : public CDialogEx { public: - CPolangDlg(CWnd* pParent = nullptr); // standard constructor + CPolangDlg(CWnd* pParent = nullptr); -// Dialog Data -#ifdef AFX_DESIGN_TIME enum { IDD = IDD_POLANG_DIALOG }; -#endif protected: enum { OPT_NULL = -1, OPT_POT = 0, OPT_PO = 1, OPT_LANG = 2 }; @@ -61,10 +56,10 @@ class CPolangDlg : public CDialogEx void UpdateInterface(int nOptions); - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnInitDialog(); - virtual void OnOK(); - virtual BOOL PreTranslateMessage( MSG* pMsg ); + virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support + virtual BOOL OnInitDialog() override; + virtual void OnOK() override; + virtual BOOL PreTranslateMessage( MSG* pMsg ) override; afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); @@ -77,6 +72,7 @@ class CPolangDlg : public CDialogEx afx_msg void OnBnClicked12Set(); afx_msg void OnBnClicked23Set(); afx_msg void OnBnClickedFormat(); + afx_msg void OnDragDropFile( NMHDR *pNMHDR, LRESULT *pResult ); DECLARE_MESSAGE_MAP() }; diff --git a/resource.h b/resource.h index 18debf1..7479f68 100644 Binary files a/resource.h and b/resource.h differ diff --git a/setup/setup.iss b/setup/setup.iss index 21c141a..f0b1f51 100644 --- a/setup/setup.iss +++ b/setup/setup.iss @@ -1,97 +1,102 @@ -#if Platform == "x64" - #define MyBitness "64-bit" -#else - #define MyBitness "32-bit" -#endif - -#define MyAppExe ExtractFileName( TargetPath ) -#define MyAppSource ( TargetPath ) -#define MyAppName GetStringFileInfo( MyAppSource, INTERNAL_NAME ) -#define MyAppVersion GetFileProductVersion( MyAppSource ) -#define MyAppCopyright GetFileCopyright( MyAppSource ) -#define MyAppPublisher GetFileCompany( MyAppSource ) -#define MyAppURL GetStringFileInfo( MyAppSource, "Comments" ) -#define MyOutputDir ExtractFileDir( TargetPath ) -#define MyOutput LowerCase( StringChange( MyAppName + " " + MyAppVersion + " " + MyBitness, " ", "_" ) ) - -#include "idp\lang\russian.iss" -#include "idp\idp.iss" -#include "dep\lang\russian.iss" -#include "dep\dep.iss" -#include "vcredist.iss" - -[Setup] -AppId={#MyAppName} -AppName={#MyAppName} {#MyBitness} -AppVersion={#MyAppVersion} -VersionInfoVersion={#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppMutex=Global\{#MyAppName} -AppCopyright={#MyAppCopyright} -DefaultDirName={pf}\{#MyAppPublisher}\{#MyAppName} -DefaultGroupName={#MyAppName} -OutputDir={#MyOutputDir} -OutputBaseFilename={#MyOutput} -Compression=lzma2/ultra64 -SolidCompression=yes -InternalCompressLevel=ultra64 -LZMAUseSeparateProcess=yes -PrivilegesRequired=admin -UninstallDisplayIcon={app}\{#MyAppExe},0 -DirExistsWarning=no -WizardImageFile=compiler:WizModernImage-IS.bmp -WizardSmallImageFile=compiler:WizModernSmallImage-IS.bmp -SetupMutex=Global\Setup_{#MyAppName} -OutputManifestFile=Setup-Manifest.txt -#if Platform == "x64" -ArchitecturesInstallIn64BitMode=x64 -ArchitecturesAllowed=x64 -#endif - -[Languages] -Name: "en"; MessagesFile: "compiler:Default.isl" -Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}" - -[Files] -Source: "{#MyAppSource}"; DestDir: "{app}"; Flags: replacesameversion uninsrestartdelete -Source: "..\README.md"; DestName: "ReadMe.txt"; DestDir: "{app}"; Flags: replacesameversion uninsrestartdelete -Source: "..\LICENSE"; DestName: "License.txt"; DestDir: "{app}"; Flags: replacesameversion uninsrestartdelete - -[Icons] -Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExe}"; Tasks: desktopicon -Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExe}" -Name: "{group}\ReadMe.txt"; Filename: "{app}\ReadMe.txt" -Name: "{group}\License.txt"; Filename: "{app}\License.txt" -Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" - -[Run] -Filename: "{app}\{#MyAppExe}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall runasoriginaluser - -[Registry] -Root: HKCU; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}"; Flags: dontcreatekey uninsdeletekey -Root: HKCU; Subkey: "Software\{#MyAppPublisher}"; Flags: dontcreatekey uninsdeletekeyifempty - -[UninstallDelete] -Name: "{userstartup}\{#MyAppName}.lnk"; Type: files -Name: "{commonstartup}\{#MyAppName}.lnk"; Type: files -Name: "{app}"; Type: dirifempty -Name: "{pf}\{#MyAppPublisher}"; Type: dirifempty -Name: "{localappdata}\{#MyAppPublisher}\{#MyAppName}"; Type: filesandordirs -Name: "{localappdata}\{#MyAppPublisher}"; Type: dirifempty - -[Code] -procedure InitializeWizard(); -begin - - if InstallVCRedist() then begin - idpDownloadAfter( wpReady ); - idpSetDetailedMode( True ); - end; - -end; +#if Platform == "x64" + #define MyBitness "64-bit" +#else + #define MyBitness "32-bit" +#endif + +#define MyAppExe ExtractFileName( TargetPath ) +#define MyAppSource ( TargetPath ) +#define MyAppName GetStringFileInfo( MyAppSource, INTERNAL_NAME ) +#define MyAppVersion GetFileProductVersion( MyAppSource ) +#define MyAppCopyright GetFileCopyright( MyAppSource ) +#define MyAppPublisher GetFileCompany( MyAppSource ) +#define MyAppURL GetStringFileInfo( MyAppSource, "Comments" ) +#define MyOutputDir ExtractFileDir( TargetPath ) +#define MyOutput LowerCase( StringChange( MyAppName + " " + MyAppVersion + " " + MyBitness, " ", "_" ) ) + +#include "idp\lang\russian.iss" +#include "idp\idp.iss" +#include "dep\lang\russian.iss" +#include "dep\dep.iss" +#include "vcredist.iss" + +[Setup] +AppId={#MyAppName} +AppName={#MyAppName} {#MyBitness} +AppVersion={#MyAppVersion} +VersionInfoVersion={#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +AppMutex=Global\{#MyAppName} +AppCopyright={#MyAppCopyright} +DefaultDirName={pf}\{#MyAppPublisher}\{#MyAppName} +DefaultGroupName={#MyAppName} +OutputDir={#MyOutputDir} +OutputBaseFilename={#MyOutput} +Compression=lzma2/ultra64 +SolidCompression=yes +InternalCompressLevel=ultra64 +LZMAUseSeparateProcess=yes +PrivilegesRequired=admin +UninstallDisplayIcon={app}\{#MyAppExe},0 +DirExistsWarning=no +WizardImageFile=compiler:WizModernImage-IS.bmp +WizardSmallImageFile=compiler:WizModernSmallImage-IS.bmp +SetupMutex=Global\Setup_{#MyAppName} +OutputManifestFile=Setup-Manifest.txt +ChangesAssociations=yes +#if Platform == "x64" +ArchitecturesInstallIn64BitMode=x64 +ArchitecturesAllowed=x64 +#endif + +[Languages] +Name: "en"; MessagesFile: "compiler:Default.isl" +Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}" + +[Files] +Source: "{#MyAppSource}"; DestDir: "{app}"; Flags: replacesameversion uninsrestartdelete +Source: "..\README.md"; DestName: "ReadMe.txt"; DestDir: "{app}"; Flags: replacesameversion uninsrestartdelete +Source: "..\LICENSE"; DestName: "License.txt"; DestDir: "{app}"; Flags: replacesameversion uninsrestartdelete + +[Icons] +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExe}"; Tasks: desktopicon +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExe}" +Name: "{group}\ReadMe.txt"; Filename: "{app}\ReadMe.txt" +Name: "{group}\License.txt"; Filename: "{app}\License.txt" +Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" + +[Run] +Filename: "{app}\{#MyAppExe}"; Parameters: "/RegServer"; StatusMsg: "Registering..." +Filename: "{app}\{#MyAppExe}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall runasoriginaluser + +[Registry] +Root: HKCU; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}"; Flags: dontcreatekey uninsdeletekey +Root: HKCU; Subkey: "Software\{#MyAppPublisher}"; Flags: dontcreatekey uninsdeletekeyifempty + +[UninstallRun] +Filename: "{app}\{#MyAppExe}"; Parameters: "/UnRegServer"; StatusMsg: "Unregistering..."; Flags: skipifdoesntexist + +[UninstallDelete] +Name: "{userstartup}\{#MyAppName}.lnk"; Type: files +Name: "{commonstartup}\{#MyAppName}.lnk"; Type: files +Name: "{app}"; Type: dirifempty +Name: "{pf}\{#MyAppPublisher}"; Type: dirifempty +Name: "{localappdata}\{#MyAppPublisher}\{#MyAppName}"; Type: filesandordirs +Name: "{localappdata}\{#MyAppPublisher}"; Type: dirifempty + +[Code] +procedure InitializeWizard(); +begin + + if InstallVCRedist() then begin + idpDownloadAfter( wpReady ); + idpSetDetailedMode( True ); + end; + +end;