|
cheers Joaquín for replying. Just so I've understood correctly all I need to do is
list1 = list2
and then list1 will have copies of all of the elements in list2 and then any changes I do in either list will not be reflected in the other list? If so this is a lot easier than the method I implemented!!! (I went through the list in a while loop and then copied each element, not very efficient)
thanks,
Andy
|
|
|
|
|
Just so I've understood correctly all I need to do is
list1 = list2
and then list1 will have copies of all of the elements in list2 and then any changes I do in either list will not be reflected in the other list?
Correct.
If so this is a lot easier than the method I implemented!!! (I went through the list in a while loop and then copied each element, not very efficient)
I don't want to dissapoint you, but basically the internals of list1 = list2 do the same kind of loop that you were using, so don't expect any performance improvement
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It works fine when I compile under VC 6.0 but when I convert the project to a VC .NET "solution", the following line will return a NULL pointer:
Code:
CWnd* pWnd = GetParent()->GetDlgItem(edt1);
Any helps? Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
Break the question into steps.
Does GetParent () actually return the window
you are expecting?
Is edt1 still valid? Did you assign a number to
it that no longer matches the ID of the control you are
trying to access?
Is that control actually being created? You can check this
using spy++ etc to see if it (a) exists, and (b) has the
right ID.
Etc.
Iain.
|
|
|
|
|
Hi All,
I am new in vc++.
I would like to send data from one dialog box to one property page.
My question is:-
A property sheet contains two-page (Cpage1 and Cpage 2).
Page1 contains one command button(btnClick) and one text box(nText1).When I press btnClcik , it calls a dialog box(Cdlg) and dialog box contains one text box(nText2) and on Command Button(btnOK).
NOW, I would like to enter integer type value in the text box(ntext2) and then press the btnOK of dialog box.
Then entered value should be shown in the textbox(nText1) of Page1(Cpage).
How to do this.
Regards
Rajesh,
rajesh
|
|
|
|
|
The Cdlg class should have an int member variable. After the call to DoModal() , simply access this member variable. Something like:
class Cdlg : public CDialog
{
public:
int var;
};
page1:onbtnclick()
{
Cdlg dlg;
dlg.DoModal();
int var = dlg.var;
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi !
I'm facing a problem and I'm sure you'll be able to help me !
In my app, I have a class which represents a path (meaning : a path you can follow to go from A to B). This class (Path) is made of any number of Segments, which can be straight or curved.
Thus, apart from the class 'Path', I created a base class called 'Segment' and two classes derived from 'Segment' : 'StraightSergment' and 'ArcSegment'.
The 'Path' class contains a list of 'Segment's.
I want to serialize a Path into a string. Thus, I have a method 'toString' which will in turn call, for each segment, their own 'toString' function. As 'Segment' is an abstract class, it will actually call either 'StraightSegment::toString' or 'ArcSegment::toString'. So far so good.
class Path
{
public:
...
string toString();
void fromString(string Source);
...
private:
list_of_segments MyList;
};
class Segment
{
virtual string toString() = 0;
virtual void fromString(string Source) = 0;
};
class StraightSegment : public Segment
{
string toString();
void fromString(string Source);
};
class ArcSegment : public Segment
{
string toString();
void fromString(string Source);
};
I have a problem when I need to materialize a 'Path' from a string : Before calling 'fromString' function from either 'StraightSegment' or 'ArcSegment', I have to decide which kind of segment it is. Where should I do this ? In the 'Segment' base class ? The problem is that 'Segment' would have to know each classes derived from it. Should I do it into another class ? The problem then would be that the 'Path' class would have to know another class than just 'Segment'.
Well, what do you suggest me ? Which solution is the best ? Are there any better solutions ?
Thank you for your help !
Jerome
|
|
|
|
|
You could have something like:
#include "BootStrap.h"
class Segment
{
...
public:
static Segment *FromString (CString s);
...
protected:
virtual BOOL DoesThisStringMatchMe (CString s) = 0;
virtual BOOL ProcessTheStrings (CString s)
DECLARE_ROOT_CLASS(CBaseFilter)
};
So the Path object knows nothing about different segments.
If you read the article Enumerate your leaf classes it gives
a good explanation of how you can go through each descendant
of Segment
Segment *FromString (CString s)
{
int nType, nTypes = GetRegisteredManufactoringPlantCount();
Segment *pGuess = NULL;
for (nType = 0; nType < nTypes; nType++)
{
CBootStrapper<CBaseFilter>* pBoot = GetRegisteredManufactoringPlant(nIdx);
pGuess = pBoot->CreateObject ();
if (pGuess->DoesThisStringMatchMe (s))
break;
delete pGuess;
pGuess = NULL;
}
if (!pGuess)
return NULL;
pGuess->ProcessString (s);
return pGuess;
}
This hasn't been compiled, obviously, and you'll need to read Jaded Hobos article for
details, but I've used this method in the past. You'll see my comment on his article!
Good luck,
Iain.
|
|
|
|
|
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.
|
|
|
|