delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/10/09:56:19

From: "Paul Bibbings" <paul DOT bibbings AT tesco DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: clear_to_color(); function
Date: Thu, 10 Feb 2000 02:49:44 -0000
Organization: Tesco ISP
Lines: 95
Message-ID: <87t9o1$fns$1@epos.tesco.net>
References: <9M1o4.14156$oU2 DOT 2450805 AT tw12 DOT nn DOT bcandid DOT com>
NNTP-Posting-Host: dialup.62-172-26-7.tesco.net
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Brian <none AT none DOT com> wrote in message
news:9M1o4.14156$oU2 DOT 2450805 AT tw12 DOT nn DOT bcandid DOT com...
> I posted a message a while back ("My program's a machine killer") about my
> machine rebooting when using the clear_to_color() function.  Someone
replied
> saying that the code worked fine on their machine, but when I run it on my
> computer, it reboots. It didn't start doing this until I started playing
> with the clear_to_color() function. The code is below. Anybody have any
idea
> why this is happening? Anybody else have the same problem?
>

I can't generate the problem of rebooting, but there were problems getting
your code to work properly on my computer, some quite superficial.
    In the first place you clear to color 0 and then set the foreground
colour in the dialogue to 0. On my computer, that's a black screen!
    Also, you have an insufficient number of arguments in the dialog
itself - you're missing dp2 and dp3.
    Then there's your declaration of main(int argc) which ought to be
main(int argc, char *argv[]), although you don't make any use of command
line arguments anyway. The #define LISTBOX_OBJECT 3 is redundant too.
Likewise you make no use of the variable ret, so you don't need it. (I guess
a lot of these are leftovers from having trimmed your code to it's simplest
while still keeping the problem).
    That said, the following seems to work okay on my computer.

regards,
Paul.


#include <stdio.h>
#include <stdlib.h>

#include "allegro.h"

   char *listbox_getter(int index, int *list_size)


      static char *strings[] =
      {
      "Entry 1", "Entry 2", "Entry 3"
      };

      if (index < 0)
      {
         *list_size = 3;
         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_list_proc,    0,      100,    320,    100,   10,      255,    0,
0,
     0,      0,  listbox_getter, NULL, NULL },

   { NULL,           0,      0,      0,      0,      0,      0,      0,
0,
     0,      0,      NULL, NULL, NULL }
   };

/*#define LISTBOX_OBJECT      3*/

   int main()
   {
      int ret;

      allegro_init();
      install_keyboard();
      if(set_gfx_mode(GFX_VGA, 320, 200, 0, 0) != 0)
      {
         allegro_exit();
         printf("Error setting graphics mode\n%s\n\n", allegro_error);
         return 1;
      }

      clear_to_color(screen, 7);
      ret = do_dialog(the_dialog, -1);

      readkey();

      allegro_exit();

      return 0;
   }




- Raw text -


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