⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resorgappprojectsview.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void CResOrgAppProjectsView::Clear(void)
{
	m_arrayProjects.RemoveAll();
}


/******************************************************************************
 *	Static callback function for List Control sorting
 *
 *	The list control will then repeatedly call this to determine how to sort
 *	its data
 *
 ******************************************************************************/

int CALLBACK CResOrgAppProjectsView::ListViewCompareProc(	LPARAM lParam1,
															LPARAM lParam2,
															LPARAM lParamSort)
{
	CString* pItem1 = (CString*)lParam1;
	CString* pItem2 = (CString*)lParam2;

	int nResult = 0;		// Default => Equal

	if ( (NULL != pItem1) && (NULL != pItem2) )
	{
		int nColumn			= LOWORD(lParamSort);
		BOOL bSortAscending	= HIWORD(lParamSort);

		switch (nColumn)
		{
			case 0:
				{
					CString sItem1 = *pItem1;
					CString sItem2 = *pItem2;

					nResult = lstrcmpi(sItem1, sItem2);

					if ( (sItem1.IsEmpty()) || (sItem2.IsEmpty()) )
					{
						nResult = -nResult;			// Modify sort so a blank entry is HIGHER than one with something in it
					}
				}
				break;

			default:
				return 0;
	   	}
		if (!bSortAscending)
		{
			nResult = -nResult;			// Sneaky way to reverse sort order...
		}
	}
	return nResult;
}


CString CResOrgAppProjectsView::GetSymbolFilePathName(const CString& sProject)
{
	CString sSymbolFilePathName;

	// First, extract the rc file name by parsing the .dsp file
	CString sResourceFilePathName = GetDocument()->GetResourceFileName(sProject);
	if (!sResourceFilePathName.IsEmpty())
	{
		// Retrieve the name of the symbol file by parsing the rc file
		sSymbolFilePathName = ::GetSymbolFileName(sResourceFilePathName);
	}
	return sSymbolFilePathName;
}


CDocument* CResOrgAppProjectsView::OpenProject(const CString& sProject,
											   BOOL bCheckNextSymbolValues /*= TRUE*/)
{
	CDocument* pDoc = NULL;

	CString sSymbolFile = GetSymbolFilePathName(sProject);
	if (!sSymbolFile.IsEmpty())
	{
		pDoc = GetDocument()->GetOpenDocument(sSymbolFile);
		if (NULL != pDoc)
		{
			// If the file is already open, just activate it
			GetDocument()->SetActiveDocument(pDoc);
		}
		else
		{
			// ...otherwise, we have to open it...
			//
			// To Do: convert to flash box
			//AfxMessageBox( "Displaying symbols for: " + sSymbolFile);

			CResOrgApp* pApp = (CResOrgApp*)::AfxGetApp();
			BOOL bCheckOption = pApp->CheckNextSymbolValues();
			pApp->CheckNextSymbolValues(FALSE);

			pDoc = pApp->OpenDocumentFile(sSymbolFile);

			pApp->CheckNextSymbolValues(bCheckOption);

			ASSERT(NULL != pDoc);
		}
		CResOrgSymbolsDoc* pSymDoc = dynamic_cast<CResOrgSymbolsDoc*>(pDoc);
		if ( (NULL != pSymDoc) && bCheckNextSymbolValues)
		{
			// This is too intrusive if we're opening multiple files
			pSymDoc->CheckNextSymbolValues();
		}
	}
	return pDoc;
}


int CResOrgAppProjectsView::DoNextSymbolValuesInUsePrompt(const CStringArray& arrayProjects)
{
	CString sProjects;

	for (int n = 0; n < arrayProjects.GetSize(); n++)
	{
		CString sLine;
	
		sLine.Format( _T("%s\\par\r\n"), arrayProjects[n]);	// Dontcha just love RTF???

		sProjects += sLine;
	}
	CNGMessageBox dlg;

	dlg.FormatMsgEx(MAKEINTRESOURCE(IDP_PRJ_SYM_NEXT_VALUES_IN_USE),
					_T("RTF"),
					sProjects);

	dlg.SetRtf();
	dlg.SetStandardIcon(IDI_WARNING);
	dlg.AddButton(IDOK, TRUE, TRUE, _T("OK") );

	return dlg.DoModal();
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgAppProjectsView message handlers

void CResOrgAppProjectsView::OnSize(UINT nType, int cx, int cy) 
{
	CResOrgAppProjectsView_BASE::OnSize(nType, cx, cy);
	
	if (m_bInitialised)
	{
		AutoSizeColumn();
	}
}


//	Context Menu handler
void CResOrgAppProjectsView::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	UNREFERENCED_PARAMETER(pWnd);

	// Make sure window is active
	GetParentFrame()->ActivateFrame();

	// Convert to client coordinates for hit testing
	// Note that TrackPopupMenu() expects its coordinates to be screen, not client!
	CPoint ptClient = point;
	ScreenToClient(&ptClient);

	UINT nFlags = 0;
	int nIndex = GetListCtrl().HitTest(ptClient, &nFlags);
	
	if (nIndex >= 0)
	{
		CCJMenu menu;
		if (menu.LoadMenu(IDM_PRJ_CONTEXT_MENU))
		{
			menu.LoadToolbar(IDM_PRJ_CONTEXT_MENU);

			CMenu* pPopup = menu.GetSubMenu(0);
			ASSERT(NULL != pPopup);

			pPopup->SetDefaultItem(ID_PROJ_OPEN);
			pPopup->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_LEFTALIGN,
								   point.x,
								   point.y,
								   AfxGetMainWnd()); // route commands through main window
			return;
		}
	}
	Default();									// Default message handling if we didn't do anything
}


