MFC_Func_自定义消息

#define WM_THREADUSERMSG WM_USER+101

enum{STOP_THREAD,BIT_WORD,MORE_POINT_BIT,MORE_WORD,INT_16,INT_32,DFLOAT32,ASCII,DECIMAL10,HEX16,SORT_0_F,SORT_F_0,POINT16,POINT10,SHOW_NEW_DATA};//子线程返回给主线程参数的类型

PostThreadMessage(threadID,WM_THREADUSERMSG,BIT_WORD,0);  //停止子线程

while(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(msg.message==WM_THREADUSERMSG) //WM_THREADUSERMSG为自定义消息
{
GetMessage(&msg,NULL,0,0);
switch(msg.wParam)
{
case BIT_WORD://位&字
pElementBatchView->m_BMonitorType=1;//位&字
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case MORE_POINT_BIT://多点位
pElementBatchView->m_BMonitorType=2;//多点位
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case MORE_WORD://多点字
pElementBatchView->m_BMonitorType=3;//多点字
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case INT_16://16位整数
pElementBatchView->m_BShowType=1;//32位整数
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
break;
case INT_32://32位整数
pElementBatchView->m_BShowType=2;//32位整数
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case DFLOAT32://实数(单精度)
pElementBatchView->m_BShowType=3;//实数(单精度)
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case ASCII://ascii字符
pElementBatchView->m_BShowType=5;//ascii字符
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case DECIMAL10://10进制
pElementBatchView->m_BValueType=1;//10进制
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case HEX16://16进制
pElementBatchView->m_BValueType=2;//16进制
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case SORT_0_F://从0-F
pElementBatchView->m_BBitOrderType=1;//从0-F
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case SORT_F_0://从F-0
pElementBatchView->m_BBitOrderType=2;//从F-0
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case POINT16://16点
pElementBatchView->m_BPointType=1;//16点
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case POINT10://10点
pElementBatchView->m_BPointType=2;//10点
pElementBatchView->CheckError();
pElementBatchView->ShowListTitle();
pElementBatchView->ShowListLeftVariable();//显示左边变量列表
nStartRow=0;//开始显示的行号
//pElementBatchView->EnableControl(true);
break;
case SHOW_NEW_DATA://拖动垂直滚动条的时候显示新数据
{
str=pElementBatchView->m_ElementList.GetItemText(msg.lParam,0);
nStartRow=msg.lParam;//开始显示的行号
}
//pElementBatchView->m_ElementList.
break;
default:
break;
}
//该消息所对应的操作
}
else if(msg.message==WM_QUIT)
{
pElementBatchView->PostMessage(WM_USERMSG,STOP_THREAD,0);//停止监视
pipeclient.Close();
return false;
}
}

posted @ 2019-07-26 16:34  石首桃花山  阅读(153)  评论(0编辑  收藏  举报