|
Hi
Sorry for not getting back to you, but I did use your solution and yes you are right it did work. Please excuse me but I am very new to C++!!
However, I have hit another problem whilst I can call my C# COM object it throws an error it says "the file or assembly xxxxxx cannot be loaded or one of its dependencies. The file sepecified can be found". In my C# COM object I am referencing another class, which itself references another class. When I compiled the C# COM Object, the bin file has the other classes as dlls are present.
What am I doing wrong here? I have to be careful here because the referenced referenced class is used elsewhere in the other project. So, I am not sure whether adding a strong key and registering it would break the program elsewhere.
Can you help?
Thanks
|
|
|
|
|
I'm not sure what the issue is here, but it sounds like you have some files missing, or not installed in the correct directories for the Windows loader to find them when they are called. You may also like to consider trying to simplify the structure of your application if at all possible.
The best things in life are not things.
|
|
|
|
|
I'm opening a Modal Dialog inside a Modal Dialog. While destroying the second Dialog, application crashes at the following assert condition:
ASSERT(::IsWindow(m_hWnd))
in the file afxwin2.inl.
How to destroy a Modal Dialog which is popped up inside another modal Dialog?
|
|
|
|
|
pix_programmer wrote: How to destroy a Modal Dialog which is popped up inside another modal Dialog?
It typically "destroys" itself by the user clicking the OK or Cancel button, or pressing the Esc key.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
This ASSERT is telling you the window doesn't exist anymore, like it was already suggested, modal dialogs don't typically get manually destroyed (although they can be).
|
|
|
|
|
Call EndDialog() method to have the second dialog destroyed properly.
onwards and upwards...
|
|
|
|
|
is there a way I can make this code say "I'm Base!"?
class CBase
{
public:
virtual void testApp()
{
printf("\nI'm base");
}
};
class CDerived : public CBase
{
public:
void testApp()
{
printf("\nI'm derived");
}
};
int _tmain(int argc, _TCHAR* argv[])
{
CBase* cp = new CDerived();
cp->testApp();
return 0;
}
|
|
|
|
|
Smith# wrote: is there a way I can make this code say "I'm Base!"?
You mean other than:
CBase* cp = new CBase(); There's also:
void CDerived::testApp()
{
CBase::testApp();
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
You should have probably posted this as an answer instead of "general"
|
|
|
|
|
David is correct, that's the way to do it, if you don't like his options, then you probably shouldn't have made it virtual, if its not virtual, then the call gets evaluated at runtime according to the pointer.
if not virtual...
CBase* cp = new CDerived();
cp->testApp();
((CDerived *)cp)->testApp();
..you just have to know exactly what it is you want.
|
|
|
|
|
So once we have said virtual, it's dead No? to access the base? Not even a hack available to do that? may be through manipulating vptrs?
|
|
|
|
|
Its not dead, its just the whole purpose behind the "virtual" keyword... that the base method can be overriden... stefan's solution probably works as well, but again, you're overriding a behavior that is designed.
|
|
|
|
|
...and by the way, the derived class doesn't HAVE to override a virtual method in the base, its optional, you only HAVE to override pure virtuals.
|
|
|
|
|
See my answer below: you can still call methods from the base class(es) even if the pointer you use to call it points to a class that has overridden that implementation:
CBase* pbase = new CBase;
CDerived* pDerived = new CDerived;
pbase->testApp();
pDerived->testApp();
pDerived->CBase::testApp();
You can invoke methods of base classes by adding the name of that class, separated by '::' to the name of the function you want to call. In doing so you ignore the virtual function table for that call only. You can freely mix calls of that type with normal calls that use the virtual functions, as you can see in the example above.
|
|
|
|
|
This should do it. Although I'm not at all sure why you'd want that.
int _tmain(int argc, _TCHAR* argv[])
{
CBase* cp = new CDerived();
cp->CBase::testApp();
return 0;
}
|
|
|
|
|
because the intellisense hides this from me.
|
|
|
|
|
this isn't what you'd call normal use...
|
|
|
|
|
It is ok using debug, and run new byte for 59 time ok for release, but the 60th, it faluts showing not enought memory, but I print the value that will be new is 2544
Like this:
void MallocSize(int iMalSize)
{
....
pData = new BYTE[iMalSize];
....
}
void AddFeature()
{
....
for(int i=0; i<3000; i++)
MallocSize(Sizet);
....
}
I try many time but each stop at the 60th, and the value is 2544 Byte
Runtime Lib:Multi-threaded DLL (/MD)
Used memory is 1.02G
and the program is 200MB
Total system memory is 2GB.
Does anyone know what is the problem?
|
|
|
|
|
You are allocating SizeT bytes of memory 3000 times, correct? So what is the value of Sizet ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
good question...
|
|
|
|
|
The problem is that while the debug version stores additional information for each allocation, the release version does not. So if you did not free all the memory that you allocated, then in the debug version, the (invisible) debug code will be able to free the memory that you forgot to clean up yourself. But the release version, lacking that additional information, is unable to do that by itself. This leaves you with memory leaks. Obviously these leaks are big enough that after 59 runs you've used up all your memory.
Fix: properly free the memory that you allocate when you don't need it any more!
|
|
|
|
|
Hi all,
i m using a Edit box control with multiple line option.
and calculate the text length of edit box,here when press enter in edit box for new line the charcter length of enter key is 2.
please tell me how can i chek this and consider it as 1 char instead of 2.
thanks in advance.
|
|
|
|
|
Windows uses \r\n as a combination to get a carriage return and a line feed. You have to build your software to take that into account.
Edit: Why do you want to consider it as one char?
|
|
|
|
|
Please tell me how can i do this?
|
|
|
|
|
If you let us know exactly what you want to achieve I'm sure I or someone else could help you. Why is it important to treat it as one single char?
|
|
|
|