Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Build Error

Status
Not open for further replies.

GrandpaF

Programmer
Joined
Oct 20, 2012
Messages
3
Location
AU
At runtime I want to generate a pagecontrol with a number of tabsheets, each tab sheet to have a StringGrid.
My code for doing so is:
-------
ppc = new TPageControl(this);
ppc->Parent = this;
ppc->Align = alClient;
ppc->TabPosition = tpTop;

for(i=0;i<NumberTabs;i++)
{ TabArray = new TTabSheet(this);
TabArray->PageControl = ppc;
TabArray->Name = AnsiString("TabArray") + IntToStr(i);
TabArray->Caption = sTitles;
TabArray->PageIndex = i;
TabArray->OnShow = TabOnShow;


GridArray = new TStringGrid(TabArray);
GridArray->Parent = TabArray;
GridArray->Align = alClient;
GridArray->ColCount = 8;
GridArray->RowCount = 2;
GridArray->DefaultRowHeight = 18;
GridArray->FixedRows = 1;
GridArray->FixedCols = 1;
GridArray->Name = "sg" + IntToStr(i+1);
GridArray->Width = 990;
GridArray->DoMouseUp;
}
---------------
My function for the "DoMouseUp" is as follows:
---------------
void __fastcall TfMainRecharges::DoMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{

// code to go here

}
//----------------------------------------
However when I make or build I get following error:

[c++ Error] MainRecharges.cpp(113):'fastcall TControl::DoMouseUp(TWMMouse & TMouseButton)' is not accessible

I canm't seem to work out how to get around this, is there a fix?


 
I am assuming that 'fastcall TControl::DoMouseUp(TWMMouse & TMouseButton)' is meant to be a call to the ancestor DoMouseUp method from the TfMainRecharges::DoMouseUp method.DoMouseUp. The problem is that there is no such method declared in TControl. The call I think you are looking for would be MouseUp, not DoMouseUp. And the parameters do no match up either; TControl::MouseUp takes the same parameters as your TfMainRecharges::DoMouseUp. Your call to TControl::DoMouseUp only has the one parameter, a reference to TWMMouse called TMouseButton??? I am pretty sure this was not what you wanted.
 
I was trying to do the same as I did earlier. You will notice in defining the TabArray a line "TabArray->OnShow = TabOnShow;"
which performs the OnShow event of the TabSheet. This works fine.

The function for this is as below:
----------------------------
void __fastcall TfMainRecharges::TabOnShow(TObject *Sender)
{ int i;

TTabSheet* tab_sender = dynamic_cast<TTabSheet*>(Sender);
if(tab_sender != NULL)
{
for(i=0;i<NumberTabs;i++)
{ if(tab_sender == TabArray)
{ TabIndex = i;
bModified[TabIndex] = true;
bFileIsOpen[TabIndex] = true;
break;
}
}
}
}
//---------------------------------------------------------------------------
 
There is no Event or Method in TControl or any of it's descendants called DoMouseUp; There is an OnMouseUp event that you can assign an event handler to (which I think is what you may be actually trying to do), and a MouseUp Method that you can override.

Question: What is this line actually saying to the compiler?

GridArray->DoMouseUp; //access TStringGrid::DoMouse

I think what you actually want is:

GridArray->OnMouseUp = TfMainRecharges::DoMouseUp;


 
Many thanks.... "GridArray->OnMouseUp = TfMainRecharges::DoMouseUp;" is what I needed, fixed the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top