W
W-cat
Unregistered / Unconfirmed
GUEST, unregistred user!
void __fastcall TForm1::Button2Click(TObject *Sender)
{
m_flag = 0;
AnsiString str = "SendUDP";
:ostMessage( this->Handle, _ID_MSG, 0, 0 );
UDP_Send->SendBuffer( str.c_str(), str.Length(), str.Length() );
m_flag = 1000;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::UDP_RecDataReceived(TComponent *Sender,
int NumberBytes, AnsiString FromIP, int Port)
{
char *strRec;
strRec = new char[NumberBytes + 1];
UDP_Rec->ReadBuffer( strRec, NumberBytes+1, NumberBytes );
Edit1->Text = strRec;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OnProc( TMessage &Message )
{
Edit2->Text = m_flag;
}
现象:
当Button2按下后,Edit2中的内容显示0。
如果交换PostMessage和UDP_Send->SendBuffer后,Edit2中的内容显示1000.
请问:能否解释上述现象的原理?
{
m_flag = 0;
AnsiString str = "SendUDP";
:ostMessage( this->Handle, _ID_MSG, 0, 0 );
UDP_Send->SendBuffer( str.c_str(), str.Length(), str.Length() );
m_flag = 1000;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::UDP_RecDataReceived(TComponent *Sender,
int NumberBytes, AnsiString FromIP, int Port)
{
char *strRec;
strRec = new char[NumberBytes + 1];
UDP_Rec->ReadBuffer( strRec, NumberBytes+1, NumberBytes );
Edit1->Text = strRec;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OnProc( TMessage &Message )
{
Edit2->Text = m_flag;
}
现象:
当Button2按下后,Edit2中的内容显示0。
如果交换PostMessage和UDP_Send->SendBuffer后,Edit2中的内容显示1000.
请问:能否解释上述现象的原理?