|
Hi!
I'm having trouble with VC++ 7. My program compiles on VC++ 6 but after i installed VC++ 7 it crashes when I try to: Find("=") in a CString. It says something about Debug Assertion Failed, File: cstringt.h at line 1661, Expression: nCount>=0.
The compiler is also warning me about: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated
I have included iostream.h and according to MSDN i should remove the .h to use the new iostream but when I do that the compiler can't find it.
I hope someone can help me!
Regards,
Tobias
|
|
|
|
|
hello. i am not sure what "=" you are trying to do but -
if you are using an if statement you have to use "=="
if you are trying to compare cstring also has a compare and getat functions.
hope this helps.
|
|
|
|
|
Please post some relevant code snippets
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
Thanks for trying to help but it didn't work... I'm trying to find the position in a CString where a "="-sign is located. Here is the code:
//The next line causes program crash!!!
valuename = readinfo.Left(readinfo.Find("="));
value = readinfo.Right(readinfo.GetLength()-valuename.GetLength()-1);
valuename, value and readinfo are CStrings. This works in VC++ 6 but not in VC++ 7 where it causes the problems I mentioned erlier.
Regards,
Tobias
|
|
|
|
|
Nevermind... I need to add some more errorchecking to my program... I used this code to read a string from a file and find the "="-sign. But i noticed that when the loop found a string where there where no "="-sign the program crashed. This is very strange because it doesn't crash when compiled on VC++ 6...
Well, thanks anyway!
Regards,
Tobias
|
|
|
|
|
Has anyone else noticed some output from TRACE seems to occasionally be dropped before it appears in the debug window?
Am I paranoid? Am I covering my own programming inadequacies by blaming M$?
TIA,
Pete
|
|
|
|
|
donno about that, but i've been bitten already by the size limit of presearved text in the output window; it just won't hold generated C source for a 4MB transparency LUT
Black rooms are calling; To men in leather coats. White labs are cooking up the silver ghost. Smashing Pumpkins, Glass and the Ghost Children
|
|
|
|
|
The input buffer size for the TRACE output window is a limited size (after all its a pipe between the processes). If your debug output TRACE volume is high and the thread reading the buffer in the VC editor does not run often enough, you can lose TRACE information from the window.
So your not paranoid, if this is what is happening to you.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
That sounds like what is happening. I'm writing LOADS of memory allocation info to the debug output to try and track down mem leaks. I guess the only solution would be to put a little pause in my AllocHook() after every TRACE().
Thanks Roger.
|
|
|
|
|
No, you are probably getting bitten by a Visual Studio bug. Visual Studio filters the output of the OutPutDebugString() function, which the TRACE macro ultimately calls, before showing it in the output window in order to remove the application name (which otherwise gets added). However, the filtering is not too smart (at least with version 6.0), and it messes up the display of TRACE messages that includes both an open parenthesis "(" and a colon ":" in that order.
When I add the following lines to my code
TRACE (_T("Text before colon: Text after colon\n"));
TRACE (_T("Text with parenthesis() before colon: Text after colon\n"));
TRACE (_T("Text with open parenthesis( before colon: Text after colon\n"));
TRACE (_T("Text with close parenthesis) before colon: Text after colon\n"));
TRACE (_T("Text with (text inside parenthesis) before colon: Text after colon\n"));
the Visual Studio output window displays
Text before colon: Text after colon
Text with parenthesis() before colon
Text with open parenthesis( before colon
Text with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Intrestingly, if I select this text text in the output window and paste it into notepad, I get
Text before colon: Text after colon
Text with parenthesis() before colonText with open parenthesis( before colonText with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Stephen C. Steel
Kerr Vayne Systems Ltd.
|
|
|
|
|
No, you aren't being paranoid - there is a bug in Visual Studio version 6.0. The TRACE macro ultimately uses OutputDebugString(), and along the way the application name gets prepended to the output. Visual studio has a filter that attempts to strip the application name before showing the text in the output window, but it is buggy.
If I add the following code to my application
TRACE (_T("Text before colon: Text after colon\n"));
TRACE (_T("Text with parenthesis() before colon: Text after colon\n"));
TRACE (_T("Text with open parenthesis( before colon: Text after colon\n"));
TRACE (_T("Text with close parenthesis) before colon: Text after colon\n"));
TRACE (_T("Text with (text inside parenthesis) before colon: Text after colon\n"));
then the Visual Studio output window displays
Text before colon: Text after colon
Text with parenthesis() before colon
Text with open parenthesis( before colon
Text with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Interestingly, if I select the text in the output window and paste it to notepad, I get
Text before colon: Text after colon
Text with parenthesis() before colonText with open parenthesis( before colonText with close parenthesis) before colon: Text after colon
Text with (text inside parenthesis) before colon
Stephen C. Steel
Kerr Vayne Systems Ltd.
|
|
|
|
|
I don't think this is the issue in my case, as I'm not using paretheses.
But thanks anyway, it's always useful to know stuff like that!
Pete
|
|
|
|
|
Can sombody tell me why this won't Beep? Cw is derived from CWinThread and Run() is supposed to be executed so what gives?
//////////////////////////////////
class Cw : public CWinThread
{
public:
int Run();
Cw();
virtual ~Cw();
};
Cw::Cw(){}
Cw::~Cw(){}
int Cw::Run()
{
Beep(1000,500);
return 0;
}
///////////////////////
elsewhere in the program:
Cw* w = new Cw();
w->CreateThread();
|
|
|
|
|
You must override CWinThread::InitInstance . This method by default returns FALSE thus preventing the call to CWinThread::Run .
As a sidenote, I assume you're doing this as a simple test and do not plan to base any actual code on this way of overriding CWinThread::Run : this method has to provide some sort of message pump (which is what does by default). To run separate tasks, it is better to use worker threads.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank Joaquin, I'll give it a try. Actually, I need a thread with a message pump because i need to send it commands to do things. I can't figure out how to get message queue on a workerthread so I'm using a UI thread. I plan to put my own GetMessage() call into Run(). I will not be using this thread to service an UI elemets though. The only other thing that I know Run() does is call OnIdle(). Can I safly not call OnIdle() - I don't plan to overide it?
|
|
|
|
|
what?
I think you answered the wrong guy.
Bye
|
|
|
|
|
Joaquín,
I tried what you said and overriding CWinThread::InitInstance works. Thanks! Now I have another question. If I declare several instances of this class they all seem to share the same variables. Maybe I am not saying that right so I will show you the code:
class Cw : public CWinThread
{
public:
DWORD delay;
DWORD freq;
BOOL InitInstance();
int Run();
Cw();
virtual ~Cw();
};
Cw::Cw()
{ delay = 0;
freq=1000;
}
Cw::~Cw(){}
int Cw::Run()
{ Sleep(delay);
Beep(freq,500);
return 0;
}
BOOL Cw::InitInstance(){Return TRUE;}
////////////////////////
Then i have four of the instances and i think i should hear 4 tones one after the other but i don't. Are they all sharing the same delay and freq?
w = new Cw();
w->freq=5000;
w->CreateThread();
x = new Cw();
x->delay=500;
x->freq=2000;
x->CreateThread();
y = new Cw();
y->delay=1000;
y->freq=1000;
y->CreateThread();
z = new Cw();
z->delay=1500;
z->freq=500;
z->CreateThread();
///////////////////////////////////////////////
The above code should sound like this:
w = new Cw();
w->freq=5000;
w->CreateThread();
Sleep(500);
x = new Cw();
x->freq=2000;
x->CreateThread();
Sleep(500);
y = new Cw();
y->freq=1000;
y->CreateThread();
Sleep(500);
z = new Cw();
z->freq=500;
z->CreateThread();
|
|
|
|
|
Joaquín,
Please ignore my message above. It was a bad test. If I change the values it will work better. Thanks again for your help.
(But I still wonder about my OnIdle question: The only other thing that I know Run() does is call OnIdle(). Can I safly not call OnIdle() - I don't plan to overide it? )
Here is how I getting my test to work (I increased the delay):
//Sleep(500);
x = new Cw();
x->delay=3000;
x->freq=2000;
x->CreateThread();
//Sleep(500);
y = new Cw();
y->delay=6000;
y->freq=1000;
y->CreateThread();
//Sleep(500);
z = new Cw();
z->delay=9000;
z->freq=500;
z->CreateThread();
|
|
|
|
|
I'm not the guy you want to chat with.
please pay attention to my question ...about ocx, I had nothing to do with your subject.
Bye.
|
|
|
|
|
I've been trying to return data from an ODBC database and display it in a tabbed dialog (property page). The code compiles just fine, but I get a runtime error during execution. Specifically,
ERROR MESSAGE:
<br />
TRACE0("ASSERT_VALID fails with NULL pointer.\n");<br />
if (AfxAssertFailedLine(lpszFileName, nLine))<br />
AfxDebugBreak();<br />
return;
I know the CRecordset class I created works fine (I've used it before in a single dialog page). The problem seems to occur during data exchange in the CPropertypage class. Here's the code that is suspect:
CPROPERTYPAGE SOURCE:
<br />
CPersonalData::CPersonalData() : CPropertyPage(CPersonalData::IDD)<br />
{<br />
m_pSet = NULL;<br />
}<br />
<br />
void CPersonalData::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CPropertyPage::DoDataExchange(pDX);<br />
DDX_FieldText(pDX, IDC_TITLE, m_pSet->m_TITLE, m_pSet);<br />
}<br />
<br />
CRecordset* CPersonalData::OnGetRecordset()<br />
{<br />
return m_pSet;<br />
}<br />
In addition, m_pSet is defined in the header file for the CPropertypage as follows:
CPROPERTYPAGE HEADER:
<br />
class CPhysiciansListSet;<br />
<br />
class CPersonalData : public CPropertyPage<br />
{<br />
DECLARE_DYNCREATE(CPersonalData)<br />
<br />
public:<br />
CPersonalData();<br />
~CPersonalData();<br />
<br />
virtual BOOL PreTranslateMessage (MSG* pMsg);<br />
<br />
enum { IDD = IDD_PERSONALDATA };<br />
CPhysiciansListSet* m_pSet;<br />
};<br />
Any suggestions would be GREATLY appreciated. I've been screwing around with this app for a week now on this one problem and I'm about to go crazy.
Thanks in advance.
|
|
|
|
|
I have a CHtmlView loaded with some HTML that i generate on the fly (loaded with IPersistStreamInit). it works fine - everything displays properly - yay.
the problem is when i try to do links within the document: links like <a href="#somelink">..</a> to <a name="somelink"> .
if i hit one of these, the browser takes me to a page that says "blank#somelink", not to the "somelink" on the original page.
since i'm loading this HTML stream dynamically, i can't use the res:// "protocol" and, "file://" doesn't work...
any ideas?
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
I nned to be able to get the main frame window from a worker thread with no GUI component. AfxGetMainWnd() get the main window for the current thread - the worker thread and so returns null.
Any ideas on how to get the MainFrame from the primary thread?
Thanks,
Giles
|
|
|
|
|
Pass HWND of MainFrame through thread parameters and then create CWnd object by CWnd::FromHandle(HWND) function in workeer thread
|
|
|
|
|
I thought of passing the handle, but was not sure if it would be okay from another thread. Despite that, I am updainting another window, but need to be able to get at the promary thread so I can attach to the Frane Window, and them the Status Bar.
Thanks,
Giles
|
|
|
|
|
Try AfxGetApp( )->m_pMainWnd
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|