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

📄 resorgprojectsview.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		int nColumn			= LOWORD(lParamSort);
		BOOL bSortAscending	= HIWORD(lParamSort);

		switch (nColumn)
		{
			case 0:
				{
					CString sItem1 = Workspace.GetName(pItem1);
					CString sItem2 = Workspace.GetName(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;
}


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

	// First, extract the rc file name by parsing the .dsp file
	CString sResourceFile = Workspace.GetResourceFileName(sProject);
	if (!sResourceFile.IsEmpty())
	{
		// Retrieve the name of the symbol file by parsing the rc file
		CString sSymbolFile = ::GetSymbolFileName(sResourceFile);
		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);

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

				Workspace.CloseResourceFile(sResourceFile);

				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 CResOrgProjectsView::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();
}


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

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


/////////////////////////////////////////////////////////////////////////////
// CResOrgProjectsView message handlers

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


//	Context Menu handler
void CResOrgProjectsView::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 CResOrgProjectsView::OnDblClick(NMHDR* /*pNMHDR*/, LRESULT* pResult) 
{
	*pResult = 0;

	OnCmdOpenProject();
}


void CResOrgProjectsView::OnCmdOpenProject(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgProjectsDoc* 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 CResOrgProjectsView::OnCmdOpenProjectsTogether(void)
{
	// TO DO: Display a progress bar if there's more than a handful of files
	int nSelCount = GetListCtrl().GetSelectedCount();

	if (nSelCount > 0)
	{
		CResOrgProjectsDoc* 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)
			{
				CResOrgAddInApp* pApp = static_cast<CResOrgAddInApp*>( ::AfxGetApp() );

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


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


void CResOrgProjectsView::OnCmdRenumberProject(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgProjectsDoc* 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 CResOrgProjectsView::OnUpdateRenumberProject(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() == 1);
}


void CResOrgProjectsView::OnCmdProjectProperties(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgProjectsDoc* 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 CResOrgProjectsView::OnUpdateProjectProperties(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() == 1);
}

⌨️ 快捷键说明

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