|
Neville, thank you!! The links were great -- just the info I was looking for -- and the advice on using autopointers (storing offsets while supplying pointer semantics) was spot on.
This is definitely something I have a production need for, not an academic exercise. The CUJ article is in Apr 2003, unfortunately it apparently is not available on their website (I will email you about this).
Cheers,
Chris
|
|
|
|
|
Here is the example code.
class outer
{
class inner
{
outer* p_outer;
};
};
now in the constructor of inner class i need the pointer of outer.
Any idea on how this could be done?
|
|
|
|
|
outer::outer : inner (this)
{
}
That should work but there are some restrictions. Don't try to do anything serious with p_outer in inner's constructor. The instance of outer hasn't been fully constructed yet.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
It seems to give me pointer to inner, not pointer to outer class.
|
|
|
|
|
No, you are supplying the "this" pointer to inner's constructor from outer's constructor. Thus "this" points to outer.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi!
Following situation:
I've a very huge class with some arrays in it. Every user input I call the following function:
CMyClass GetByValue()
{
return m_Class;
}
Then:
void OnUserInput(...)
{
CMyDoc pDoc = GetDocument();
CMyClass cClass = pDoc->GetByValue();
//Some operations with cClass...
[...]
}
After a period of time the app slows down (because m_Class gets very big -> arrays inside it are filled)...
Is there a possibility to fast-copy a class? Or to fast-copy CArrays?
I can't use pointers cause' I need a COPY of m_Class -> the original m_Class should not be modified...
Build a system that even a fool can use, and only a fool will use it.
|
|
|
|
|
Assuming that you copy constructors aren't slow, then you have a basic design flaw in your software. You can't expect to make copies of huge amounts of data every time the user does something.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I did not think it would take so long...
...the data is for my Undo/Redo...
Build a system that even a fool can use, and only a fool will use it.
|
|
|
|
|
Yeah, I had a feeling that was the case. I have done the same thing. The only real way to do undo/redo is to save delta's instead of complete copies of the data. It is more work, but well worth the effort.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I think you're right,I will have to save deltas instead of the whole data. I summed everything my Und/Redo class needs, it's about 200kb, every click! So RAM gets filled with 200kb every time I get an user input, that's not good
Build a system that even a fool can use, and only a fool will use it.
|
|
|
|
|
Jakob Bysewski wrote:
I can't use pointers cause' I need a COPY of m_Class -> the original m_Class should not be modified...
So, return a const reference. Like this:
const CMyClass &GetByValue()
{
return m_Class;
}
In this case, you'll not be able to corrupt your class, because you'll only be able to call const methods.
It's not the fall that kills you: it's the sudden stop - Down by Law, Jim Jamursch (1986)
|
|
|
|
|
When you have a CListCtrl and it is set to Large icons, every item that is added appears next to the last item (if there's room) or at the next line. I am making a class derived from CListCtrl but i want the items to be centerred in the Control, and every item that is added shoulder appear underneath the last one (so there arent any items next to eachother in any way).
Is there a preset flag for this or would i have to write my own code for this? And how would i start if i would? If anyone has some good sites about the ListControl and how to modify it they would be very appreciated
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Can someone help me with this? I need a simple and basic example to implement GL in a MDI app! Thank you!!
|
|
|
|
|
Hi!
I was wondering if you can override the default functionality for OnFileNew and OnFileOpen to have your document's view open in only one child window as it happens in an SDI application.
More clarification:
When we create an MDI application we get a child frame window which gets the view inside it. If we have to say FIle New then I would like to replace the existing view in the same child window with the new one. Yeah an interesting quesion is why am i going into all the troubles of MDI when this is the functionality of an SDI application, but actually I have another document template also within this application. Can somebody help me out with this.
thanks
rahul
|
|
|
|
|
I am sure I have seen articles on this either here or on CodeGuru. Have you had a good look around the Doc/View articles?
It really shouldn't be difficult. You can overide OnFileNew etc. and do whatever you want with docs and views.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hello, my problem:
Need a dialog box to get 2 coordinates (x,y) to draw a rectangle in the viewport!! I have managed to do it but only when I rezise the window!
Probably a stupid question but...
Thankx!!!
|
|
|
|
|
Call Invalidate().
Kuphryn
|
|
|
|
|
Call for View 1) Invalidate() 2) UpdateWindow()
===========================
My home is www.brigsoft.com
|
|
|
|
|
I want to create an aplication which will be checking wheater a porno dialer wants to make a connection.
I use RasEnumConnections for checkin the active connections and investigate its phone number. But it seems that the p dialers are smarter than I am, because the localphonebook is 0
is there anyone who knows how they work and what is the best to catch them.
|
|
|
|
|
sorry not localphonebook but szLocalPhoneNumber is alway 0 but the connector calls 0 700 ......
|
|
|
|
|
I have a block of code that is used by multiple threads and need to provide mutual exclusion .
I am doing the following
1. Declaring class member : CCriticalSection cs ;
2. before I spawn these threads I am Initializing the critical Section as
InitializeCriticalSection((_RTL_CRITICAL_SECTION*)&cs);
3. In the thread i do the following :
EnterCriticalSection((_RTL_CRITICAL_SECTION*)&cs);<br />
*<br />
*<br />
LeaveCriticalSection((_RTL_CRITICAL_SECTION*)&cs);
4. I spawn 10 threads as of now and I am getting memory errors left and right . The code works when the calls to enter and leave critical section are commented !
Please help
|
|
|
|
|
Try this:
class MySynchronizedObject {
public:
static CCriticalSection m_cs;
void synchronizedMethod() {
m_cs.Lock();
something();
m_cs.Unlock();
}
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Use CRITICALSECTION instead of CCriticalsections , other functions (Enter, Leave) are the same. You can even drop the RTL_CRITICAL_SECTION* .
~RaGE();
|
|
|
|
|
CCriticalSection is a MFC-wrapper around the Critical Section from Win32.
You should call cs.Lock() and cs.Unlock() instead of using Enter and LeaveCriticalSection.
To use Enter and Leave... use a CriticalSection instead, and drop your _RTL_CRITICAL_SECTION* cast.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi!
How can i use Delete() from CDaoRecordset class to delete records in an Access DB???
|
|
|
|