Click here to Skip to main content
16,011,447 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: learn STL / templates Pin
Tomasz Sowinski13-Sep-01 4:50
Tomasz Sowinski13-Sep-01 4:50 
GeneralRe: C++ Pin
Tomasz Sowinski13-Sep-01 5:15
Tomasz Sowinski13-Sep-01 5:15 
General_CrtIsValidHeapPtr Pin
Derek Lakin13-Sep-01 2:04
Derek Lakin13-Sep-01 2:04 
GeneralRe: _CrtIsValidHeapPtr Pin
Tomasz Sowinski13-Sep-01 2:08
Tomasz Sowinski13-Sep-01 2:08 
GeneralRe: _CrtIsValidHeapPtr Pin
Derek Lakin13-Sep-01 2:17
Derek Lakin13-Sep-01 2:17 
GeneralRe: _CrtIsValidHeapPtr Pin
Tomasz Sowinski13-Sep-01 2:28
Tomasz Sowinski13-Sep-01 2:28 
GeneralRe: _CrtIsValidHeapPtr Pin
Derek Lakin13-Sep-01 2:34
Derek Lakin13-Sep-01 2:34 
GeneralRe: _CrtIsValidHeapPtr Pin
Tomasz Sowinski13-Sep-01 2:45
Tomasz Sowinski13-Sep-01 2:45 
So there are two overloads of AddPage, right?
void AddPage(UINT nResID);
void AddPage(CTabPage *page);

You need to keep not only the page pointer, but a boolean value meaning 'tab control created this page'. To avoid code duplication, create new private method that adds the page to internal list. Note the second parameter.
private:
void RealAddPage(CTabPage *page, bool bOwnedByMe);

AddPage methods should call ReadAddPage passing true or false respectively:
void CYourTab::AddPage(CTabPage *page)
{
RealAddPage(page, false);
}
void CYourTab::AddPage(UINT nResID)
{
CTabPage *page = new CTabPage(nResID);
// do whatever you need to fully construct page
RealAddPage(page, true);
}

In destructor, you'll iterate through list of pages and call delete only on those created with a call to AddPage accepting resource ID.

Tomasz Sowinski -- http://www.shooltz.com
GeneralRe: _CrtIsValidHeapPtr Pin
Derek Lakin13-Sep-01 3:02
Derek Lakin13-Sep-01 3:02 
GeneralDialog Resizing Pin
13-Sep-01 1:34
suss13-Sep-01 1:34 
GeneralRe: Dialog Resizing Pin
Tomasz Sowinski13-Sep-01 2:04
Tomasz Sowinski13-Sep-01 2:04 
GeneralRe: Dialog Resizing Pin
13-Sep-01 3:10
suss13-Sep-01 3:10 
GeneralRe: Dialog Resizing Pin
Tomasz Sowinski13-Sep-01 3:17
Tomasz Sowinski13-Sep-01 3:17 
GeneralRe: Dialog Resizing Pin
13-Sep-01 4:14
suss13-Sep-01 4:14 
GeneralRe: Dialog Resizing Pin
Tomasz Sowinski13-Sep-01 4:28
Tomasz Sowinski13-Sep-01 4:28 
GeneralRe: Dialog Resizing Pin
13-Sep-01 2:15
suss13-Sep-01 2:15 
GeneralRe: Dialog Resizing Pin
13-Sep-01 3:17
suss13-Sep-01 3:17 
GeneralRe: Dialog Resizing Pin
13-Sep-01 3:25
suss13-Sep-01 3:25 
GeneralRe: Dialog Resizing Pin
13-Sep-01 4:04
suss13-Sep-01 4:04 
GeneralRe: Dialog Resizing Pin
13-Sep-01 3:28
suss13-Sep-01 3:28 
GeneralRe: Dialog Resizing Pin
#realJSOP13-Sep-01 5:00
professional#realJSOP13-Sep-01 5:00 
GeneralRe: Dialog Resizing Pin
Tomasz Sowinski13-Sep-01 5:38
Tomasz Sowinski13-Sep-01 5:38 
GeneralProblem with MSComm Ocx Pin
Patwa13-Sep-01 1:07
Patwa13-Sep-01 1:07 
GeneralExcel and VisualC++6.0 Pin
13-Sep-01 0:17
suss13-Sep-01 0:17 
GeneralRe: Excel and VisualC++6.0 Pin
Michael P Butler13-Sep-01 0:32
Michael P Butler13-Sep-01 0:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.