Click here to Skip to main content
15,905,229 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: resizing the dialog box along with the controls for all resolutions Pin
Paolo Messina26-Jul-00 10:29
professionalPaolo Messina26-Jul-00 10:29 
GeneralVisual Studio and Intellisense Pin
Jeremy Davis25-Jul-00 3:26
Jeremy Davis25-Jul-00 3:26 
GeneralRe: Visual Studio and Intellisense Pin
peterchen25-Jul-00 9:47
peterchen25-Jul-00 9:47 
GeneralRe: Visual Studio and Intellisense Pin
Mike Dunn25-Jul-00 10:13
Mike Dunn25-Jul-00 10:13 
GeneralPop-up menus Pin
Roger25-Jul-00 1:58
Roger25-Jul-00 1:58 
GeneralRe: Pop-up menus Pin
Igor Chouvalov25-Jul-00 4:38
Igor Chouvalov25-Jul-00 4:38 
Generalvirtual serial port Pin
herb124-Jul-00 12:04
herb124-Jul-00 12:04 
GeneralRe: virtual serial port Pin
Gert Boddaert25-Jul-00 4:10
Gert Boddaert25-Jul-00 4:10 
I suppose you do not control (the source) of the existing application. So you have to figure out how it talks to the COM port.

If it uses its own COM driver, you will have to emulate this driver, which can be more difficult (depending on whether you are used to writing drivers) than rewriting the existing application.

If it uses the Win32 CreateFile API call to open the COM port, you can start by either trying to specify an non-existing COM port in the program, let's say port 3. Of course if this port does not exist, the program will not be able to open it. But then again, you could create this "file" yourself and mimic the Win32 COM API mechanism. (if that works, it will be the simpliest solution).

For more information, look at the CreateFile Win32 function with regard to the COM port communications.

If the program uses Hardware flow control, it might be very difficult.

I use the following code in my programs to open a COM port. I could easily 'fool' this code that there is a virtual COM port on the other side. So it depends on the existing program's implementation.

Best regards,

GBO
---

BOOL CSerial::Open()
{
COMMTIMEOUTS timeouts;
DWORD dwSerialStatus;
char szPort[16];
char strTemp[10];
DCB dcb; // Abre el puerto serie
::ZeroMemory(szPort, 16);
::ZeroMemory(strTemp, 10);
strcpy(szPort, "COM");
_ltoa( PortNum, strTemp, 10 );
strupr( strTemp );
strcat(szPort, strTemp);

hCom = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);

if (hCom == NULL || hCom == INVALID_HANDLE_VALUE)
{
// try \\.\COMxx
::ZeroMemory(szPort, 16);
strcpy(szPort, "\\\\.\\COM");
strcat(szPort, strTemp);
hCom = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
}


if (hCom != NULL && hCom != INVALID_HANDLE_VALUE)
{
if (GetCommState(hCom, &dcb))
{
// Llena la estructura del DCB
dcb.BaudRate = BaudRate;
dcb.ByteSize = DataBits;
switch (Parity)
{
case 'N' :
dcb.Parity = NOPARITY;
break;
case 'E' :
dcb.Parity = EVENPARITY;
break;
case 'O' :
dcb.Parity = ODDPARITY;
break;
}
dcb.StopBits = ONESTOPBIT;
if (SetCommState (hCom, &dcb))
{
if (GetCommModemStatus (hCom, &dwSerialStatus))
{
// Setea los timeouts de la puerta serie
timeouts.ReadIntervalTimeout = 100;
timeouts.ReadTotalTimeoutMultiplier = 1;
timeouts.ReadTotalTimeoutConstant = 100;
timeouts.WriteTotalTimeoutMultiplier = 1;
timeouts.WriteTotalTimeoutConstant = 100;
if (SetCommTimeouts (hCom, &timeouts))
{
if (PurgeComm(hCom, PURGE_TXCLEAR | PURGE_RXCLEAR |
PURGE_TXABORT | PURGE_RXABORT))
{
if (SetupComm (hCom, RxBufSiz, TxBufSiz))
{
if (EscapeCommFunction(hCom, SETDTR))
{
// All OK
}
else
{
DWORD dwError = ::GetLastError();
_ASSERT(NULL);
}
return TRUE;
}
}
}
}
}
}
}
DWORD dwError = ::GetLastError();
_ASSERT(NULL);
return FALSE;
}
QuestionMenus with bitmaps in C??? Pin
Lars Hammar24-Jul-00 11:10
sussLars Hammar24-Jul-00 11:10 
AnswerRe: Menus with bitmaps in C??? Pin
Igor25-Jul-00 4:13
Igor25-Jul-00 4:13 
QuestionHow to create MS Access file at runtime? Pin
Ammar24-Jul-00 1:54
Ammar24-Jul-00 1:54 
AnswerRe: How to create MS Access file at runtime? Pin
Sandra24-Jul-00 5:10
Sandra24-Jul-00 5:10 
GeneralGUI - minimize, maximize and close Pin
Stanik23-Jul-00 21:31
Stanik23-Jul-00 21:31 
GeneralRe: GUI - minimize, maximize and close Pin
Philip Nicoletti31-Jul-00 7:43
Philip Nicoletti31-Jul-00 7:43 
Generalmetafile to bitmap Pin
haipengl23-Jul-00 18:02
haipengl23-Jul-00 18:02 
GeneralRe: metafile to bitmap Pin
Arvind2323-Jul-00 18:37
Arvind2323-Jul-00 18:37 
GeneralRe: metafile to bitmap Pin
Feng Yuan23-Jul-00 21:47
Feng Yuan23-Jul-00 21:47 
GeneralRe: metafile to bitmap Pin
haipengl24-Jul-00 11:17
haipengl24-Jul-00 11:17 
GeneralRe: metafile to bitmap Pin
Feng Yuan25-Jul-00 16:02
Feng Yuan25-Jul-00 16:02 
GeneralPostmessage to radio control Pin
Member 351723-Jul-00 17:44
Member 351723-Jul-00 17:44 
GeneralRe: Postmessage to radio control Pin
Mike Dunn23-Jul-00 20:37
Mike Dunn23-Jul-00 20:37 
GeneralProcess-Adress Pin
tommy23-Jul-00 5:48
tommy23-Jul-00 5:48 
GeneralRe: Process-Adress Pin
Feng Yuan23-Jul-00 21:50
Feng Yuan23-Jul-00 21:50 
GeneralRe: Process-Adress Pin
tommy27-Jul-00 10:49
tommy27-Jul-00 10:49 
Generalnumber of control on a dialog resource Pin
muharrem ergoktas23-Jul-00 2:43
sussmuharrem ergoktas23-Jul-00 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.