I try to use Up-Down button component. The on-line help
gives the following example:
void __fastcall TForm1::FormCreate(TObject *Sender)
{
for (int i = 0; i < 10; i++)
{
TTabSheet *pPage = new TTabSheet(PageControl1);
pPage->PageControl = PageControl1;
pPage->Caption = AnsiString("Page") + IntToStr(i);
}
}
void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
{
PageControl1->SelectNextPage(Button == btNext);
}
----------------------------------------------------------------
My implementation is as follows:
----------------------------------------------------------------
void __fastcall TmainForm::lshBtnClick(TObject *Sender, TUDBtnType Button)
{
changeLowerStopbandsUpperEdge(Button == btNext);
}
void __fastcall TmainForm::changeLowerStopbandsUpperEdge(bool
upButtonPressed)
{
if (upButtonPressed == true)
lshOffset++;
else
lshOffset--;
lshBtn -> Position = frequencyArray[lshOffset];
oldLsh = lshBtn -> Position;
}
The compiler gives me the following error message:
[C++Error] main.cpp(221): Ambiguity between 'Mplayer::btNext' and
'Comctrls::btNext'.
Where the problem can be, what's the solution?
Thanks for your time.
----------------------------------------------------------------
--
Best regards
Charles Moori
The optimist thinks, the Earth is the best place to live.
The pessimist is scared, that is true.
(R. Oppenheimer)
Change this line:
changeLowerStopbandsUpperEdge(Button == btNext);
To this instead:
changeLowerStopbandsUpperEdge(Button == Comctrls::btNext);
Gambit
"Charles Moori" <cmo...@primus.ca> wrote in message
news:3e7660a3$1...@newsgroups.borland.com...
In the meantime I have found the solution, but I got a non-consistent behaviour
of
this button, so I have deleayed the reply. I wanted to give a working piece of
code,
so other people could learn (which I will do if I found the solution for this
new problem).
The way I found was:
I have created a variable of type TUDButtonType
TUDButtonType bt;
run the code, and stopped right after this definition. When 'watching' this
variable,
C-Builder gives the following line:
bt: 0 /* Comctrls::btNext */
This made clear, what is missing from my code.
Sorry that I took you time, as I found, you are one of the (if not the very
first) most
helping guy in the Borland Newsgroups. Thank you for it, and hopfully you keep
helping others for long time.
Charles
"Remy Lebeau (TeamB)" wrote:
--
the buttob definition line should be read as follows:
TUDBtnType bt = Button;
and now when stopping the program right after this line, it really gives the
watch I mentioned in my reply.
Thanks and sorry for the mistake
This code behave non-consistently, sometimes it incremented the value in the window
- despite the fact, that the btPrev arrow was pressed - sometimes, rarely, it
worked
for one or two presses as it planned.
Now, here is the code, what seems to work:
void __fastcall TmainForm::changeLowerStopbandsUpperEdge(TUDBtnType bt)
{
if (bt == Comctrls::btPrev)
lshOffset--;
else
lshOffset++;
oldLsh = lshBtn -> Position;
lsbHighEdge->Lines->Clear();
lsbHighEdge->Lines->Text = (AnsiString)frequencyArray[lshOffset];
}
The calling argument difference [ bool prevButtonPressed <---> TUDBtnType bt)
is not significant.
The main difference is that I removed the association between the button and the
related
TRichEdit window. So I can increment/decrement the Button's position by 1, and
fill the window using my frequencyArray. Everything is working fine.
My question here is, if there is another solution which allows the association of
the button and the edit window. If yes, please let me know.
I provide the code fragments below, so if somebody meets similar task, could use
this - or possible a better solution (which will be in your replies)-
Here is the event handler:
void __fastcall TmainForm::lshBtnClick(TObject *Sender, TUDBtnType Button)
{
TUDBtnType bt = Button; // this is just for debugging
changeLowerStopbandsUpperEdge(bt); // here instead of 'bt', 'Button' can be
passed
}
The called function:
void __fastcall TmainForm::changeLowerStopbandsUpperEdge(TUDBtnType bt)
{
if (bt == Comctrls::btPrev)
lshOffset--;
else
lshOffset++;
lsbHighEdge->Lines->Clear();
lsbHighEdge->Lines->Text = (AnsiString)frequencyArray[lshOffset];
}
and finally the frequency array:
int frequencyArray[MAX_FREQ_NUM] =
{
0, 20, 30, 40, 50, 60, 70, 80, 90, 100,
200, 300, 400, 500, 600, 700, 800, 900, 1000,
2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000,
11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000
};
Looking forward for your suggestions
Charles