|
Are you waiting for your thread? If your main thread returns before your spawned thread returns, nothing good can happen of it.
|
|
|
|
|
Dear all
who has genetic or particle algorithm using vc++ or matlab snippet or demo? thanks all.
regards
Li Zhiyuan
25/6/2007
|
|
|
|
|
is it possible to set a menu to CWnd, CStatic etc?
|
|
|
|
|
CWnd having style overlapped or pop-up window can contain a menu bar; a child windows cannot have a menu bar.
However you can have "context menus" any where on the window
|
|
|
|
|
Hi ALL,
I am inserting my entry into the "Application" event log for Windows, thro, ReportEvent as follows,
bRet = ::ReportEvent( m_hEventSource,
wEventType,
0, //event category
INF_DUMMY,
psidCurrUser,
1,
0,
(LPCTSTR*)&lptszMessage,
NULL
);
it does one entry into the event log successfully.
but if i see the "Category" column in the event log its displayed as "None",
here i want to display some text(such as "Test category"),
If anyone know how to do it, please help me.
|
|
|
|
|
Hi,
Iam not very familiar to this. But I found in MSDN that for event id , categories you need to register message files EventMessageFile, CategoryMessageFile, and ParameterMessageFile to the registry.
Please search the msdn for messages files.
Since you passed 0 in the category it displayed none.
Best Regards
Raj
|
|
|
|
|
Yes i have created a message dll.
and i have given it as
MessageId=1
Facility=FACILITY_CHECK
SymbolicName=CATEGORY1
Language=English
Category 1
in mc file.
during call to ReportEvent,
if i give
bRet = ::ReportEvent( m_hEventSource,
wEventType,
CATEGORY1, //category
INF_DUMMY,
psidCurrUser,
1,
0,
(LPCTSTR*)&lptszMessage,
NULL
);
category column is not displaying with what text i have given for CATEGORY1.
it displaus as "Devices" in category column....
|
|
|
|
|
Have you correctly set the registry keys for the event source, particularly the "CategoryMessageFile" and its count.
And also if you define all the event, category and parameter in a single file the category must be the first.
-- modified at 9:21 Monday 25th June, 2007
|
|
|
|
|
Does any know how to implement C++ code into a C project
meaning I have a project that is C code and I code ( CLass of the code I trying to implement)
When I have a pointer to that class in a C stucture I get compile errors (maybe becuase the programs are .c extensions as opposed to .cpp)
I am using Visual Studio for the build
I am afraid If I change the extension of the programs to C++ .cpp It will screw other things up
is these anyway to "connect" these 2 piecies to code
Maybe write a compiler diretive e.g. extern CPLUSPLUS (just a guess)
Thankx
|
|
|
|
|
Hi,
Change the "compile as" option /TP this will compile your .C, .cpp file as C++ code.
That is change to CPP project.
|
|
|
|
|
This is a makefile project C code from what I understand paramter passing is different in C++
|
|
|
|
|
Just out of interest, how do you think your code might get screwed up if you change the file extension(s) to .cpp?
Cheers,
Dan
|
|
|
|
|
I think paramter passing is different for a C++ prog
|
|
|
|
|
I am basically trying to implemnt C++/C# code into a C makefile project
one project C makefile one C++/C# project into one soulution
|
|
|
|
|
You should be including a header that that C structure is defined. You should wrap that header in extern "C", ie
extern "C" <br />
{ <br />
struct MyCStruct { };<br />
}<br />
Or if you can not change that header you could include that header wrapped in extern "C" as well, from the C++ side. ie
<br />
extern "C"<br />
{<br />
#include "MyCStruct.h"<br />
}<br />
Orhun Birsoy
|
|
|
|
|
ok let me ask you then
The C code is a makefile project The Main Anchor point is The "C" struct which I will define
as you indicated as extern "C" in my C++ or C# project
The in the C code generated by the make file project I could sat if (a == "C++") myclass
Where myclass is the the Class from my C++ or C# project
I will create one soultion
does this sound do able
|
|
|
|
|
I don't think I understand what you are asking, but this site might help you more How to mix C and C++
Orhun Birsoy
|
|
|
|
|
I am trying to implement C++ oode into a C makefile project
|
|
|
|
|
Hello!
below is my code for sending AT command to the port to the device ...
i m suppose to get a response "OK" after sending "AT" to through the port but the result i get are all symbols ... can anyone help me with this ???
Thanks alot!!!
HANDLE m_hCom;
DCB m_dcb;
COMMTIMEOUTS m_CommTimeouts;
DWORD iBytesWritten = 0;
DWORD iBytesRead = 0;
char sBuffer[5];
m_hCom =CreateFile("COM7:",
GENERIC_READ | GENERIC_WRITE,
0, // exclusive access
NULL, // no security
OPEN_EXISTING,
0, // no overlapped I/O
NULL); // null template
SetupComm(m_hCom, 128, 128); // set buffer sizes
GetCommState(m_hCom, &m_dcb);
m_dcb.BaudRate = CBR_9600;
m_dcb.ByteSize = 8;
m_dcb.Parity = NOPARITY;
m_dcb.StopBits = ONESTOPBIT;
m_dcb.fAbortOnError = TRUE;
m_dcb.fBinary = TRUE;
SetCommState(m_hCom, &m_dcb);
GetCommTimeouts (m_hCom, &m_CommTimeouts);
m_CommTimeouts.ReadIntervalTimeout = 0;
m_CommTimeouts.ReadTotalTimeoutConstant = 0;
m_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
m_CommTimeouts.WriteTotalTimeoutConstant = 0;
m_CommTimeouts.WriteTotalTimeoutMultiplier = 0;
SetCommTimeouts (m_hCom, &m_CommTimeouts);
WriteFile(m_hCom,"AT\r",2,&iBytesWritten,NULL);
ReadFile(m_hCom, &sBuffer, 1, &iBytesRead, NULL);
printf("\n%s",sBuffer);
CloseHandle(m_hCom);
|
|
|
|
|
A few remarks:
(1) Why are you setting to zero all the reading timeout values?
(2) In WriteFile you're not sending the carriage return (\r), since you specified only two bytes to send.
(3) You are not checking neither the ReadFile return value nor how many bytes you obtained (i.e. the iBytesReas value, of course you have to check this only when ReadFile returns a nonzero value).
Hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I'm not sure if "COM7:" is a valid port name. You have omitted all error checking and assume everything works perfectly.
You don't have a clue whether the could be opened or not.
You should at least verify that m_hCom doesn't equal INVALID_HANDLE_VALUE after the call to ::CreateFile() .
You have set up the timeouts so that there won't be any timeout, ::ReadFile() will return immediately with whatever is found in the FIFO, if any. In practice; your device would have to send the response before you sent the request in order for the code you've written to get the response.
Have a look at this article[^]. It will show you how to implement serial communication.
Post again if anything is unclear after reading the article.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
If your doing any kind of port programming then your deffinatly going to want to check out the CSerial utility class.
http://www.codeproject.com/system/serial.asp
Its without a doubt, one kick ass class library. The sample includes C++ console, and mfc samples. Check it out pronto!
|
|
|
|
|
Hello Guru's
I am writing below code for copy the content of buffer to file
CString strLine = "";
CString buffer = "";
CStdioFile fileObj,filewrite;
CString fname;
fileObj.Open(str, CFile::modeRead | CFile::shareDenyWrite);
fname = fileObj.GetFileName();
while(fileObj.ReadString(strLine))
{
fileObj.ReadString(strLine);
buffer += strLine + "\r\n";
}
fileObj.Close();
// MessageBox(buffer);
SetDlgItemText(IDC_EDIT3,buffer);
/*//////////////////////Copying file to another folder//////////////////////////*/
fileObj.Open("c:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);
///////////////////////////////////////////////////
filewrite.Open(str,CFile::modeCreate|CFile::modeWrite);
strLine.Empty();
while(filewrite.ReadString(strLine))
{
filewrite.WriteString(strLine);
fname += strLine + "\r\n";
}
filewrite.Close();
MessageBox(fname);
I am understand where i am wrong .
The above code work correctly up to
CString strLine = "";
CString buffer = "";
CStdioFile fileObj,filewrite;
CString fname;
fileObj.Open(str, CFile::modeRead | CFile::shareDenyWrite);
fname = fileObj.GetFileName();
while(fileObj.ReadString(strLine))
{
fileObj.ReadString(strLine);
buffer += strLine + "\r\n";
}
fileObj.Close();
// MessageBox(buffer);
SetDlgItemText(IDC_EDIT3,buffer);
/*//////////////////////Copying file to another folder//////////////////////////*/
fileObj.Open("c:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);
and i can create an 0 byte .txt file using this .But when i try to copy content on buffer to file . I am become fail I think this code of line is wrong .
filewrite.Open(str,CFile::modeCreate|CFile::modeWrite);
strLine.Empty();
while(filewrite.ReadString(strLine))
{
filewrite.WriteString(strLine);
fname += strLine + "\r\n";
}
filewrite.Close();
MessageBox(fname);
if any one in the world tell me how can we solve this problem.
Regard's
Kaushik
|
|
|
|
|
You open file on the write mode but in this loop you want to read of that?
filewrite.Open(str,CFile::modeCreate|CFile::modeWrite);
strLine.Empty();
while(filewrite.ReadString(strLine))
From the MSDN
CFile::modeRead Opens the file for reading only.
CFile::modeReadWrite Opens the file for reading and writing.
CFile::modeWrite Opens the file for writing only.
|
|
|
|