|
for(int nIndex=0;nIndex<10;nIndex++)
{
delete [] objSomeC[nIndex].objSomeA;
}
delete [] objSomeC;
If you want to do it at the object's destruction, you might use this variant:
class CMainOne
{
public:
class CSomeA
{
public:
int nXA;
int nYA;
};
class CSomeC
{
public:
~CSomeC()
{
delete [] objSomeA;
}
int nXC;
int nYC;
CSomeA *objSomeA;
};
CMainOne();
~CMainOne()
{
delete [] objSomeC;
}
CSomeC * objSomeC;
};
CMainOne::CMainOne()
{
objSomeC=new CSomeC[10];
for(int nIndex=0;nIndex<10;nIndex++)
{
objSomeC[nIndex].objSomeA=new CSomeA[10];
}
} with the usual checkins i've omitted for brevity.
rechi
|
|
|
|
|
Hi rechi,
thnaks now Code working fine..
regards
anju
|
|
|
|
|
If you are just doing:
delete []objSomec->objSomeA
delete []objSomec
then you are missing out deleting the other 9 'new CSomeA's. That is, you allocate 10 CSomec's, and for each of these, you allocate 10 CSomeA's - you need to delete these 10 as well, the delete[] will correctly delete the 10 CSomeCs, but it wont delete the 10 CSomeA's that are embedded in each CSomeC. To do this, you should add a destructor to CSomeC that has the same loop as above, but calls delete[] objSomeC[nIndex].objSomeA
|
|
|
|
|
I found how do it in VS C++ 6.0
http://support.microsoft.com/default.aspx?scid=KB;en-us;q236312
but I need do it in Visual Studio C++ .NET (in VS C++ .NET it doesn't work)
|
|
|
|
|
Since MFC7 CHtmlView has it's own implementation of colecontrolsite, so usually you don't need to implement it on your own. Instead, for simply disabling the context menu, implement onshowcontextmenu and return S_OK. So your xontext menu is not shown any more.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
How Can I use a obj file instead of cpp file? Not Project->Setting->Link->Obj/Lib Modules, just using some code in source file.
|
|
|
|
|
I think you will find "pragma" (a group of compiler directives) has absolutely nothing to do with your issue.
I think you will also find that linkage of external modules requires a library format, but you can create your own library which contains nothing but the single object file you have in mind.
Bernd
|
|
|
|
|
Everytime I post something on here, I get the greatest advice. So I'm here to abuse the system again!
Lets say I have a dialog I created.."We'll call it 'Dialog'"
Is there some way before I call Dialog.DoModal() that i can preset what "icon" i want to load at a specific spot
for example.. i have 4 icons, each of them having a number. (ie, 1 icon has the numerical 1 on it, another has a numerical 2 on it, ect)
I want to be able to load the icon based on a selection a user made on a previous window.
as an example:
GET NUMBER
IF NUMBER == 1
Dialog.icon=icon001.ico
ELSE IF NUMBER == 2
Dialog.icon=icon002.ico
END IF
Dialog.DoModal()
lead2gold
|
|
|
|
|
In the header file for the dialog, add the member (in the public section, or make an accessor function for it):
CIcon m_YourIcon;
Then, when you know what icon you want:
char * a_pszIcon = NULL;
if( Number == 1 )
{
a_pszIcon = "icon1.ico";
}
else
if( Number == 2 )
{
a_pszIcon = "icon2.ico";
}
Dialog.m_YourIcon.Attach( (HICON)LoadImage( NULL, a_pszIcon, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ) );
Now, add a WM_INITDIALOG handler for your dialog, and in the handler put the code:
SetIcon( m_YourIcon, TRUE );
SetIcon( m_YourIcon, FALSE );
That's all you should have to do...if I understood the question correctly.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
It did very nicely! thanks so much!
lead2gold
|
|
|
|
|
|
Chris Richardson give you a good solution.;)
|
|
|
|
|
|
Hey, call me stupid but why would a plain MFC dialog-based project give the following output on close (in debug mode)?
The thread 0xC04 has exited with code 3 (0x3).
The program 'C:\...\FreqResp.exe' has exited with code 3 (0x3).
When the exe is compiled in release mode, when you exit the main dialog the program brings up the "FreqResp MFC Application has encountered a problem and needs to close" window.
Any ideas on why this would be happening would be helpful!
Cheers,
Dave
|
|
|
|
|
Does your app call abort() or signal() ? They both cause the app to exit with code 3, look up SIGABRT in MSDN for more details...
abort() sounds like it could be being called here, as that (according to MSDN) ends with an "abnormal program termination" - hence the message you get in release?
Dylan Boycott Bush Punch GWB
|
|
|
|
|
Hrrm - I don't call abort() or signal() in my program
I am stuck - it just seems to exit like any other mfc dialog app, but can't figure it out! If a button with IDOK or IDCANCEL is pressed the dialog should exit with code 0, but the app just won't do it!
Is there anything that could be failing and terminating the program, like something failing to close??
Cheers,
Dave
Cheers,
Dave
|
|
|
|
|
That sounds pretty odd. I'd try doing a 'rebuild all' and then stepping through the exit process in debug.
Dylan Boycott Bush Punch GWB
|
|
|
|
|
In the CFileSAveDialog, I give the user to save a file in the xls format
When I run the application in an os with no excel installed, the file does not get saved.
please help
|
|
|
|
|
How are you trying to save the file? If you are automating Excel to perform the save, then obviously Excel must be installed for it work...
Dave
|
|
|
|
|
Thanks for your reply
I use the excel to automate the saveing, so i think it is not possible
should just the user that it cant be saved unless excel is installed
|
|
|
|
|
What files do you need to include with your executable to get help working? Is there an install step that's necessary?
I verified my help interface on my computer, and then sent the application and the .hlp and .cnt files to a friend who said he couldn't access help from my application. I haven't created an install utility yet, he just extracted all the files to a directory of his choosing on his computer.
I tried searching for information on installing help, but haven't found anything yet...
|
|
|
|
|
according to your description, I think the reason for the problem maybe caused by the help files' path, please check your source code to confirm that you used the opposite path, if you used the absolute path in your application, the problem maybe occur on other computers.
good luck;)
Sh Ai
|
|
|
|
|
I've always created applications for a handful of engineers in a lab environment. This is my first "commercial" application, and I hate to admit it, it's the first time I've tackled Help!
I looked through my application to try to find out where the help file is specified, and didn't find anything. Can you provide a little more information on where I would find a reference to the help path?
Also, did you really mean "opposite" path?
Thanks for your reply.
|
|
|
|
|
help always goes like this:
void OnHelp()
{
WinHelp(m_hWnd,helpfile,0,0);//
// if you set helpfile like "C:\\path\\help.chm"
//then you may find no help file on another computer if no such file in such folder.
//i mean you should put all the help files in the subfolder where the exe file is.example:
//execute file path is "." so, the help file should be in ".\\help\\"
}
|
|
|
|
|
I used this function to get mouse cursor coodinates. I got different results when the program run in the Woindows 98/Me and Windows 2000/Xp. Why?
Thanks
|
|
|
|