Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Another "help with Allegro GUI"-type question

Credits go to Dennis and Hrvoje Ban for helping out!
This thread is locked; no one can reply to it. rss feed Print
Another "help with Allegro GUI"-type question
Elverion
Member #6,239
September 2005
avatar

I'v been searching through the GUI-related posts and see that many people are having trouble with the program closing due to do_dialog(). I also have this problem, but it only happens with d_menu_proc. d_slider_proc and d_text_proc work just fine, only d_menu_proc causes problems for me.

The dialog:

DIALOG file_menu[] =
{
   /* (proc)      (x) (y) (w)  (h) (fg) (bg) (key) (flags) (d1) (d2)   (dp)  (dp2) (dp3) */
   { d_menu_proc, 8,  24, 224, 16, 32,   97,   0,    0,      0,   0,   (void*)help_menu, NULL, NULL },
   { NULL,        0,  0,  0,   0,  0,   0,   0,    0,      0,   0,   NULL, NULL, NULL }
};

DIALOG dlg[] =
{
   /* (proc)      (x) (y) (w)  (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)        (dp2) (dp3) */
   { d_menu_proc, 8,  24, 224, 16, 32,   97,   0,    0,      0,   0,   file_menu, NULL, NULL },
   { NULL,        0,  0,  0,   0,  0,   0,   0,    0,      0,   0,   NULL,       NULL, NULL }
};

The callback:

int help_menu(void *dp3, int d2)
{
  //allegro_message("HELP MENU");
  return D_O_K;
}

I assume it has something to do with the callback. I created the dialog in "dlg" (the graphical Allegro GUI builder), so I think it's all correct. I'm not sure what would cause it to crash though, as nothing happens in it. It is declared as int, as it should be, and is casted to void * in the dialog, and I have the extra NULL line in there. Could it have something to do with the parameters of the callback?

--
SolarStrike Software - MicroMacro home - Automation software.

Hrvoje Ban
Member #4,537
April 2004
avatar

Allegro Manual said:

int d_menu_proc(int msg, DIALOG *d, int c);

The dp field points to an array of menu structures: see do_menu() for more information.

do_menu, MENU struct

Dennis
Member #1,090
July 2003
avatar

Quote:

I assume it has something to do with the callback.

As already pointed out by Hrvoje, there is no callback function expected at dp.

[append]more specifically: You're file_menu is a DIALOG array, while it should be a MENU array.

MENU file_menu[] =
{
   /* (text),(callback proc),(child),(flags),(dp) */
   // insert your menu entries here
};

DIALOG dlg[] =
{
   /* (proc)      (x) (y) (w)  (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)        (dp2) (dp3) */
   { d_menu_proc, 8,  24, 224, 16, 32,   97,   0,    0,      0,   0,   file_menu, NULL, NULL },
   { NULL,        0,  0,  0,   0,  0,   0,   0,    0,      0,   0,   NULL,       NULL, NULL }
};

Elverion
Member #6,239
September 2005
avatar

Yeah...apparently when I was reading the manual, I read it as an array of menu_proc's, not menu structs! Very stupid, I know. I've fixed it up, and it's now working. Thanks a lot guys, I appreciate it (even though you made me look like an idiot :P).

--
SolarStrike Software - MicroMacro home - Automation software.

Dennis
Member #1,090
July 2003
avatar

Quote:

Yeah...apparently when I was reading the manual, I read it as an array of menu_proc's, not menu structs!

...and then you decided to use an array of DIALOG...;D
Don't worry about it, sometimes everybody mixes something up. Nobody is perfect.

Go to: