|
A simple modeless dialog with a few static controls and a progress control would suffice.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want to find the value of checkbox wother it is checked or unchecked.
Which function to use.
I kope GetDlgItemText() will not work.
Dhiraj Kumar Saini
|
|
|
|
|
CButton::GetCheck
Maxwell Chen
|
|
|
|
|
In addition to the MFC suggestion already provided, you can also send the control a BM_GETCHECK or BM_SETCHECK message.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello Friends,
I am facing the problem of memory leak. In one of the application I am taking dynamic global object. And when I try to delete then in my WinMain() function before return 0; statement but it gives me assertion errror.
I am using somewhat like this;
<br />
myclass *obj = new myclass();<br />
<br />
INT WINAPI WinMain( ....)<br />
{<br />
delete obj;
return 0;<br />
<br />
}
the error is like this:
Debug assertion failed.
expression _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) is invalid.
So I am using somewhat like this
INT WINAPI WinMain( ....)<br />
{<br />
delete (void *)obj;
return 0;<br />
<br />
}
Now my question is.
Now will there be any memory leak in the programme or not ???
|
|
|
|
|
I guess yes. The type info is corrupted.
Maxwell Chen
|
|
|
|
|
use auto_ptr...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Don't overabuse auto_ptr: you don't need to wrap every pointer into a smart pointer when it is not required.
|
|
|
|
|
There is probably something wrong in your destructor. Use your debugger to see exactly what is happening (check if the pointers are valid and so on).
|
|
|
|
|
The memory leak control implemented on the CRT overloads the new and delete operators to add some extra memory to contain some signatures that are tracked by a global data structure.
At end, is something is wrong between this structure and the related allocated memory a warning is reported.
In your case your obj pointer is also a global data. But since the initialization order of global data is not predictable (in the sense that it depends on the order the linker links the modules) probably your "new " call happens before the tracking structure is properly initialized (hence, it isn't tracked).
But the delete is. Hence the misleading and the resulting report.
Try this:
class myhandle
{
myclass* p;
public:
myhandle() :p(new myclass) {}
~myhandle() { delete p; }
myclass* operator->() const { return p; }
};
myhandle thehandle;
INT WINAPI WinMain( ....)
{
myhandle->do_something_with_myclass(...)
return 0;
}
Now allocation and deallocation are wrapped in ctor / dtor.
When thehandle is created the compiler will place an "atexit" to invoke the destructor.
Since the order of destruction is the inverse of the order of construction, you're so granted that either both new and delete are tracked or none of them is. Both case are coherent.
<edit>
I see just now ThatsAlok writing "use auto_ptr".
In fact std::auto_ptr behave just like myhandle in respect to construction / destruction.
</edit>
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Your program is not causing any assertion, but the following is. May be you are doing something like this -
class myclass
{
public:
char Ary[200];
char *p;
myclass()
{
p = new char[1000];
}
~myclass()
{
delete []p;
}
};
myclass *obj = new myclass();
myclass *obj2 = new myclass();
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
delete obj2; //not getting error here.
obj = obj2;
delete obj; //getting error here.
return 0;
}
|
|
|
|
|
you didn't take in account what i told you yesterday.
Fix your signature immediately. the html you use in it is not well formatted[^]not well formatted, thus a break in the pages' style.
if you use too much characters in the sense that CP don't allow much, then reduce your signature.
|
|
|
|
|
Ok I got it. there were too many charcters. and so it was happening. I have remooved the charcters. And I think now its correct
|
|
|
|
|
GauranG33 wrote: Ok I got it. there were too many charcters. and so it was happening. I have remooved the charcters. And I think now its correct
actually, it's a bit better, but not perfect.
here is your sig :
<b>G</b>auran<b>G</b><sup><font color=red>33</sup>
you're not closing the <font> tag...
|
|
|
|
|
I think this will be right
GauranG33
|
|
|
|
|
|
I notified him twice of the very same thing. He's convinced nothing is wrong.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: He's convinced nothing is wrong
seems that he finally figured out he had a problem 'cause he's fixed it now
|
|
|
|
|
Hi,
I am getting the following error while building the code in Debug code:
error PRJ0019: A tool returned an error code from "Performing Custom Build Step
Please help regarding the following error.
Regards
|
|
|
|
|
from MSDN:
An error level was nonzero for a custom build step or build event.
It seems that your custom build step failed. Plz check the steps written in it.
|
|
|
|
|
The message i am getting is p[osted here.Please help what should i do to get rid of this error:
>Deleting intermediate and output files for project 'AudioCap', configuration 'Debug|Win32'
1>Performing Custom Build Step
1>MC: -u switch must be used with Unicode message file!
1>Project : error PRJ0019: A tool returned an error code from "Performing Custom Build Step"
1>Build log was saved at "file://d:\voice editor sw\VRS\AudioCap\Debug\BuildLog.htm"
1>AudioCap - 1 error(s), 0 warning(s)
Regards,
|
|
|
|
|
MC: -u switch must be used with Unicode message file!
May be your project settings are ANSI, and you are using switch -u which is for unicode files. Use -a in place of -u.
Or paste the "Custom build step" steps. Also tell about your project settings, ANSI or UNICODE ?
|
|
|
|
|
hits07 wrote: 1>MC: -u switch must be used with Unicode message file!
How clear do you want it? The Message Compiler (MC) is needing the -u switch. See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want to open the dialog box for browse button in order to select single or multiple files. I am using MFC.
how to do it.
Thanks In aadvance.
Dhiraj Kumar Saini
|
|
|
|
|
The class for showing the dialog is CFileDialog .
You can use the following sample code -
char szFilters [] = "Text Files (*.text)|*.txt|";
CFileDialog FileDialog (TRUE, "txt", "", OFN_FILEMUSTEXIST, szFilters, this);
CString FileName;
if (FileDialog.DoModal () == IDOK)
{
FileName = FileDialog.GetPathName ();
}
|
|
|
|