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

📄 mytree.cpp

📁 一个用于无刷直流电动机的驱动与控制程序.里面所用的采集卡的型号为MC08.
💻 CPP
字号:
// MyTree.cpp : implementation file
//

#include "stdafx.h"
#include "TestForm.h"
#include "MyTree.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// MyTree

MyTree::MyTree()
{	m_uFlags=0;
}

MyTree::~MyTree()
{
}


BEGIN_MESSAGE_MAP(MyTree, CTreeCtrl)
	//{{AFX_MSG_MAP(MyTree)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MyTree message handlers



void MyTree::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
		//定义指向主框架的指针
		CMainFrame *pMainFrame=(CMainFrame*) AfxGetMainWnd();

		//存放树型控件选项的标题	
		CString str;
		
		//树型控件选项索引
		int ItemIndex;
		
		//获得所点击树型控件选项的句柄
	 	HTREEITEM hItem =HitTest(point, &m_uFlags);	

		//获得所点击树型控件选项的标题
		str=GetItemText(hItem);		

	 	//进行的是与运算,对于二进制数来说都为1的情况下结果为1
	 	if ( (m_uFlags&TVHT_ONITEMLABEL))
	 	{		
			CTestFormApp  *pApp=(CTestFormApp *)AfxGetApp();
			
// 			pApp->pCTestFormView->m_Title=GetItemText(hItem);
// 			pApp->pCTestFormView->Invalidate(TRUE);
//			pApp->pEncoderDialog->Invalidate(FALSE);
//			pApp->pMotorDialog->Invalidate(FALSE);
//			pApp->pPTestDialog->Invalidate(FALSE);

//			SelectItem(hItem);
		}

		//编码
		if(str=="机械传动试验平台") 
		{
			//
			ItemIndex =  0x000;		//编码
			//MessageBox("机械传动试验平台");			
		}
		
			
		if(str== "试验项目")
		{			

			ItemIndex =  0x010;		//编码
			//MessageBox("试验类型");
		}
		
		if(str=="试验帮助系统")
		{
			//
			ItemIndex =  0x020;		//编码
			//MessageBox("试验帮助系统");
		}

		if(str=="设备调试")
		{
			//
			ItemIndex =  0x030;		//编码
			//MessageBox("试验帮助系统");
		}

		if(str=="系统设置")
		{
			//
			ItemIndex =  0x040;		//编码
			//MessageBox("试验帮助系统");
		}
			
		////////////////////
		if(str=="效率试验")
		{
			//
			ItemIndex =  0x011;
			//MessageBox("效率试验");
		}			
			
		if(str=="超载试验")
		{
			//
			ItemIndex =  0x012;
			//MessageBox("超载试验");
		}			
			
		if(str=="传动精度试验")
		{
			//
			ItemIndex =  0x013;
			//MessageBox("传动精度试验");
		}
			
		if(str=="过度过程试验")
		{
			//
			ItemIndex =  0x014;
			//MessageBox("过度过程试验");
		}
			
		if(str=="启动力矩试验")
		{
			//
			ItemIndex =  0x015;
			//MessageBox("启动力矩试验");
		}

		if(str=="空程回差试验")
		{
			//
			ItemIndex =  0x016;
			//MessageBox("刚度及回差试验");
		}
			
		if(str=="刚度及回差试验")
		{
			//
			ItemIndex =  0x017;
			//MessageBox("刚度及回差试验");
		}
			
		////////////////////
		if(str=="效率试验帮助")
		{
			//
			ItemIndex =  0x021;
		}
			
		if(str=="超载试验帮助")
		{
			//
			ItemIndex =  0x022;
		}
			
		if(str=="传动精度试验帮助")
		{
			//
			ItemIndex =  0x023;
		}
			
		if(str=="过度过程试验帮助")
		{
			//
			ItemIndex =  0x024;
		}
					
		if(str=="启动力矩试验帮助")
		{
			//
			ItemIndex =  0x025;
		}
		
		if(str=="空程回差试验帮助")	
		{
			//
			ItemIndex =  0x026;
		}	
			
		if(str=="刚度及回差试验帮助")	
		{
			//
			ItemIndex =  0x027;
		}

		////////////////////
		if(str=="伺服电机调试")
		{
			//
			ItemIndex =  0x031;
		}
			
		if(str=="效率仪调试")
		{
			//
			ItemIndex =  0x032;
		}
			
		if(str=="编码器调试")
		{
			//
			ItemIndex =  0x033;
		}

		////////////////////
		if(str=="试验设置")
		{
			//
			ItemIndex =  0x041;
		}

		//向主框架类发送消息
		pMainFrame->PostMessage(WM_TREEBAR_HIT,ItemIndex,0);		
		
		//MessageBox("123");		
	 	
	CTreeCtrl::OnLButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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