• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
November 23, 2024, 09:45:37 am

News:

SMF - Just Installed!


Runtime Create in CBuilder

Started by Roman Novgorodov, July 02, 2009, 01:52:17 am

Previous topic - Next topic

Roman Novgorodov

Hello

The following sample shows simple way to create an instance of TnrComm component in CBuilder (BCB, C++Builder etc) at runtime.
It inits the general properties and assigns an event on data receiving.



TnrComm *ComPort;

//--- create instance of component ...

void __fastcall TForm1::Button1Click(TObject *Sender)
{
        ComPort = new TnrComm(Application);
        ComPort->ComPortNo      = 1;
        ComPort->BaudRate       = 19200;
        ComPort->ByteSize       = 8;
        ComPort->Parity         = 0;
        ComPort->StopBits       = 0;
        ComPort->TerminalUsage  = 0;
        ComPort->TraceStates = TTraceStates() << tsRxChar;
        ComPort->OnAfterReceive = (TOnReceived) &ComPortAfterReceivedd;
        ComPort->Active         = true;
}

//--- event handler ---------
void __fastcall TForm1::ComPortAfterReceivedd(TObject *Com, Pointer Buffer,
      DWORD Received)
{
        OutputDebugString("DATA!!!!!!");
}


Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.