Witam,
Piszę aplikację w c++ builder , która ma się komunikować z portem com. Niestety nie mogę wybrać portu com ani prędkości transmisji jakby combox1 i 2 wgl nie działały zostają podkreślone w kodzie i komunikat cannot initialize object parameter of type 'Vcl::TCustomListControll' with an expression of type 'Vcl::TComboBox', zarówno w RichEdit cannot initialize object parameter of type 'Vcl::TControl' with an expression of type 'Vcl::TrichEdit'. Szukałem już wątku w necie lecz nic nie znalazłem :/ proszę o pomoc!
void __fastcall TForm1::OpenCommClick(TObject *Sender)
{ // -----wybór portu
switch (ComboBox1->ItemIndex) { //przy ComboBox1 podkreślenie i komunikat: cannot initialize object parameter of type 'Vcl::Controls::TCustomListControll' with an expression of type 'Vcl::Stdctrls::TComboBox'
case 0:
portName = _T("COM1");
break;
case 1:
portName = _T("COM2");
break;
case 2:
portName = _T("COM3");
break;
case 3:
portName = _T("COM4");
break;
case 4:
portName = _T("COM5");
break;
case 5:
portName = _T("COM6");
break;
default:
portName = _T("COM1");
}
hCommDev = CreateFile(portName, GENERIC_READ |
GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (hCommDev != INVALID_HANDLE_VALUE) {
// sprawdza, czy port jest otwarty prawidłowo
SetupComm(hCommDev, cbInQueue, cbOutQueue);
dcb.DCBlength = sizeof(dcb);
GetCommState(hCommDev, &dcb);
// wybór prędkości transmisji
switch (ComboBox2->ItemIndex) {//przy ComboBox1 podkreślenie i komunikat: cannot initialize object parameter of type 'Vcl::Controls::TCustomListControll' with an expression of type 'Vcl::Stdctrls::TComboBox'
case 0:
dcb.BaudRate=CBR_300;
break;
case 1:
dcb.BaudRate=CBR_1200;
break;
case 2:
dcb.BaudRate=CBR_9600;
break;
default:
dcb.BaudRate=CBR_1200;
}
//------
int __fastcall RSreceive(void* Parameter)
{
bResult = readSerialPort(hCommDev, &bytesRead, sizeof(bufferIn));
if(bResult && bytesRead != 0)
Form1->RichEdit2->Text = bufferIn; /przy RichEdit2 podkreślenie i komunikat: cannot initialize object parameter of type 'Vcl::Controls::TControl' with an expression of type 'Vcl::Comctrls::TrichEdit'
else
MessageBox(NULL, sbuffer7, sbuffer1, MB_OK);
return TRUE;
}