void CResOrgAppProjectsView::OnDblClick(NMHDR* /*pNMHDR*/, LRESULT* pResult) 
{
	*pResult = 0;

	OnCmdOpenProject();
}


void CResOrgAppProjectsView::OnCmdOpenProject(void)
{
	int nSelCount = GetListCtrl().GetSelectedCount();

	if (nSelCount > 0)
	{
		CResOrgAppProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			CStringArray arrayProjects;

			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CResOrgSymbolsDoc* pSymDoc = DYNAMIC_DOWNCAST(	CResOrgSymbolsDoc,
																	OpenProject(sProject,
																	FALSE ) );
					if (NULL != pSymDoc)
					{
						if (pSymDoc->CheckNextSymbolValues(FALSE) )
						{
							arrayProjects.Add(sProject);
						}
					}
					else
					{
						CString sMsg;
						sMsg.Format(IDP_PRJ_NO_SYM_FILE, sProject);

						::AfxMessageBox(sMsg,
										MB_OK | MB_ICONEXCLAMATION);
					}
				}
			}
			if (Options.WarnIfNextSymbolValuesInUse())
			{
				if (arrayProjects.GetSize() > 0)
				{
					DoNextSymbolValuesInUsePrompt(arrayProjects);
				}
			}
		}
	}
}


void CResOrgAppProjectsView::OnCmdOpenProjectsTogether(void)
{
	int nSelCount = GetListCtrl().GetSelectedCount();

	if (nSelCount > 0)
	{
		CResOrgAppProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			CStringArray arraySymbolFilePathNames;

			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CString sSymbolFilePathName = GetSymbolFilePathName(sProject);

					if (!sSymbolFilePathName.IsEmpty())
					{
						arraySymbolFilePathNames.Add(sSymbolFilePathName);
					}
				}
			}
			if (arraySymbolFilePathNames.GetSize() > 0)
			{
				CResOrgApp* pApp = (CResOrgApp*)::AfxGetApp();

				pApp->OpenMultiFileSymbolsView(arraySymbolFilePathNames);
			}
			else
			{
				::AfxMessageBox(_T("No resource symbol files were found in the selected projects"),
								MB_OK | MB_ICONSTOP);
			}
		}
	}
}


void CResOrgAppProjectsView::OnUpdateOpenProjectsTogether(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() >= 2);
}


void CResOrgAppProjectsView::OnCmdRenumberProject(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgAppProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CResOrgSymbolsDoc* pDoc = dynamic_cast<CResOrgSymbolsDoc*>( OpenProject(sProject, FALSE) );
					if (NULL != pDoc)
					{
						if (pDoc->GetSymbolBuffer()->GetSymbolCount() > 0)
						{
							AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_TOOLS_RENUMBER);
						}
						else
						{
							AfxMessageBox(	_T("This file contains no symbols"),
											MB_OK | MB_ICONSTOP);
						}
					}
				}
			}
		}
	}
}


void CResOrgAppProjectsView::OnUpdateRenumberProject(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() == 1);
}


void CResOrgAppProjectsView::OnCmdProjectProperties(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgAppProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CResOrgSymbolsDoc* pDoc = dynamic_cast<CResOrgSymbolsDoc*>( OpenProject(sProject, FALSE) );
					if (NULL != pDoc)
					{
						::AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_PROPERTIES);
					}
				}
			}
		}
	}
}


void CResOrgAppProjectsView::OnUpdateProjectProperties(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() == 1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -