From: "Edmund Horner" Newsgroups: comp.os.msdos.djgpp References: <39c41012_4 AT spamkiller DOT newsfeeds DOT com> Subject: Re: Allegro GUI query Lines: 110 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Organization: Paradise Net Message-ID: <969175865.827425@shelley.paradise.net.nz> Cache-Post-Path: shelley.paradise.net.nz!unknown AT 203-79-93-177 DOT tnt11 DOT paradise DOT net DOT nz X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/) Date: Sun, 17 Sep 2000 19:33:27 +1200 NNTP-Posting-Host: 203.96.152.26 X-Complaints-To: newsadmin AT xtra DOT co DOT nz X-Trace: news.xtra.co.nz 969175866 203.96.152.26 (Sun, 17 Sep 2000 19:31:06 NZST) NNTP-Posting-Date: Sun, 17 Sep 2000 19:31:06 NZST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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" 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 > #include > #include > > #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; > } > > >