|
That source code was also what I used. But the values I got were:
Cylinders: 4111 ( I use __int64 already.)
TracksPerCylinder: 255
SectorsPerTrack: 63
BytesPerSector: 512
The result, as you see, is 33GB.
But actually it is a 55.9GB one.
It means amount of cylinders should be 6964.
BuggyMax
|
|
|
|
|
I am showing bar Graph on a dilaog using progress bars. The graph is dynamically updating and this is shown by vayring values of progress bar.
I simply want the dialog to printed on a paper when the user clicks on a certain button on the dialog.
Plz guide me how to do so.
Reply me soon
|
|
|
|
|
I have developed a Dialog based Application.
I am using an ActiveX control. It plays a multimedia file.
Whenever it plays a file, it took a huge amount of memory, because the memory consumption depends on the number of frames contained in the file being played by the ActiveX control.
Now what I like, is to reclaim the memory consumed by the file.
Please can anybody tell me, how to reclaim the memory, because if we are reclaiming the memory it means we know in advance the location in memory we are consuming.
Please I need utmost help in this regard.
The Phantom. ™
|
|
|
|
|
Is your app allocating the memory, or is the ActiveX control doing it?
|
|
|
|
|
The ActiveX control consuming the memory...
The Phantom. ™
|
|
|
|
|
busisoft wrote:
Now what I like, is to reclaim the memory consumed by the file.
The ActiveX control consuming the memory...
Then there's not anything your program can do about it.
|
|
|
|
|
I have a CDialog derived class CMyDlg. I hope the CMyDlg can release itself automatically. To accomplish this, I implement the CMyDlg:: PostNcDestroy as follows:
CMyDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();
delete this;
}
Then, I always call the following code to create an instance of CMyDlg:
CMyDlg* pMyDlg = new CMyDlg;
pMyDlg->DoModal()
I believe that the PostNcDestroy() function will be called eventually if the CMyDlg is ended from the EndDialog(). And there is no memory leak, since *this* is deleted in the PostNcDestroy().
Can anyone confirm me whether my implementation is OK or not?
Thanks in advance.
lauch
|
|
|
|
|
There is nothing wrong in your approach theoretically, but you don't need to do all this. Just create it on the stack and when it goes out of scope it gets destroyed automatically. You only need to create a heap object (which them means you gotta delete it yourself) if you plan on creating a modeless dialog.
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
to Nish,
Thanks for your reply.
For some reasons, I must new the CMyDialog as a heap object and it must be a modal dialog box (which is created by the DoModal() function). Therefore, I decide to delete itself in the PostNcDestroy() specifically. I have tested my program, there is no memory leak. However, do you think my appraoch is safe? or is there probably a side effect in this implementaion?
Lauch
|
|
|
|
|
|
Nish,
Please help.
After EndDialog() is called, the DoModal() is released. I have walked through the MFC source code of the CDialog::DoModal(), I found DestroyWindow() is called in CDialog::DoModal() function, which in turn call PostNcDestroy() which will delete *this* pointer. And then, the code listed below will also be executed:
PostModal();
// unlock/free resources as necessary
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
UnlockResource(hDialogTemplate);
if (m_lpszTemplateName != NULL)
FreeResource(hDialogTemplate);
return m_nModalResult;
Since *this* is already freed, all member variable, function method and the memory allocated for the above code is supposed to be freed already, I am not sure whether or not it safe. Any hint?
Thanks.
|
|
|
|
|
lauch2 wrote:
I am not sure whether or not it safe.
It's safe, don't worry. When you do your delete you are deleting your dialog object, here they are basically freeing the dialog resource.
Anyway just in case you are still worried, you can move the delete from the PostNCDestroy to just after the DoModal :-
CDlg* a = new CDlg();
a->DoModal();
delete a;
This way you ensure that you delete it only after the call to PostModal from within DoModal.
But seriously I do not think there is any problem right now.
Regards,
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
On second thoughts I suggest that you do this :-
CDlg* a = new CDlg();
a->DoModal();
delete a;
Because if PostModal gets called after you delete the object then it is actually trying to access members of an object that does not exist anymore. This might cause problems as you can guess.
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
Nish,
Another question:
Do you know any messages will send to a dialog subsequently after calling the EndDialog() to triggle the dailog to close itself?
lauch
|
|
|
|
|
If anybody knows how to implement automation function in Visual C++ to copy bitmap that resides on the clipboard to a MS Word documetn. Sounds so simple but I am clueless. Please HELP!!!
|
|
|
|
|
I have a single document interface application. Its base class is CFormView. I've added a CTreeCtrl to it just like I would in a dialog based application. I've given the tree control an Id and I've created a variable of type CTreeCtrl. However, when I try to use it my application crashes. Its seems that my tree control has not been initialized...
this->m_ctrlSetupTree {CTreeCtrl hWnd=0x00000000}
|
|
|
|
|
The the code that creates the CTreeCtrl object, i.e. Create().
Kuphryn
|
|
|
|
|
How do I get the parent CWnd* pParentWnd?
BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );
|
|
|
|
|
Call GetParent().
Kuphryn
|
|
|
|
|
isn't it your view? this (or similar)
t!
|
|
|
|
|
|
I would bet you are trying to use it before the tree control has been created. Are you trying to access the tree control in a WM_SIZE handler? If so, it won't be created the first couple times the WM_SIZE handler gets called. Usually, the fix for this is something like this:
if( !IsWindow( m_YourTreeCtrl ) )
return;
However, if you are trying to access the tree in a function that's only called once (say, for initialization), then you'll have to put the initialization code in some other function that's called later on.
Chris Richardson Terrain Software
|
|
|
|
|
I'm calling the following code. But it seems that my hWnd is still null.
CRect treeRect;
treeRect.NormalizeRect();
CImageList *pImageList=new CImageList;
if(this->m_ctrlSetupTree.Create(WS_VISIBLE,treeRect,this,IDC_SETUP_TREE))
{
Beep(999,99);
int i, icons=0;
for (icons=0; RCanalTree::m_icons[icons]; icons++) {}
pImageList->Create(16, 16, TRUE, icons,6);
for (i=0; RCanalTree::m_icons[i]; i++)
{
pImageList->Add(AfxGetApp()->LoadIcon(RCanalTree::m_icons[i]));
}
m_ctrlSetupTree.SetImageList(pImageList,TVSIL_NORMAL);
if(this->m_oCanalManager.CreateNewDataStructures())
{
}
}
}
|
|
|
|
|
Your control is failing to be created because you haven't specified the WS_CHILD style. Here's the correct line of code:
if(this->m_ctrlSetupTree.Create(WS_CHILD|WS_VISIBLE,treeRect,this,IDC_SETUP_TREE))
{
..... snip .....
}
Chris Richardson Terrain Software
|
|
|
|
|
Hmmmm...Create still returned zero..
CTreeCtrl::Create returned 0
if(this->m_ctrlSetupTree.Create(WS_CHILD|WS_VISIBLE|TVS_HASLINES,treeRect,this,IDC_SETUP_TREE))
|
|
|
|