|
the problem is that
pos is set to -1 if no more separators can be found.
the solution u proposed works for that simple loop but in the following code it after displaying the entire row(all the tokens) the application hangs. can you please figure out why that is ?
while(pos != NULL)//while thr is data present
{
//MessageBox(m_LineList.GetNext( pos ));
str = m_LineList.GetNext( pos );
while( str != '\0' )//while not end of string
{
for(int i=1;i
|
|
|
|
|
str will never be modified, you have an endless loop.
the atoi line is converting str, not temp.
atoi is converting string to intenger, not float
you aren't checking strpos.
The code doesn't make much sense since the outer loop implies you have multiple matrices, which you clearly don't. Are you tring to read a row at a time, or all the rows as one string? If the latter, you need to change the scope of your loops. I'll leave that as an excercise for you.
while(pos != NULL)<br />
{<br />
CString str = m_LineList.GetNext(pos);<br />
int strpos = 0;<br />
<br />
for(int i = 1; i < 3 && strpos >= 0; i++)<br />
{<br />
for (int j = 1; j < 3 && strpos >= 0; j++)<br />
{<br />
CString temp = str.Tokenize( ", " , strpos );<br />
if (strpos >= 0)<br />
{<br />
simmatrix[i][j]= temp.IsEmpty() ? 0.0f : (float) atof(temp);<br />
MessageBox(temp);<br />
}<br />
}<br />
}<br />
}
If you put this in a function, you could simplify the strpos tests.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
thanks, got the stuff workin
|
|
|
|
|
I was wondering if I can modify the colors of the scrollbars of some text boxes...something similar to what CSS does in HTML. Because this would make my application more interesting.
in css the code would be
scrollbar-face-color:005585;<br />
scrollbar-highlight-color:005585;<br />
scrollbar-3dlight-color:005585;<br />
scrollbar-shadow-color:005585;<br />
scrollbar-darkshadow-color:FFFFFF;<br />
scrollbar-arrow-color:FFFFFF;<br />
scrollbar-track-color:FFFFFF;
This code modifies the color of the scrollbars of internet explorer, but also of the textareas.
|
|
|
|
|
Ummm, the user sets his colors, and probably doesn't want applications mucking around with them. Bad idea.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello,
I am using a 3rd party SDK to display inventory of a machine; anyway after using the following code I close my application in debug mode and it throws an ASSERT error (listed below). This looks to me like the object either isn't being destroyed properly or the refrence count is incorrect for what ever reason...
Any ideas?
<code>
IDatabasePtr ptr = NULL;
IInventoryPtr inventory = NULL;
int result = 0;
CWaitCursor wait;
try
{
ptr.CreateInstance(__uuidof(Database), NULL, CLSCTX_INPROC_SERVER);
result = ptr->SetConnectionString(_bstr_t(strConnectionString));
if (result == 0)
AfxMessageBox("Database connect failed.");
else
{
try
{
inventory.CreateInstance(__uuidof(Inventory), NULL, CLSCTX_INPROC_SERVER);
inventory->ShowInventoryTree(lComputerIDN);
}
catch (_com_error&)
{
AfxMessageBox("COM Error: Failed");
}
}
}
catch(_com_error&)
{
AfxMessageBox("COM Error: Failed");
}</code>
Here's the error in debug.
<code>CCmdTarget::~CCmdTarget()
{
#ifndef _AFX_NO_OLE_SUPPORT
if (m_xDispatch.m_vtbl != 0)
((COleDispatchImpl*)&m_xDispatch)->Disconnect();
ASSERT(m_dwRef <= 1);
Whoever said nothing's impossible never tried slamming a revolving door!
-- modified at 11:06 Tuesday 21st February, 2006
|
|
|
|
|
Hi all,
While working with print templates I got into a situation where my JavaScript loaded ActiveX control was not filling my m_spClientSite with a value other than NULL.
After wrestling with it for a while I decided to take a back door. It was necessary for me to access the COM interfaces in my instance of IE so I went to the Running Object Table. I enumerated its contents and was relaxed when I saw 3 IE entries as that was the number of IE windows I had open. Each one had been opened from the other. My problem is that all the IE objects in the ROT have the values of the first IE window opened (unfortunately not the one I wanted).
So my question is: is there a way of access the other IE COM interfaces?
Or even more helpful: what's the procedure when you control hasn't got a useful value in its m_spClientSite.
Thanks loads for any help
Tom
|
|
|
|
|
As I understand it you want to access IE interfaces from an ActiveX control hosted by it but IOleObject::SetClientSite hasn't been called on your control yet. This is a situation that should never happen, something is going wrong - perhaps your code is trying to access IE's interfaces before the control is hosted properly. My advise would be to try to find the source of the problem and not "hack around" it - You'll just make more trouble for yourself.
Steve
|
|
|
|
|
Thanks Steve.
That which should never happen seem to be a common occurance using print templates though.
Tom
|
|
|
|
|
i not want use
void a()
{
}
void b()
{
}
a_funlen = b - a
|
|
|
|
|
What is your question?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
a function compile and link, in exe's length
int fun()
{
__asm mov eax, 1
__asm ret 0
}
mov eax, 1 == b8 01 00 00 00
ret 0 == c3
so the fun length is 6
|
|
|
|
|
The best way is to have the compiler produce assembly code. Go to project properties | C/C++ | Output Files | Assemler Output. Select "Assembly, Machine-Source and Code." The output will be ".cod" files in your object directory.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
How can I tell MessageBox() to switch to next row?
I tried "\n" and it seems not working.
|
|
|
|
|
Sometime you have to use \r\n
(or \n\r... I don't remember)
Bye
Have a nice code day
|
|
|
|
|
what about in an editbox? how can I tell it to switch the line?
|
|
|
|
|
well, if you found a solution on the messagebox, then use the same solution there.
I suppose that is needed \r\n .
Have you already tryed, and it doesn't work?
Have a nice code day
|
|
|
|
|
I will try it after work, no C++ in my office.
Thanks
|
|
|
|
|
Make sure you have multiline selected for the edit box too...
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I just tried, it works like a charm, big help!
|
|
|
|
|
\n is normally only for consoles in win32.
The win32 user interface is working with \r\n.
Don't try it, just do it!
|
|
|
|
|
Following should work.
MessageBox("First line\nSecond line");
We Believe in Excellence
|
|
|
|
|
Aqueel wrote: MessageBox("First line\nSecond line");
some time not
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have a project coded in Visual Studio 6, now I just installed Studio 2005 and when I compile it, it gives me the following error, although I did not modify the source code at all.
Error 2 fatal error LNK1181: cannot open input file '.\Debug\APPMODUL.obj'
I also get a warning:
Warning 1 warning LNK4076: invalid incremental status file '.\Debug/pmt.ilk'; linking nonincrementaly
and I don't know why this appears either. Maybe someone can help me pls?
|
|
|
|
|
When you open your project in Studio 2005, just delete 'debug' folder from project folder. and then rebuild your project and solution.
-Malli...!
|
|
|
|