www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/16/20:45:19

From: "23yrold3yrold" <cbarry AT pangea DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Allegro GUI query
Date: Sat, 16 Sep 2000 19:28:19 -0500
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
NNTP-Posting-Host: spamkiller
Message-ID: <39c41012_4@spamkiller.newsfeeds.com>
X-Comments: This message was posted through Newsfeeds.com
X-Comments2: IMPORTANT: Newsfeeds.com does not condone, nor support, spam or any illegal or copyrighted postings.
X-Comments3: IMPORTANT: Under NO circumstances will postings containing illegal or copyrighted material through this service be tolerated!!
X-Report: Please report illegal or inappropriate use to <abuse AT newsfeeds DOT com> You may also use our online abuse reporting from: http://www.newsfeeds.com/abuseform.htm
X-Abuse-Info: Please be sure to forward a copy of ALL headers, INCLUDING the body (DO NOT SEND ATTACHMENTS)
Organization: Newsfeeds.com http://www.newsfeeds.com 73,000+ UNCENSORED Newsgroups.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019