I am new learner and I copy the exact code from book and run the following code . this code for MDI sample program
my PC is XP system

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "ViewMain.h"
#include "MDIChild.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Open1Click(TObject *Sender)
{
 if (OpenDialog->Execute())
{
TChild* child = new TChild(this);
child->SetParent(this);//   <----LINE WITH ERROR HIGH LIGHTED
child->Image->Picture->LoadFromFile(OpenDialog->FileName);
child->ClientWidth = child->Image->Picture->Width;
child->ClientHeight = child->Image->Picture->Height;
child->Caption = OpenDialog->FileName;
child->Show();
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Save1Click(TObject *Sender)
{
 TChild* child = dynamic_cast<TChild*>(ActiveMDIChild);
if (!child) return;
if (SaveDialog->Execute())
{
child->Image->Picture->SaveToFile(SaveDialog->FileName);
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Tile1Click(TObject *Sender)
{
  Tile();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Cascade1Click(TObject *Sender)
{
 Cascade();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ArrangeAll1Click(TObject *Sender)
{
  ArrangeIcons();
}
//---------------------------------------------------------------------------

error of compiling is :-

[C++ Error] ViewMain.cpp(23): E2247 '_fastcall TCustomForm::SetParent(TWinControl *)' is not accessible

the line with error is :-
child->SetParent(this);// <----LINE WITH ERROR HIGH LIGHTED

Can any expertist point out what's wrong . Is it because I use XP
( and not win98 or 2000)?

Method SetParent() has private or protected access.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.