Error Heap in allocate modeless .
-
I have the code about create many modeless dialog .
for(int i=0;i < 5;++i)
{
pRegionDlg[i] = new CRegionDlg ( this );
pRegionDlg[i]->Create( IDD_DIALOG , this );
pRegionDlg[i]->ShowWindow( SW_SHOW ) ;
}this code is error heap . but I don't understand why it's error . while this code can run good on other program . Thanks for reading and helping .
-
I have the code about create many modeless dialog .
for(int i=0;i < 5;++i)
{
pRegionDlg[i] = new CRegionDlg ( this );
pRegionDlg[i]->Create( IDD_DIALOG , this );
pRegionDlg[i]->ShowWindow( SW_SHOW ) ;
}this code is error heap . but I don't understand why it's error . while this code can run good on other program . Thanks for reading and helping .
HTT90 wrote:
this code is error heap . but I don't understand why it's error . while this code can run good on other program .
What is this supposed to mean? What error? Where? How was
pRegionDlg
declared? Please clarify."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
"Man who follows car will be exhausted." - Confucius
-
I have the code about create many modeless dialog .
for(int i=0;i < 5;++i)
{
pRegionDlg[i] = new CRegionDlg ( this );
pRegionDlg[i]->Create( IDD_DIALOG , this );
pRegionDlg[i]->ShowWindow( SW_SHOW ) ;
}this code is error heap . but I don't understand why it's error . while this code can run good on other program . Thanks for reading and helping .
Maybe 'the other program' properly allocates the
pRegionDlg
array. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Maybe 'the other program' properly allocates the
pRegionDlg
array. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I did : in header file :
CRegionDlg *pRegionDlg[8] ;
and when I debug , I receive a message , it's inform me no loaded from dll . and heap is error .
Please don't define arrays in header files. Please report full error message. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Please don't define arrays in header files. Please report full error message. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I don't know why now it's run good and no error . :( . Can You say why don't define arrays in header files ? I'm chicken . :)
You should never define variables inside header files (headers are for declarations), because you may get multiple definitions of the same symbol (if, as usual, the header is included by many sources). If you need to access a variable from multiple sources then you have to:
- Declare it as
extern
inside an header file. - Define it inside just one source file.
- Include the header file into every source that needs to access the variable itself.
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] - Declare it as
-
You should never define variables inside header files (headers are for declarations), because you may get multiple definitions of the same symbol (if, as usual, the header is included by many sources). If you need to access a variable from multiple sources then you have to:
- Declare it as
extern
inside an header file. - Define it inside just one source file.
- Include the header file into every source that needs to access the variable itself.
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] - Declare it as