Click here to Skip to main content
15,913,262 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to use SetWindowsHookEx to hook onto CreateWindowEx ? Pin
Stephen Hewitt18-Sep-06 13:56
Stephen Hewitt18-Sep-06 13:56 
GeneralRe: How to use SetWindowsHookEx to hook onto CreateWindowEx ? Pin
jipai20-Sep-06 15:39
jipai20-Sep-06 15:39 
AnswerRe: How to use SetWindowsHookEx to hook onto CreateWindowEx ? Pin
Naveen17-Sep-06 17:58
Naveen17-Sep-06 17:58 
GeneralRe: How to use SetWindowsHookEx to hook onto CreateWindowEx ? Pin
jipai17-Sep-06 18:44
jipai17-Sep-06 18:44 
AnswerRe: How to use SetWindowsHookEx to hook onto CreateWindowEx ? Pin
Hamid_RT17-Sep-06 19:52
Hamid_RT17-Sep-06 19:52 
GeneralRe: How to use SetWindowsHookEx to hook onto CreateWindowEx ? Pin
jipai18-Sep-06 6:36
jipai18-Sep-06 6:36 
GeneralRe: How to use SetWindowsHookEx to hook onto CreateWindowEx ? Pin
Hamid_RT18-Sep-06 9:43
Hamid_RT18-Sep-06 9:43 
Questionworking with a COM port in C++/MFC Pin
jet91517-Sep-06 14:29
jet91517-Sep-06 14:29 
I have created a MFC project in Visual C++ .NET. My goal is read in what is coming from COM port 4.
Here is the entire function below with some comments on what happens:

<br />
BOOL CReadComDlg::ConfigureCOMPort()<br />
{<br />
  CString strPort;<br />
  BOOL fSuccess;<br />
  iCOMPortNumber = 4;  //looked at the device manager to get this<br />
<br />
  strPort.Format("COM%d", iCOMPortNumber) ;<br />
<br />
  //Create the handle for reading from the COM port<br />
  //--returns a valid handle--<br />
  m_hFile =  CreateFile( strPort,                    <br />
			 GENERIC_READ | GENERIC_WRITE,<br />
		         (DWORD)NULL,	// exclusive access<br />
 			 NULL,			// no security<br />
		         OPEN_EXISTING,<br />
			 FILE_ATTRIBUTE_NORMAL,<br />
			 NULL	);		// hTemplate<br />
<br />
  //Check weather the handle is valid or not<br />
  if (INVALID_HANDLE_VALUE == m_hFile)<br />
  {<br />
    AfxMessageBox( "ERROR 2: unable to connect to COM port." );<br />
    return FALSE;<br />
  }<br />
<br />
<br />
  // suggest the buffer sizes for the COM port.<br />
  //--this function fails, error code 995 but according to MSDN, this is <br />
  //only a suggestion to the hardware so i suppose it is okay that it fails.--<br />
  SetupComm( m_hFile,		//handle<br />
	    (DWORD)2048,	//input buffer, in bytes<br />
	    (DWORD)2048);	//output buffer, in bytes<br />
<br />
	<br />
  //get the current control settings of the COM port<br />
  //--This function fails---<br />
  DCB dcb;<br />
  fSuccess = GetCommState(m_hFile,&dcb);<br />
<br />
  if (!fSuccess) <br />
  {<br />
    //--dError == 995<br />
    DWORD dError = GetLastError();<br />
<br />
    // Handle the error.<br />
    AfxMessageBox ("Error 3: Failed to Get the System Communication Settings.", MB_OK|MB_ICONEXCLAMATION );<br />
    return FALSE;<br />
  }<br />
.<br />
.<br />
.<br />
.<br />
}<br />


Both functions return error code 995: ERROR_OPERATION_ABORTED = The I/O operation has been aborted because of either a thread exit or an application request.

What does this mean? What am i doing wrong? When I use hyperterminal to setup the connection it works fine. I want to be able to receive data from the COM port. I don't even want to send anything out to the COM port.

If anyone has any suggestions, helpful links, or sample code that would be very helpful. Thank you for your time.
QuestionPassing data from modal dialog. Pin
SzyKam17-Sep-06 12:57
SzyKam17-Sep-06 12:57 
AnswerRe: Passing data from modal dialog. Pin
Christian Graus17-Sep-06 13:02
protectorChristian Graus17-Sep-06 13:02 
GeneralRe: Passing data from modal dialog. Pin
SzyKam17-Sep-06 13:12
SzyKam17-Sep-06 13:12 
GeneralRe: Passing data from modal dialog. Pin
Christian Graus17-Sep-06 13:15
protectorChristian Graus17-Sep-06 13:15 
GeneralRe: Passing data from modal dialog. Pin
SzyKam17-Sep-06 13:26
SzyKam17-Sep-06 13:26 
GeneralRe: Passing data from modal dialog. Pin
Christian Graus17-Sep-06 13:39
protectorChristian Graus17-Sep-06 13:39 
GeneralRe: Passing data from modal dialog. Pin
S Douglas17-Sep-06 23:28
professionalS Douglas17-Sep-06 23:28 
GeneralRe: Passing data from modal dialog. Pin
Christian Graus17-Sep-06 23:52
protectorChristian Graus17-Sep-06 23:52 
GeneralRe: Passing data from modal dialog. Pin
S Douglas18-Sep-06 0:37
professionalS Douglas18-Sep-06 0:37 
GeneralRe: Passing data from modal dialog. Pin
S Douglas18-Sep-06 0:47
professionalS Douglas18-Sep-06 0:47 
AnswerRe: Passing data from modal dialog. Pin
erfi17-Sep-06 23:19
erfi17-Sep-06 23:19 
QuestionLoadMenu problem Pin
Mohammad A Gdeisat17-Sep-06 12:02
Mohammad A Gdeisat17-Sep-06 12:02 
AnswerRe: LoadMenu problem Pin
Mohammad A Gdeisat17-Sep-06 12:16
Mohammad A Gdeisat17-Sep-06 12:16 
GeneralRe: LoadMenu problem [modified] Pin
erfi17-Sep-06 19:49
erfi17-Sep-06 19:49 
GeneralRe: LoadMenu problem Pin
Mohammad A Gdeisat18-Sep-06 1:39
Mohammad A Gdeisat18-Sep-06 1:39 
QuestionCan't set Window name when using CreateWindow Pin
BarryOg17-Sep-06 12:02
BarryOg17-Sep-06 12:02 
AnswerRe: Can't set Window name when using CreateWindow Pin
Roland Rüdenauer17-Sep-06 12:30
Roland Rüdenauer17-Sep-06 12:30 

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.