|
What does your question have to do with C/C++/MFC?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
hi,
how do i detect memory leak, in a win32 console project?
Zo.Naderi-Iran
|
|
|
|
|
|
If all else fails, you can use the Signal Flare debugging pattern: Increase the size of your allocations (one at a time) by ten, and rerun your program. When the memory leak increases by ten, you've found the problem.
|
|
|
|
|
|
|
If using protocol TCP and UDP how to use more network bandwidth?
Especially, how to limit transfer speed of other application, when my program is transferring data?
|
|
|
|
|
Q1: Increase the packet-size as much as practical. The header size is fixed, so by increasing the total size of the packet, you are minimizing the proportion of the data that is used to just transfer the header.
The downside is that more packets will fail a CRC check, meaning you'll have to download a larger number of larger chunks of data in the event of CRC failure.
Q2: Don't know. I certainly wouldn't want a program to explicitly screw with the transfer speed of an app I was already running. I suspect that the best solution would be to have the user pause/shut-down these other programs themselves.
|
|
|
|
|
Assume your program can,Then, why others program can not?
If all the programs can, what will be the result?
|
|
|
|
|
So your application is more important than any other and you should be given priority?
Consider using QoS services[^]
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
I have two views ( CMainView and CMembersView ) in my SDI application. The code below resizes my MFC GridCtrl according to size of app's window when the view is initialized.
I get valid values for CRect grid_rect {top=0 bottom=952 left=0 right=1819} in CMainView. But in CMemberView I am having some undesired values.
void CMembersView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
initialized = TRUE;
CWnd *pGridCtrl = this->GetDlgItem(IDC_MEMBERSGRID);
ASSERT(pGridCtrl);
CRect rect,grid_rect;
CWnd *pWnd = this->GetOwner();
pWnd->GetClientRect(rect);
pGridCtrl->GetWindowRect(grid_rect);
grid_rect = rect;
grid_rect.left += 16;
grid_rect.top += 150;
grid_rect.bottom -= 300;
grid_rect.right -= 16;
pGridCtrl->MoveWindow(grid_rect);
Where am I going wrong ?
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
The window size is never specified when you first call pGridCtrl->GetWindowRect(grid_rect); in the OnInitialUpdate.
Please write some codelike below in your CMembersView::OnSize
CWnd *pGridCtrl = this->GetDlgItem(IDC_MEMBERSGRID);
ASSERT(pGridCtrl); if ( ::IsWindow(pGridCtrl->GetSafeHwnd()) )
{
pGridCtrl->MoveWindow(..<the_desired_size_of_gridctrl_in_the_CMembersView)
}
modified on Thursday, August 25, 2011 4:08 AM
|
|
|
|
|
Doesn't help much.
---------------------------------------------
" Future Lies in Present "Manmohan Bishnoi
|
|
|
|
|
I guess you do not catch all my meaning.
If you just set the grid position in OnInitialUpdate, then even it works. There still some problem after you resize your application.
To make sure it works in all case, you must do it inside OnSize
CMembersView::OnSize:
CWnd *pGridCtrl = this->GetDlgItem(IDC_MEMBERSGRID);
ASSERT(pGridCtrl); if ( ::IsWindow(pGridCtrl->GetSafeHwnd()) )
{
CRect rctClient;
this->GetClientRect(&rctClient);
pGridCtrl->MoveWindow(0, 0, rctClient.Width()/2, rctClient.Height());
}
modified on Thursday, August 25, 2011 10:19 AM
|
|
|
|
|
yes you were right. now code is working.
thanks.
---------------------------------------------
" Future Lies in Present "Manmohan Bishnoi
|
|
|
|
|
IIRC GetXXXRect take pointers as parameters. Have you tried with
pGridCtrl->GetWindowRect(&grid_rect);
Same comment for the GetClientRect call a few line above.
|
|
|
|
|
This is working fine :-
void CMainView::OnInitialUpdate() {
CFormView::OnInitialUpdate();
initialized = TRUE;
CWnd *pGridCtrl = GetDlgItem(IDC_SALEPURCHASEGRIDCTRL);
CRect rect,grid_rect;
CWnd *pWnd = this->GetOwner();
pWnd->GetClientRect(rect);
pGridCtrl->GetWindowRect(grid_rect); grid_rect = rect;
grid_rect.left += 16;
grid_rect.top += 150;
grid_rect.bottom -= 300;
grid_rect.right -= 16;
pGridCtrl->MoveWindow(grid_rect); .
.
.
This is not working properly:-
void CMembersView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
initialized = TRUE;
CWnd *pGridCtrl = this->GetDlgItem(IDC_MEMBERSGRID);
ASSERT(pGridCtrl);
CRect rect,grid_rect;
CWnd *pWnd = this->GetOwner();
pWnd->GetClientRect(rect);
pGridCtrl->GetWindowRect(grid_rect); grid_rect = rect;
grid_rect.left += 16;
grid_rect.top += 150;
grid_rect.bottom -= 300;
grid_rect.right -= 16;
pGridCtrl->MoveWindow(&grid_rect);
.
.
.
---------------------------------------------
" Future Lies in Present "Manmohan Bishnoi
|
|
|
|
|
Are the coordinate that should be returned by GetWindowRect really null ? What does the debugger says (if you look into the pGridCtrl structure) ? Have tried GetLastError ?
|
|
|
|
|
In CMainView :-
grid_rect {top=-0 bottom=912 left=0 right=1819} CRect
In CMembersView :-
grid_rect {top=-32639 bottom=-32483 left=-32709 right=-31884} CRect
---------------------------------------------
" Future Lies in Present "Manmohan Bishnoi
|
|
|
|
|
Actually, you are overwriting grid_rect in the next part of the code with the content of rect, making the GetWindowRect call unnecessary. What if you comment out this line pGridCtrl->GetWindowRect(grid_rect); ?
( just to test if the MoveWindow is accepted).
|
|
|
|
|
I use it to just test whether grid_rect fetches some values or not.
Ok. I comment it out. But still it doesn't help.
---------------------------------------------
" Future Lies in Present "Manmohan Bishnoi
|
|
|
|
|
Then I guess the OP was right and the structure/window is not initialized properly at this point of time. So either this is the standard behaviour, and you will have to initialize it in another event, or something goes wrong when creating the GridCtrl.
|
|
|
|
|
This code below occurs no error but the result seems a bit weird.
class KBase
{
public:
void BaseFun()
{
printf( "KBase::BaseFun() this=%p\n", this );
}
};
class KMiddle : public KBase
{
};
class KMiddle2 : public KBase
{
};
class KDerived : public KMiddle, public KMiddle2
{
};
int main()
{
KDerived d;
d.KBase::BaseFun(); d.KMiddle::BaseFun(); d.KMiddle2::BaseFun();
return 0;
}
BaseFun simply shows this pointer and the result goes..
---------------------------
KBase::BaseFun() this=0012FF63
KBase::BaseFun() this=0012FF63
KBase::BaseFun() this=0012FF64
---------------------------
So my question is why KBase::BaseFun() and KMiddle::BaseFun() show the same address and the only KMiddle2::BaseFun() does the different address?
I was looking for the answer by reading Stephen Prata's book and Effective C++ but I couldn't.
Thanks in advance.
modified on Wednesday, August 24, 2011 9:51 PM
|
|
|
|
|
Which complier do you use?
in some complier that follow the standard c++ strictly, like g++, your code will not compiled and got Error Message:
`D' is an ambiguous base of `B'
To make the multiple inheritance follows the standard c++ well, you should using virtual inheritance in this case.
class KMiddle : virtual public KBase
class KMiddle2 : virtual public KBase
class KDerived : public KMiddle, public KMiddle2
|
|
|
|
|
Hi,
xrg_soft@163.com wrote: Which complier do you use?
I use Visual Studio 2008.
xrg_soft@163.com wrote: To make the multiple inheritance follows the standard c++ well, you should using virtual inheritance
I know that the multiple inheritance needs virtual inheritance.
However, when I don't on purpose, the result seems not understandable.
Could you explain to me why those 'this' addresses look unrestrained?
|
|
|
|