Mail Archives: djgpp/2000/09/17/03:58:59
Yep, the problem is a _pain_, but it's obvious.
In your DIALOG definition table, you copy the uninitialised value of Bmp
into the d_icon_proc() record. It's only later that Bmp gets set to what
you want. d_icon_proc() is still referring to the junk value it started out
with.
Solution: Before you call do_dialog(), you need to have a line like (in this
case):
the_dialog[5].dp = Bmp;
I know how annoying it is, trust me! But there's not really much you can do
about it without radically changing your program.
Edmund.
"23yrold3yrold" <cbarry AT pangea DOT ca> wrote in message
news:39c41012_4 AT spamkiller DOT newsfeeds DOT com...
> Hello. Can anyone skim the following code and tell me why the d_icon_proc
> won't display the Bmp as it's icon? According to Allegro's docs this
should
> work easily. Thank you.
>
>
> Chris
>
>
> #include <stdlib.h>
> #include <stdio.h>
> #include <allegro.h>
>
> #define White makecol16(255, 255, 255)
> #define Black makecol16( 0, 0, 0)
>
> BITMAP *Bmp;
> PALETTE pal;
>
> /* for the d_edit_proc() object */
> char the_string[32] = "Change Me!";
>
>
> /* callback function to specify the contents of the listbox */
> char *listbox_getter(int index, int *list_size)
> {
> static char *strings[] =
> {
> "Zero", "One", "Two", "Three", "Four", "Five",
> "Six", "Seven", "Eight", "Nine", "Ten"
> };
>
> if (index < 0) {
> *list_size = 11;
> return NULL;
> }
> else
> return strings[index];
> }
>
>
> DIALOG the_dialog[] =
> {
> /*(dialog proc) (x) (y) (w) (h) (fg) (bg) (key)
> (flags) (d1) (d2) (dp) (dp2)
> (dp3) */
> { d_clear_proc, 0, 0, 0, 0, Black, White, 0, 0,
> 0, 0, NULL, NULL, NULL },
> { d_edit_proc, 80, 32, 512, 48, Black, White, 0, 0,
> sizeof(the_string)-1, 0, the_string, NULL, NULL },
> { d_button_proc, 80, 132, 160, 48, Black, White, 't', 0,
> 0, 0, (char*)"&Toggle Me", NULL, NULL },
> { d_list_proc, 360, 100, 206, 206, Black, White, 0, 0,
> 0, 0, listbox_getter, NULL, NULL },
> { d_button_proc, 80, 400, 160, 48, Black, White, 0,
> D_EXIT, 0, 0, (char*)"This program sucks", NULL,
> NULL },
> { d_icon_proc, 360, 400, 160, 48, Black, Black, 0,
> D_EXIT, 0, 0, Bmp, NULL,
> NULL },
> { NULL, 0, 0, 0, 0, Black, White, 0, 0,
> 0, 0, NULL, NULL, NULL }
> };
>
>
> int main(int argc, char *argv[])
> {
> int ret;
>
> /* initialise everything */
> allegro_init();
> install_keyboard();
> install_mouse();
> install_timer();
> set_color_depth(16);
> set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
>
> Bmp = load_bitmap("Test Icon.bmp", pal);
>
> /* do the dialog */
> ret = do_dialog(the_dialog, -1);
>
> destroy_bitmap(Bmp);
>
> return 0;
> }
>
>
>
- Raw text -