Click here to Skip to main content
15,922,696 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to print string in next line on Edit control Pin
sribachana13-Nov-08 15:41
sribachana13-Nov-08 15:41 
QuestionRe: How to print string in next line on Edit control Pin
David Crow13-Nov-08 17:36
David Crow13-Nov-08 17:36 
AnswerRe: How to print string in next line on Edit control Pin
voidjinjin13-Nov-08 14:46
voidjinjin13-Nov-08 14:46 
QuestionBrowser plugins question. Pin
rrrado13-Nov-08 2:38
rrrado13-Nov-08 2:38 
QuestionRe: Browser plugins question. Pin
David Crow13-Nov-08 2:44
David Crow13-Nov-08 2:44 
AnswerRe: Browser plugins question. Pin
rrrado13-Nov-08 3:02
rrrado13-Nov-08 3:02 
AnswerRe: Browser plugins question. Pin
Saurabh.Garg13-Nov-08 14:01
Saurabh.Garg13-Nov-08 14:01 
Questionwhich of the buttons is clicked ? Pin
wielklem13-Nov-08 1:08
wielklem13-Nov-08 1:08 
Hi,

I'm creating a whole bunch of buttons during run-time. When anyone of these buttons is clicked it should go through the same function, but with different parameters. A small example to clarify;
for (x = 0; x < 10; x++)
{
  TButton *b = new TButton(this);
  b->Caption = "My button " + IntToStr(x);
  b->Top = 100;
  b->Left = 100 + 10 * x;
  b->OnClick = myfunction(x);
  b->Parent = this;
}

void __fastcall TForm1::myfunction(int x)
{
  ShowMessage("Button " + IntToStr(x) + " clicked");
}


This, however, doesn't work. I get an "Not an allowed type" error when compiling. Apparantly I can't pass variables like this to myfunction.


I can only do something like this;
b->OnClick = myfunction;

void __fastcall TForm1::myfunction(TObject *Sender)
{
  ShowMessage("Button ? clicked");
}


But how do I know which of the ten buttons is clicked now? How can I pass this information to the function?

thanx
Willem
AnswerRe: which of the buttons is clicked ? Pin
CPallini13-Nov-08 2:04
mveCPallini13-Nov-08 2:04 
GeneralRe: which of the buttons is clicked ? Pin
wielklem13-Nov-08 2:37
wielklem13-Nov-08 2:37 
GeneralRe: which of the buttons is clicked ? Pin
CPallini13-Nov-08 2:59
mveCPallini13-Nov-08 2:59 
QuestionRe: which of the buttons is clicked ? Pin
David Crow13-Nov-08 2:48
David Crow13-Nov-08 2:48 
AnswerRe: which of the buttons is clicked ? Pin
CPallini13-Nov-08 2:56
mveCPallini13-Nov-08 2:56 
GeneralRe: which of the buttons is clicked ? Pin
David Crow13-Nov-08 3:15
David Crow13-Nov-08 3:15 
GeneralRe: which of the buttons is clicked ? Pin
CPallini13-Nov-08 3:19
mveCPallini13-Nov-08 3:19 
QuestionRe: which of the buttons is clicked ? Pin
David Crow13-Nov-08 2:53
David Crow13-Nov-08 2:53 
AnswerRe: which of the buttons is clicked ? Pin
wielklem13-Nov-08 5:30
wielklem13-Nov-08 5:30 
AnswerRe: which of the buttons is clicked ? Pin
Iain Clarke, Warrior Programmer13-Nov-08 2:55
Iain Clarke, Warrior Programmer13-Nov-08 2:55 
QuestionUpdate the Window.. Pin
gothic_coder12-Nov-08 23:57
gothic_coder12-Nov-08 23:57 
AnswerRe: Update the Window.. Pin
SandipG 13-Nov-08 1:12
SandipG 13-Nov-08 1:12 
GeneralRe: Update the Window.. Pin
gothic_coder13-Nov-08 3:23
gothic_coder13-Nov-08 3:23 
QuestionRe: Update the Window.. Pin
bob1697213-Nov-08 16:35
bob1697213-Nov-08 16:35 
AnswerRe: Update the Window.. [modified] Pin
gothic_coder13-Nov-08 19:04
gothic_coder13-Nov-08 19:04 
QuestionRe: Update the Window.. Pin
bob1697214-Nov-08 4:18
bob1697214-Nov-08 4:18 
AnswerRe: Update the Window.. Pin
gothic_coder14-Nov-08 20:32
gothic_coder14-Nov-08 20: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.