📄 maintoolwindowctrl.cpp
字号:
/************************************************************************
*
* Resource ID Organiser Add-In for Visual C++
*
* (c) Copyright 2000-2005 by Riverblade Limited (UK). All rights reserved.
*
************************************************************************
*
* Description : CMainToolWindowCtrl - implements the ResOrg toolwindow
*
* Compiler : Microsoft Visual C++ .NET 2003
*
* Target
* Environment : Windows 2000/XP/Vista;
* Visual Studio 2002, 2003 or 2005
*
* NOTE:
*
* This software is provided "as is". All title and copyrights in and
* to the software, including but not limited to any images, text etc.
* etc. incorporated into it, are the property of Anna-Jayne Metcalfe
* and Riverblade Limited, except where acknowledged otherwise.
*
* Your may freely use this code in your own products, PROVIDED
* this notice is not removed or modified.
*
* Please visit http://www.riverblade.co.uk/products/resorg or email
* support@riverblade.co.uk for latest updates and product support
*
************************************************************************
*
* MODIFICATION HISTORY:
*
* This is a controlled document. See project configuration
* control tool for latest version and full version history.
*
* $Archive: /Projects/AddIns/ResOrg/ResOrgNETAddIn/MainToolWindowCtrl.cpp $
* $Revision: 1 $
* $Date: 22/10/05 11:10 $
* $Author: Anna $
*
* $History: MainToolWindowCtrl.cpp $
*
* ***************** Version 1 *****************
* User: Anna Date: 22/10/05 Time: 11:10
* Created in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
*
* $Nokeywords: $
*
************************************************************************/
#include "stdafx.h"
#include "MainToolWindowCtrl.h"
const UINT WM_RESORG_OPEN = ::RegisterWindowMessage( _T("ResOrgShowMainWnd") );
static bool FillComboBox( WTL::CComboBox* pCtrl,
const CStringArray& arrayChoices,
LPCTSTR pszSelection)
{
if (NULL != pCtrl)
{
pCtrl->ResetContent();
for (int n = 0; n < arrayChoices.GetSize(); n++)
{
pCtrl->AddString( arrayChoices[n] );
}
pCtrl->SelectString(-1, pszSelection);
return true;
}
return false;
}
HRESULT CMainToolWindowCtrl::Initialise(IDispatch* pDispatch, HWND hWndResOrg)
{
CComPtr<EnvDTE::_DTE> pDTE;
pDispatch->QueryInterface(&pDTE);
m_AutomationHelper.SetDTE(pDTE);
m_hWndResOrg = hWndResOrg;
Refresh();
return S_OK;
}
HRESULT CMainToolWindowCtrl::Refresh(void)
{
AFX_MANAGE_STATE( ::AfxGetStaticModuleState() );
if (m_FileChangeMonitor.IsMonitoring() )
{
m_FileChangeMonitor.Stop();
}
if (UpdateSymbolFilesCtrl() && !m_sWorkspacePathName.IsEmpty() && !m_sResourceSymbolFile.IsEmpty() )
{
CNGSplitPath split(m_sWorkspacePathName);
CString sWorkspaceFolder = split.GetDrive() + split.GetDirectory();
CString sPathName = ::CombinePath(sWorkspaceFolder, m_sResourceSymbolFile);
// If the file has changed, parse it and update statistics
if ( ConfigureSymbolManager(m_pSymbols, sPathName) )
{
UpdateSymbolPropertiesCtrls();
m_FileChangeMonitor.Start( sPathName,
m_hWnd,
WM_USER_RESID_FILE_CHANGED);
}
}
SetAvailableControls();
return S_OK;
}
LRESULT CMainToolWindowCtrl::OnInitDialog(HWND hWnd, LPARAM lParam)
{
UNREFERENCED_PARAMETER(hWnd);
UNREFERENCED_PARAMETER(lParam);
LRESULT lResult = DefWindowProc();
// Initialse the resizer
DlgResize_Init( false, // Add Gripper
false, // Set minimum tracking size
WS_CLIPCHILDREN); // Forced styles
m_ctrlProjects.Attach( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_FILE) );
m_ctrlProperties.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_PROPERTIES) );
m_ctrlEdit.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_EDIT) );
m_ctrlRenumber.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_RENUMBER) );
m_ctrlResourceRangeCaption.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_LOW_RANGE_CAPTION) );
m_ctrlResourceRange.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_LOW_RANGE) );
m_ctrlCommandRangeCaption.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_HIGH_RANGE_CAPTION) );
m_ctrlCommandRange.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_HIGH_RANGE) );
m_ctrlOutOfRangeSymbolsCaption.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_OUT_OF_RANGE_CAPTION) );
m_ctrlOutOfRangeSymbols.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_OUT_OF_RANGE) );
m_ctrlConflictsCaption.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_CONFLICTS_CAPTION) );
m_ctrlConflicts.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_SYM_CONFLICTS) );
m_ctrlWarningIcon.Attach( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_WARNING_ICON) );
m_ctrlWarningText.SubclassWindow( ::GetDlgItem(m_hWnd, IDC_TOOLWIN_WARNING_MSG) );
m_ctrlProperties.SetIcon(IDI_TOOLWIN_PROPERTIES);
m_ctrlProperties.SetTooltipText(IDS_TOOLWIN_PROPERTIES, TRUE);
m_ctrlEdit.SetIcon(IDI_TOOLWIN_EDIT);
m_ctrlEdit.SetTooltipText(IDS_TOOLWIN_EDIT, TRUE);
m_ctrlRenumber.SetIcon(IDI_TOOLWIN_RENUMBER);
m_ctrlRenumber.SetTooltipText(IDS_TOOLWIN_RENUMBER, TRUE);
ASSERT( ::IsWindow(m_ctrlWarningIcon.m_hWnd) );
m_ctrlResourceRange.SetWindowText( _T("") );
m_ctrlCommandRange.SetWindowText( _T("") );
m_ctrlOutOfRangeSymbols.SetWindowText( _T("") );
m_ctrlConflicts.SetWindowText( _T("") );
m_ctrlResourceRangeCaption.SetWindowText( _T("Resource / Control IDs:") );
m_ctrlCommandRangeCaption.SetWindowText( _T("Command IDs:") );
#ifdef _DEBUG
// The Refresh button really shouldn't be needed - it's really just there for testing
::ShowWindow(::GetDlgItem(m_hWnd, IDC_TOOLWIN_REFRESH), SW_SHOWNORMAL);
#endif
m_ctrlWarningText.SetWindowText( _T("") );
return lResult;
}
void CMainToolWindowCtrl::OnDestroy(void)
{
m_AutomationHelper.SetDTE(NULL);
}
/////////////////////////////////////////////////////////////////////////////
// CMainToolWindowCtrl message handlers
void CMainToolWindowCtrl::OnCbnSelchangeResourceSymbolFile(int nCode, UINT uID, HWND hWndCtrl)
{
AFX_MANAGE_STATE( ::AfxGetStaticModuleState() );
UNREFERENCED_PARAMETER(nCode);
UNREFERENCED_PARAMETER(uID);
UNREFERENCED_PARAMETER(hWndCtrl);
if (m_FileChangeMonitor.IsMonitoring() )
{
m_FileChangeMonitor.Stop();
}
DoDataExchange(true);
int nSel = m_ctrlProjects.GetCurSel();
if (CB_ERR != nSel)
{
m_ctrlProjects.GetLBText(nSel, m_sResourceSymbolFile.GetBuffer(_MAX_PATH) );
m_sResourceSymbolFile.ReleaseBuffer();
}
if (!m_sWorkspacePathName.IsEmpty() && !m_sResourceSymbolFile.IsEmpty() )
{
CNGSplitPath split(m_sWorkspacePathName);
CString sWorkspaceFolder = split.GetDrive() + split.GetDirectory();
CString sPathName = ::CombinePath(sWorkspaceFolder, m_sResourceSymbolFile);
// If the file has changed, parse it and update statistics
if ( ConfigureSymbolManager(m_pSymbols, sPathName) )
{
m_FileChangeMonitor.Start( sPathName,
m_hWnd,
WM_USER_RESID_FILE_CHANGED);
}
UpdateSymbolPropertiesCtrls();
}
}
void CMainToolWindowCtrl::OnBnClickedToolwinRefresh(int nCode, UINT uID, HWND hWndCtrl)
{
AFX_MANAGE_STATE( ::AfxGetStaticModuleState() );
UNREFERENCED_PARAMETER(nCode);
UNREFERENCED_PARAMETER(uID);
UNREFERENCED_PARAMETER(hWndCtrl);
Refresh();
}
void CMainToolWindowCtrl::OnBnClickedToolwinEdit(int nCode, UINT uID, HWND hWndCtrl)
{
AFX_MANAGE_STATE( ::AfxGetStaticModuleState() );
UNREFERENCED_PARAMETER(nCode);
UNREFERENCED_PARAMETER(uID);
UNREFERENCED_PARAMETER(hWndCtrl);
if (::IsWindow(m_hWndResOrg) )
{
#ifdef _RESORG_EXPIRY_DATE
::DoVersionExpiryCheck();
#endif
CNGSplitPath split(m_sWorkspacePathName);
CString sWorkspaceFolder = split.GetDrive() + split.GetDirectory();
CString sPathName = ::CombinePath(sWorkspaceFolder, m_sResourceSymbolFile);
::SendMessage(m_hWndResOrg, WM_RESORG_OPEN, 0, (LPARAM)(LPCTSTR)sPathName);
}
}
void CMainToolWindowCtrl::OnBnClickedToolwinRenumber(int nCode, UINT uID, HWND hWndCtrl)
{
AFX_MANAGE_STATE( ::AfxGetStaticModuleState() );
UNREFERENCED_PARAMETER(nCode);
UNREFERENCED_PARAMETER(uID);
UNREFERENCED_PARAMETER(hWndCtrl);
#ifdef _RESORG_EXPIRY_DATE
::DoVersionExpiryCheck();
#endif
// To renumber all the symbols in a given file we need to pick starting
// values for each of the four symbol catgories identified by the _APS_NEXT...
// symbols in each resource file.
//
// The Symbol Renumbering Wizard works this out by looking at the values
// of existing symbols in the resource symbol file.
//
CRenumWizard Wizard;
Wizard.Initialise(m_pSymbols);
if (ID_WIZFINISH == Wizard.DoModal() )
{
if (m_pSymbols->IsModified() )
{
if (Save(m_pSymbols) )
{
UpdateSymbolPropertiesCtrls();
}
else
{
// Restore previous values
OnCbnSelchangeResourceSymbolFile(0, 0, NULL);
}
}
}
}
void CMainToolWindowCtrl::OnBnClickedToolwinProperties(int nCode, UINT uID, HWND hWndCtrl)
{
AFX_MANAGE_STATE( ::AfxGetStaticModuleState() );
UNREFERENCED_PARAMETER(nCode);
UNREFERENCED_PARAMETER(uID);
UNREFERENCED_PARAMETER(hWndCtrl);
#ifdef _RESORG_EXPIRY_DATE
::DoVersionExpiryCheck();
#endif
CResourceSymbolFilePropertySheet dlg( IDP_SYM_FILE_PROPERTIES_CAPTION,
::AfxGetMainWnd() );
dlg.Initialise(m_pSymbols, NULL);
if (IDOK == dlg.DoModal())
{
if (m_pSymbols->IsModified() )
{
if (Save(m_pSymbols) )
{
UpdateSymbolPropertiesCtrls();
}
else
{
// Restore previous values
OnCbnSelchangeResourceSymbolFile(0, 0, NULL);
}
}
}
}
LRESULT CMainToolWindowCtrl::OnMsgResourceSymbolFileChanged(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE( ::AfxGetStaticModuleState() );
UNREFERENCED_PARAMETER(uMsg);
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
// Refresh the displayed properties and restart the monitor
OnCbnSelchangeResourceSymbolFile(0, 0, NULL);
return 0L;
}
/////////////////////////////////////////////////////////////////////////////
// CMainToolWindowCtrl implementation
bool CMainToolWindowCtrl::UpdateSymbolFilesCtrl(void)
{
m_sWorkspacePathName = m_AutomationHelper.GetSolutionPathName();
CStringArray arrayProjects;
m_AutomationHelper.GetProjectNames(arrayProjects);
CStringArray arraySymbolFilePathNames;
for (int n = 0; n < arrayProjects.GetSize(); n++)
{
CString sProject = arrayProjects[n];
if (!sProject.IsEmpty() )
{
CString sResourceFile = m_AutomationHelper.GetResourceFileName(sProject);
if (!sResourceFile.IsEmpty() )
{
CString sSymbolFile = ::GetSymbolFileName(sResourceFile);
if (!sSymbolFile.IsEmpty())
{
arraySymbolFilePathNames.Add(sSymbolFile);
}
}
}
}
CStringArray arraySymbolFiles;
for (int n = 0; n < arraySymbolFilePathNames.GetSize(); n++)
{
CString sSymbolFile = arraySymbolFilePathNames[n];
if (!sSymbolFile.IsEmpty() )
{
CString sRelativeFileName;
LPTSTR pszRelativeFileName = sRelativeFileName.GetBuffer(_MAX_PATH);
::PathRelativePathTo( pszRelativeFileName,
m_sWorkspacePathName,
FILE_ATTRIBUTE_NORMAL,
sSymbolFile,
FILE_ATTRIBUTE_NORMAL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -