|
skinnyreptile wrote:
TRACE (strText);
strText.ReleaseBuffer(nLineLength);
Try switching these two statements.
|
|
|
|
|
Even without trace statment, it's still not working.
|
|
|
|
|
Read the documentation carefully. Note the requirement that the first word of the buffer must specify the maximum number of bytes that can be copied into the buffer. You need something like:
int i, nLineLength, nLineCount;
char szBuffer[64];
nLineCount = m_edit.GetLineCount();
for (i=0;i < nLineCount ;i++)
{
nLineLength = m_edit.LineLength(i);
m_edit.GetLine(i, szBuffer, nLineLength);
szBuffer[nLineLength] = '\0';
TRACE("%s\n", szBuffer);
}
or
int i, nLineLength, nLineCount;
char szBuffer[64];
nLineCount = m_edit.GetLineCount();
for (i=0;i < nLineCount ;i++)
{
nLineLength = m_edit.LineLength(i);
*((int *) szBuffer) = nLineLength;
m_edit.GetLine(i, szBuffer);
szBuffer[nLineLength] = '\0';
TRACE("%s\n", szBuffer);
}
|
|
|
|
|
Where does it crash? On what line?
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
On line 0. If the for loop is start at line 1, it won't crash.
|
|
|
|
|
I haven't tried, but...
nLineCount = m_redit.GetLineCount();
for (i=0; i < nLineCount - 1; i++)
{
nLineLength = m_redit.LineLength(i);
m_redit.GetLine(i, strText.GetBuffer(nLineLength));
TRACE (strText);
strText.ReleaseBuffer(nLineLength);
}
Do this works?
|
|
|
|
|
I tried the following code with display line 0 only when nLineCount > 1. THe code still crash.
if (nLineCount > 1)
{
nLineLength = m_redit.LineLength(0);
m_redit.GetLine(0, strText.GetBuffer(nLineLength));
TRACE (strText);
strText.ReleaseBuffer(nLineLength);
}
|
|
|
|
|
The function LineLength will return the ONLY the number of characters for the given line not including the carriage-return character. According MSDN the function LineLength actually calls the message EM_LINELENGTH and in the MSDN this message states that It does not include the carriage-return character at the end of the line. Also you should account for the NULL character at the end of the string when assigning the length of the buffer.
This code works for me:
<code>
int i, nLineLength, nLineCount;
CString strText;
nLineCount = m_redit.GetLineCount();
for (i=0;i < nLineCount ;i++)
{
nLineLength = m_redit.LineLength(i);
int nActualCharactersReturned = m_redit.GetLine(i, strText.GetBuffer(nLineLength + 2));
strText.ReleaseBuffer(nActualCharactersReturned);
TRACE (strText);
}
</code>
Kelly Herald
Software Developer
MPC
|
|
|
|
|
Thank you for all the help, guys!
|
|
|
|
|
How do you "auto-scale" data points on a graph?
the data will be received at a constant frequency.
I will be receiving data from a CAN/bluetooth gateway on a vehicle.
How do I go about graphing and receiving those data points and putting them on both a line and bar graph?
Thanks.
|
|
|
|
|
This is a very generic question, but I'll give it a try:
1. Separate the data from the viewing of the same data...
2. use dynamic memory assignment if you don't know the amount of data that you'll need.
3. think about how many history do you need to maintain.
4. create a control derived from a CStatic called CGraph.
5. Override the OnPaint function of that control in order to draw the axis, the captions and the labels.
6. Draw each point depending on a scale factor.
7. if the graph needs to be scrolled, think about a scrolling bar... (think about drawing the part needed ni order to avoid to collapse too much the CPU)
Hope this helps...
|
|
|
|
|
I think you need to enable the "toolwindow" style (i.e. its equivalent in C#).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi !
I have a very basic question about C++ :
I want to allocate on the heap a two-dimensionnal array. I tried to do this :
int* pArray=new int[x][y];
but of course it didn't work, so I did that :
int* pArray=new int[x*y];
and each time I need to acces my array, I calculate the x/y position. It works, but still, I'm curious : is it possible to allocate memory in such a way that I can then use the usual notation for a multidimensionnal array : Array[x][y]=z.
Thank you for your help !
Jerome
|
|
|
|
|
int **pArray = new int*[x];
for(int i=0; i<x; i++)
pArray[x] = new int[y]; This will let you use pArray[x][y] = z . To deallocate this array, do this:
for(int i=0; i<x; i++)
delete [] pArray[x];
delete [] pArray; Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Great ! Thanks Ryan !
Jerome
|
|
|
|
|
You're welcome
BTW. That was one heck of a speedy reply
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi everyone!
I have to get the text from a ms word document (.doc) and save the text to a text file (.txt).
Have any of you guys done this? Or can you give me a hint where to start?
majo
|
|
|
|
|
Here's one way using Word Automation:
CString strFileName;
_Application app;
Documents docs;
_Document doc;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtFalse((short) FALSE),
vtTrue((short) TRUE),
vtDoc((short) 0),
vtText((short) 2),
vtRtf((short) 6),
vtHtml((short) 8);
if (app.CreateDispatch("Word.Application") == TRUE)
{
docs = app.GetDocuments();
m_ebDocName.GetWindowText(strFileName);
doc = docs.Open(COleVariant(strFileName), vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
strFileName.Replace(".doc", ".txt");
doc.SaveAs(COleVariant(strFileName),
vtText,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional);
docs.Close(vtFalse, vtOptional, vtOptional);
app.Quit(vtOptional, vtOptional, vtOptional);
}
|
|
|
|
|
Thanks a lot!
I will try this...
majo
|
|
|
|
|
Here is a static PINT varible: temp.
I want to store the value "12" to *temp, and my program coded like below
static PINT temp;
* temp=12;
I can succeed in compiling it, but there is an error when running it:
The instruction at "0x00406a3a" referenced memory at"0x00000000". The memory could not be "written".
What is the problem? How can solve it?
Thank you in advance!
|
|
|
|
|
Try:
static PINT temp;<br />
temp = new int;<br />
*temp = 12;
|
|
|
|
|
Obviously temp doesn't point to anything. You need to point it to an integer before attempting to dereference it.
onwards and upwards...
|
|
|
|
|
I see, after seeing your explanation
Can I ask another question?
First I completet the below sentences:
PINT temp;
temp=new int;
Then I have a PVOID varible temp2,which is to be applied like
temp=(PINT)temp2;
Is it right after twice times of putting the pointer?
Thank you!
|
|
|
|
|
Hi all,
i have a SYSTEMTIME that represents the hour '03:02:25 PM' i want to
represent this time as STRING!
i am not using MFC, i use ATL/Win32API
can any1 help?
thanks in advanced,
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
strftime will probably do what you ask.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|