|
Dear Friends,
Sometime my application gives an error and an abnormal error dialog box generates and then my application shuts down. Some time it may happen that my application hung-up.
Although presently I don't any such kind of error but I would like to track such kind of errors and wish to do some preventive measures accordingly in abnormal cases. Will you please tell me how to track error messages in MFC.
Also please write to me whether I can make my program to generate a particular error to check whether my preventive measures are working properly.
I am new to VC++ and at present I am unable to find any solution for it. Although I find a function say GetLastError(), but how to use it, to a particular error, I am not getting........I think WM_ENABLE message may also help me in case of hung-up but how to add this message to class wizard.
Thus please help me to find the solution...
Thanking You in advance.
Billar
|
|
|
|
|
A quick question.
Does anyone know if a given stl iterator[^], say for a std::vector, remains valid throughout the lifetime of that vector?
I'm having some problem accessing an object stored in a vector via an iterator. The iterator was initialised at at some point in my program, but when I come to access the object through the iterator at a later stage, it fails
To clarify, if I set an iterator like:
vector<obj*>::iterator ite = myvec.begin() + 4;
Will ite , my iterator, remain valid as long as the vector variable is not modified?
I Dream of Absolute Zero
|
|
|
|
|
I think I've sorted my iterator problem. It came down to the smart pointers being to darn smart for its own good and deallocating my objects.
I'd still like an answer to the iterator validity question though!
I Dream of Absolute Zero
|
|
|
|
|
My understanding is that the iterator will be valid as long as the container is unchanged. Once
you change it, all bets are off.
They are equivalent to the old K&R Node * pointing to nodes in a linked list.
But any non-const container member function could mess things up. And it wouldn't be thread
safe, as you may mess things up elsewhere... And so on.
I only ever use iterators locally, but there is no reason your idea shouldn't work if you
are careful.
Iain.
|
|
|
|
|
To clarify, if I set an iterator like:
vector::iterator ite = myvec.begin() + 4;
Will ite, my iterator, remain valid as long as the vector variable is not modified?
Yes, provided you don't insert or delete anything from myvec from the moment you set the value of ite .
With std::list s, on the other hand, iterators remain valid no matter if you insert or delete elements (except if you delete the element the iterator is pointing to, of course.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for confirming that for me.
I Dream of Absolute Zero
|
|
|
|
|
Hello All,
I am getting assertion failed message while runing my application in Win32 debugIU mode:
error message is like this:
Assertion failed
Program: .....\x.exe
file oledisp2.cpp
line: 321
As we know it is vc++ src file. And my application is running properly in Win32 cmrelIU mode. But problem in Win 32 debugIU mode. And that too, same application is running on other PC properly.
What could be the reason? Would you please provide some solution?
Regards,
Jokhan
|
|
|
|
|
Step in through the code and isolate the line shouting Assert.
There is no spoon.
mail
|
|
|
|
|
Have you looked at line 321 of oledisp2.cpp? An unknown type is being used in a call to InvokeHelperV() .
jokhan wrote:
And my application is running properly in Win32 cmrelIU mode. But problem in Win 32 debugIU mode...What could be the reason?
Because the ASSERT() macro will catch program errors only when you are using the debug version of MFC. It will be turned off (and produce no code) when you build your program with the release version of the library.
Don't let the fact that when no errors/messages are produced during the release version of your product that your product is indeed error-free. Whatever condition exists that caused the assertion to fire in the debug version still exists in the release version.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I would like to seek some advice as in general terms how proceed with my current program, written as a MFC Dialog (C++) application in Visual Studio .Net.
I have developed it over the last few months as an application which creates its own internal database – a large array of a user defined structure. I can access this data by two means; by name or index (0 to n).
Now I need to provide an interface to this array (database) so that I can write other applications to use this database along side my program.
So my question is
‘What sort of interface should I provide?
and
How to implement it? i.e. do I need to protect the data during access etc
I have never written any DLLs, just used them, also currently think of using the database item name as the access key and would like the option to write these programs in C or C++, so I question the use of CString as the database names are held in a CStringArray .
Any comments greatly appreciated.
|
|
|
|
|
IMHO a better approach with a long term view will be to make ur internal database external on some Database servers(M$SQL/MySql,Oracle). Sorry for not answering wot you exactly asked.
There is no spoon.
mail
|
|
|
|
|
Hello Friends,
I want to use the cursor control keys (Key up, key down, key left, key right) and the cursor should move according to the appropriate item which is being displayed in the listview. The Item should be get selected with respective to the cursor key.
please help me regarding the above matter.
Thank you in Advance only,
Neelesh J Jain.
|
|
|
|
|
use OnKeyDown or OnKeyUp
You can read up about these functions on MSDN.
hope this helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I am using onKeyUp member function only, but how to navigate in the list box according to the appropriate key.
Thank you,
Neelesh Jain.
|
|
|
|
|
test for VK_UP (VK_DOWN)
then you can set the selectitem (or SetCurSel) property or something of the listbox +1 or -1.
Look up the members for CListBox...
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Neelesh K J Jain wrote:
...in the list box...
In your original post, you indicated this was a listview, yet now you indicate it is a listbox. Which is it?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello all,
needing to allocate a large number of buffers (let's say 20.000 buffers of
sizes between 8 and 200 bytes (I do not know their size at first)), which method would you recommend:
1. malloc (slow from my tests)
2. dlmalloc (Doug Lea's malloc replacement)
3. other
If your solution is a custom memory allocator, I need it to work on Win32
(e.g. Win9x included). I've done tests with dlmalloc and it seems pretty
fast. Perhaps an experience/advice of using it in the real-world would help.
Thanks.
Regards,
George Ionescu.
|
|
|
|
|
http://www.mathtools.net/C_C__/Memory_management/index.html[^]
Short of rolling your own with Virtual*() i was impressed with what i read about Hoard.
If you know the allocation size extents(8-200) and the pattern of allocations you should be able to write an optimized allocator that will outperform most generic implimentations.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Since you are using VC++, the choice should be the new operator.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
How to eliminate this warning?
warning C4652: compiler option 'Generate Browser Info' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header.
pls help
Mithuna
|
|
|
|
|
I suggest you completely clean and rebuild your project. This should eliminate the warning.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
|
Hi,
I am developing a client server application with vc++.
I have the following 3 main classes
* PayrollDlg - This is the main dialog box
* WageDlg - This dialog box is accessible thru PayrollDlg
* AbsSocket - This class manages the networking aspect i.e creating a socket & sending , receiving data.
Now i need to create an object os AbsSocket that can be accessed from both PayrollDlg as well as WageDlg. Where do i declare this object to achieve this. If i declare the AbsSocket object in either PayrollDlg or WageDlg classes it becomes local to that class. What i actually want to know is where is the main() function as if i declare the AbsSocket object in this main it can be accessed anywhere right?
|
|
|
|
|
You can declare it as global in one cpp file and then declare it using extern in another
AbsSocket g_AbsSocket;
extern AbsSocket g_AbsSocket;
or if u want a cleaner way you can do this
class CGlobalVariables
{
static AbsSocket g_AbsSocket;
};
CGlobalVariables::AbsSocket g_AbsSocket;
and include this class in stdafx.h
then u can use it like
CGlobalVariables::g_AbsSocket
whereever u like
as for accessing the main function, in MFC it is buried deep under the classes of MFC u can't(shouldn't) access it
hope it helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
You could always derive PayrollDlg and WageDlg from a common class where AbsSocket is a member variable.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|