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

📄 resorgappprojectsview2.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 2 页
字号:

	if (!sPathName.IsEmpty())
	{
		pDoc = GetDocument()->GetOpenDocument(sPathName);
		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(sPathName);
			ASSERT(NULL != pDoc);

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


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

	CString sSymbolFile = GetSymbolFilePathName(sProject);
	if (!sSymbolFile.IsEmpty())
	{
		return OpenResourceSymbolFile(sSymbolFile, bCheckNextSymbolValues);
	}
	return NULL;
}


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


bool CResOrgAppProjectsView2::IsProject(const CString& sItem) const
{
	return false;
}


bool CResOrgAppProjectsView2::IsResourceFile(const CString& sItem) const
{
	return false;
}


bool CResOrgAppProjectsView2::IsSolution(const CString& sItem) const
{
	if ( (NULL != GetDocument() ) && (sItem == GetDocument()->GetSolutionName() ) )
	{
		return true;
	}
	return false;
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgAppProjectsView2 message handlers

int CResOrgAppProjectsView2::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	int nResult = CResOrgAppProjectsView2_BASE::OnCreate(lpCreateStruct);
	
	if (-1 != nResult)
	{
		m_ctrlProjects.EnableMultiSelect(true);

		if (!m_ctrlProjects.Create(	WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS,
									CRect(0,0,0,0),
									this,
									IDC_RESORG_SYMBOLS))
		{
			TRACE( _T("Failed to create projects tree control.\n"));

			return -1;
		}

		m_images.Create(16, 16, ILC_COLOR | ILC_MASK, 0, 1);

		m_ctrlProjects.SetImageList(&m_images, TVSIL_NORMAL);
	}
	return nResult;
}


void CResOrgAppProjectsView2::OnSize(UINT nType, int cx, int cy) 
{
	CResOrgAppProjectsView2_BASE::OnSize(nType, cx, cy);
	
	if (NULL != m_ctrlProjects.GetSafeHwnd() )
	{
		m_ctrlProjects.SetWindowPos(	NULL,
									0,
									0,
									cx,
									cy,
									SWP_SHOWWINDOW | SWP_NOZORDER
									);
	}
}


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

	OnCmdOpenProject();
}


void CResOrgAppProjectsView2::OnCmdOpenProject(void)
{
	if (NULL != GetDocument() )
	{
		// Get the first selected item
		HTREEITEM hItem = m_ctrlProjects.GetFirstSelectedItem();

		while (NULL != hItem)
		{
			CString sItem = m_ctrlProjects.GetItemText(hItem);
			ASSERT(!sItem.IsEmpty() );

			if (!sItem.IsEmpty() )
			{
				if (IsProject(sItem) )
				{
					// Open all symbol files associated with the project
				}
				else if (IsResourceFile(sItem) )
				{
					CString sResourceFilePathName = sItem;		// TODO: Get full pathname from sItem
					if (!sResourceFilePathName.IsEmpty())
					{
						// Open the symbol file associated with the resource file
						CResOrgSymbolsDoc* pSymDoc = DYNAMIC_DOWNCAST(	CResOrgSymbolsDoc,
																		OpenResourceSymbolFile( ::GetSymbolFileName(sResourceFilePathName),
																		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);
						}
					}
				}
				else if (IsSolution(sItem) )
				{
					// Open ALL symbol files within the solution
				}
				else
				{
					// Open the symbol file
				}
			}
			hItem = m_ctrlProjects.GetNextSelectedItem(hItem);
		}
	}
/*
	if (nSelCount > 0)
	{
			CStringArray arrayProjects;

			POSITION pos = m_ctrlProjects.GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = m_ctrlProjects.GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = m_ctrlProjects.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 CResOrgAppProjectsView2::OnCmdOpenProjectsTogether(void)
{
/*
	int nSelCount = m_ctrlProjects.GetSelectedCount();

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

		if (NULL != pDoc)
		{
			CStringArray arraySymbolFilePathNames;

			POSITION pos = m_ctrlProjects.GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = m_ctrlProjects.GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = m_ctrlProjects.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 CResOrgAppProjectsView2::OnUpdateOpenProjectsTogether(CCmdUI* pCmdUI)
{
//	pCmdUI->Enable( m_ctrlProjects.GetSelectedCount() >= 2);
}


void CResOrgAppProjectsView2::OnCmdRenumberProject(void)
{
/*
	if (m_ctrlProjects.GetSelectedCount() > 0)
	{
		CResOrgAppProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			POSITION pos = m_ctrlProjects.GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = m_ctrlProjects.GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = m_ctrlProjects.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 CResOrgAppProjectsView2::OnUpdateRenumberProject(CCmdUI* pCmdUI)
{
//	pCmdUI->Enable( m_ctrlProjects.GetSelectedCount() == 1);
}


void CResOrgAppProjectsView2::OnCmdProjectProperties(void)
{
/*	if (m_ctrlProjects.GetSelectedCount() > 0)
	{
		CResOrgAppProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

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

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


void CResOrgAppProjectsView2::OnUpdateProjectProperties(CCmdUI* pCmdUI)
{
//	pCmdUI->Enable( m_ctrlProjects.GetSelectedCount() == 1);
}

⌨️ 快捷键说明

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