Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » buttons

This thread is locked; no one can reply to it. rss feed Print
buttons
Tomek Kozera
Member #6,507
October 2005
avatar

Is there some support for buttons in allegro? I mean like menu buttons so that I wouldn`t have to check myself if mouse is clicked and propper frame is on top etc.

TeamTerradactyl
Member #7,733
September 2006
avatar

Tomek, are you talking about the buttons that are found in the allegro examples/exgui example file?

Tomek Kozera
Member #6,507
October 2005
avatar

Yes, thanks. It seems to cover all I`ll need. I just wish it would look that complicated (the code)...

EDIT:
I`ve tried to display a single button using the code from that example and I failed.
Here`s the code:

1 
2extern int info1(void);
3 
4int my_button_proc(int msg, DIALOG *d, int c)
5{
6 int ret = d_button_proc(msg, d, c);
7 if (ret == D_CLOSE && d->dp3)
8 return ((int (*)(void))d->dp3)();
9 return ret;
10}
11 
12void Manager::MainMenu(){
13DIALOG the_dialog[] ={
14 { d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15 { my_button_proc, 400, 150, 160, 20, 0, 0, 'i', D_EXIT, 0, 0, "&Info", NULL, (void *)info1 },
16 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17}; //(*)
18 do_dialog(the_dialog, -1);
19}
20 
21int info1(void) { allegro_message("asasas");}

In line (*) I get an error: invalid conversion from `const void*' to `void*'

Simon Parzer
Member #3,330
March 2003
avatar

Try to replace (void *)info1 by (const void*)info1.

Tomek Kozera
Member #6,507
October 2005
avatar

I`ve done that and this way I get the same error in the same place, except that I get it twice.
I`ve tried to make a rebuild (deleted all non .cpp and non .h files from the dir) and it didn`t help.

Go to: