Click here to Skip to main content
15,921,463 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to emit alarm sound on computer without soundcard Pin
GameProfessor28-Apr-08 21:18
GameProfessor28-Apr-08 21:18 
GeneralRe: How to emit alarm sound on computer without soundcard Pin
Saurabh.Garg28-Apr-08 22:10
Saurabh.Garg28-Apr-08 22:10 
AnswerRe: How to emit alarm sound on computer without soundcard Pin
Ozer Karaagac29-Apr-08 2:03
professionalOzer Karaagac29-Apr-08 2:03 
QuestionMDI Child Outside of MDI Parent? Pin
Lewis J28-Apr-08 10:09
Lewis J28-Apr-08 10:09 
AnswerRe: MDI Child Outside of MDI Parent? Pin
David Crow28-Apr-08 10:11
David Crow28-Apr-08 10:11 
GeneralRe: MDI Child Outside of MDI Parent? Pin
Lewis J28-Apr-08 12:46
Lewis J28-Apr-08 12:46 
AnswerRe: MDI Child Outside of MDI Parent? Pin
Chris Meech29-Apr-08 5:16
Chris Meech29-Apr-08 5:16 
QuestionHow To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 9:33
MrFloyd200928-Apr-08 9:33 
Hi everybody.
I have a problem with Serial Communication in MFC. My program could not open serial port and the error is INVALID_HANDLE_VALUE. But if I open the Hyper Terminal program before opening my program, my code is running and I had succeed open port and read port operations. I can't understand this situation.

Thanks in advance...

Port settings are like these (These are parameters)
Baud Rate : 9600
Parity : Even
Stop Bits : 1
Data Bits : 7

And the scale is connected COM1 port to the computer.

My simple code is below as:
////////////////////////////
dcb.DCBlength=sizeof(DCB);
dcb.BaudRate=(unsigned long)atol(m_sBaudRate);
if ( m_sParity.Compare("None") == 0 )
dcb.Parity = NOPARITY;
else
if ( m_sParity.Compare("Even") == 0 )
dcb.Parity = EVENPARITY;
else
if ( m_sParity.Compare("Odd") == 0 )
dcb.Parity = ODDPARITY;
else
dcb.Parity = NOPARITY;
.........
.........
hComm = CreateFile(m_sCOM /*COM1*/,
GENERIC_READ | GENERIC_WRITE,
0,
/* comm devices must be opened w/exclusive-access */ NULL,
/* no security attrs */ OPEN_EXISTING,
/* comm devices must use OPEN_EXISTING */ 0,
/* not overlapped I/O */ NULL /* hTemplate must be NULL for comm devices */ );

if (hComm == INVALID_HANDLE_VALUE)
{
AfxMessageBox("Port not opened!");
}
..............................
..............................
ReadData(m_sResults);
///////////////////////////////////////////////////////////
AnswerRe: How To Connect Serial Port in MFC? Pin
CPallini28-Apr-08 9:40
mveCPallini28-Apr-08 9:40 
GeneralRe: How To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 9:53
MrFloyd200928-Apr-08 9:53 
AnswerRe: How To Connect Serial Port in MFC? Pin
David Crow28-Apr-08 9:44
David Crow28-Apr-08 9:44 
General[Message Deleted] Pin
MrFloyd200928-Apr-08 9:58
MrFloyd200928-Apr-08 9:58 
GeneralRe: How To Connect Serial Port in MFC? Pin
David Crow28-Apr-08 10:01
David Crow28-Apr-08 10:01 
GeneralRe: How To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 10:05
MrFloyd200928-Apr-08 10:05 
GeneralRe: How To Connect Serial Port in MFC? Pin
David Crow28-Apr-08 10:09
David Crow28-Apr-08 10:09 
GeneralRe: How To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 10:19
MrFloyd200928-Apr-08 10:19 
GeneralRe: How To Connect Serial Port in MFC? Pin
CPallini28-Apr-08 10:28
mveCPallini28-Apr-08 10:28 
GeneralRe: How To Connect Serial Port in MFC? Pin
David Crow28-Apr-08 10:40
David Crow28-Apr-08 10:40 
GeneralRe: How To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 10:55
MrFloyd200928-Apr-08 10:55 
GeneralRe: How To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 11:00
MrFloyd200928-Apr-08 11:00 
GeneralRe: How To Connect Serial Port in MFC? Pin
David Crow28-Apr-08 11:06
David Crow28-Apr-08 11:06 
GeneralRe: How To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 11:40
MrFloyd200928-Apr-08 11:40 
GeneralRe: How To Connect Serial Port in MFC? Pin
Randor 28-Apr-08 12:42
professional Randor 28-Apr-08 12:42 
GeneralRe: How To Connect Serial Port in MFC? Pin
CPallini28-Apr-08 21:13
mveCPallini28-Apr-08 21:13 
GeneralRe: How To Connect Serial Port in MFC? Pin
MrFloyd200928-Apr-08 23:11
MrFloyd200928-Apr-08 23:11 

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.