应用程序间发送消息

void __fastcall TMainForm::Message_Re_Load(TMessage &Message)
{
    //*
    if (Message.Msg==WM_COPYDATA)
    {

        COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)Message.LParam ;
        int dataLen = pCopyData->cbData ;
        Message_Load_Bds_Form *temp = (Message_Load_Bds_Form *)pCopyData->lpData;
        if (temp->mode==list_bds)
        {
             String bdsname=String(temp->BDS_Form_Caption);
             if (!(bdsname.Trim().IsEmpty()))   
             {
                   for(int i = 0;  i< 50; i++)
                   {
                       if(BDS_Edit[i]->Caption ==bdsname)
                       {
                           ActiveBDS_Edit = BDS_Edit[i];
                            ((TfrmBDS_Edit *)MainForm->BDS_Edit[i])->Timer1->Enabled = true;
                           BDS_Edit[i]->Show();
                           BDS_Edit[i]->WindowState=wsNormal;
                           if(BDS_Edit[i]->Caption!="全矿高压供电系统图")
                           {
                           }
                           //********************************
                          // ((TfrmBDS_Edit *)MainForm->BDS_Edit[i])->Timer1->Enabled = false;
                           break;
                       }
                   }
             }
        }
        else if  (temp->mode==list_Node_Tatol)
        {

             int ifzaddr =temp->Fz;
             int inodeaddr = temp->Node;
             if (ifzaddr < 1 || inodeaddr < 1)
             {

             }
             else
             {
                  int  tmpEgisType= temp->egistype;
                  if(tmpEgisType == 0x3E||tmpEgisType == 84||tmpEgisType == 91||tmpEgisType == 73||tmpEgisType == 136||tmpEgisType == 156||tmpEgisType == 188)
                  {
                      if (Search_total_cjfz!=NULL)
                      {
                          Search_total_cjfz->Close();
                          Search_total_cjfz=NULL;
                          delete  Search_total_cjfz;
                      }
                      Search_total_cjfz = new TfrmSearch_total_Cjfz(ifzaddr,inodeaddr,255,this);
                      Search_total_cjfz->Show();

                  }
                  else
                  {
                      if (Search_total!=NULL)
                      {
                           Search_total->Close();
                           Search_total=NULL;
                           delete  Search_total;
                      }
                      Search_total = new TfrmSearch_total(ifzaddr,inodeaddr,255,username,Level,this);
                      Search_total->Show();
                  }
             }               
        } 
    }

    MainForm->Dispatch(&Message);
}

以上为消息接收部分(接收程序中)。

     HWND hWnd=::FindWindow("TMainForm", NULL);
     UINT   uMsg=::RegisterWindowMessage("WM_List_Bds_Form");
     Message_Load_Bds_Form temp_List;
     memset(temp_List.BDS_Form_Caption,0,sizeof(temp_List.BDS_Form_Caption));
     TListItem *Item;
     Item=lv_alarm_Up_computer->Selected;
     if (Item!=NULL)
     {


                strcat(temp_List.BDS_Form_Caption,Item->SubItems->Strings[2].Trim().c_str());
                temp_List.mode=list_Node_Tatol;
                std::vector<Alarm_Soe_List>::iterator it;
                for(it = Use_Alarm_Soe_List.begin(); it!= Use_Alarm_Soe_List.end(); it++)
                {
                     if (Item->Index==it->List_view_index)
                     {
                         temp_List.Fz=it->FZAddr;
                         temp_List.Node=it->NodeAddr;
                         String cc=it->linename;
                         temp_List.egistype=it->ZB_Type;
                         if (temp_List.Fz<1||temp_List.Fz>254||temp_List.Node<1||temp_List.Node>254)
                         {
                              Item=NULL ;
                              delete Item;
                         }
                         break;
                     }
                }
                COPYDATASTRUCT cds;
                cds.dwData=sizeof(temp_List);
                cds.cbData=sizeof(temp_List);
                cds.lpData= (void*)&temp_List;
                SendMessage(hWnd,WM_COPYDATA,(WPARAM)this->Handle,(LPARAM)&cds);
     }
     Item=NULL;
     delete Item;  

以上为消息发送部分(发送程序中)。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值