From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro 2.0 and Mouse Date: Mon, 30 Dec 1996 20:55:51 +0000 Organization: None Lines: 70 Distribution: world Message-ID: <7sqNMZBXxCyyEwkc@talula.demon.co.uk> References: <3 DOT 0 DOT 32 DOT 19961224121328 DOT 006a2c4c AT dataplusnet DOT com> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp >I have allegro 2.0. When I write a program that uses the mouse, I run it >in a ms-dos window, I get a message that the program would run better in >MS-DOS mode. It asks if it should make a shortcut so it always runs in >MS-DOS mode. There is a yes and no button and when I click no, it works >fine. Is there anyway to prevent this from happening? I recently worked out a way to avoid this message, having finally got win95 so I could experiment with it :-) The problem is with the timer code, not the mouse, and the solution is to change the timer routines so that the clock is locked at a fixed frequency rather than adjusting to whenever interrupts are required. This reduces the timer accuracy to 1/200th of a second, but makes everything run much more smoothly in a DOS box (under clean DOS I'm still using the old, more accurate code). This improvement will be in the next release of Allegro. If you can't wait until then, grab the work-in-progress version from: http://www.talula.demon.co.uk/allegro/wip.html >Another question: Lets say I have a button in the top left corner of the >screen (0,0),(20,20). How would I program it so that to click the button >you would have to left click and release in the button inside the button >range for it to go. I have tried a way that tests if it is in the box >range and if the left button is pressed. Is there a different way? The easiest way to do something like that is to make a new object procedure, but base it on one of the existing ones, eg. d_button_proc(). I think this does what you want - it handles the click message itself, but uses the standard button object to do all the drawing and keyboard input processing. int my_button_proc(int msg, DIALOG *d, int c) { /* special handling for click messages */ if (msg == MSG_CLICK) { /* ignore the click if it isn't with the left button */ if (!(mouse_b & 1)) return D_O_K; /* select the button and redraw ourselves */ d->flags |= D_SELECTED; show_mouse(NULL); SEND_MESSAGE(d, MSG_DRAW, 0); show_mouse(screen); /* while the button is held, make sure the mouse stays over the button */ while (mouse_b & 1) { if ((mouse_x < d->x) || (mouse_x >= d->x + d->w) || (mouse_y < d->y) || (mouse_y >= d->y + d->h)) { /* canceled? deselect the button and return... */ d->flags &= ~D_SELECTED; show_mouse(NULL); SEND_MESSAGE(d, MSG_DRAW, 0); show_mouse(screen); return D_O_K; } } /* we have been clicked! */ return D_CLOSE; } /* pass other messages through to the standard button object */ return d_button_proc(msg, d, c); } /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */