Hi i'm trying out some mouse routines...can someone help me as im sorta stuck, im trying to click a particular colour using the mouse and set it as the current colour in the program i'm creating...i've been trying for 9 hours and im not getting any further than when i started. i've got the mouse routines all srted its just linking them together...would anyone be able to help out or even direct me in the right direction as i am really stuck. thanks![]()
Basically when the mouse clicks the colours the coordinates are to be returned and compared with the colour coordinates and set accordingly....but its not working!!!
Code:#include <stdio.h> #include <conio.h> #include <graphics.h> #include <dos.h> #include <stdlib.h> #define MOUSE 0x33 #define INITIALISE 0x00 #define ON 0x01 #define OFF 0x02 void Colour_Selection (void); void Init_Mouse (void); void Cursor_On (void); void Init_Graphics (void); void Mouse_Coord(int*, int*); int buttclicked(); int LeftButtonPressed; void main (void){ int *x, *y; Init_Graphics(); Init_Mouse(); //initialises the mouse Cursor_On(); //switches cursor on Colour_Selection(); buttclicked(); if(LeftButtonPressed){ } //closegraph(); getch(); } void Init_Graphics (void){ int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver, &gmode,"\\tc\\bgi"); errorcode = graphresult(); if(errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt"); } } void Colour_Selection (void){ int x, y, colour; colour = 0; for(x=1; x<9; x++){ setfillstyle(1,0); bar(22+(x*40),441,-8+(x*40),422); setfillstyle(1,colour); bar(20+(x*40),440,-10+(x*40),420); colour++; setfillstyle(1,0); bar(22+(x*40),471,-8+(x*40),452); setfillstyle(1,colour); bar(20+(x*40),470,-10+(x*40),450); colour++; } } void Init_Mouse(void) { union REGS regs; regs.x.ax = INITIALISE; int86(MOUSE, ®s, ®s); } void Cursor_On (void) { union REGS regs; regs.x.ax = ON; int86(MOUSE, ®s, ®s); } void Mouse_Coord(int *x,int*y) { union REGS regs; regs.x.ax=3; int86(0x33,®s,®s); if(regs.x.bx&1) LeftButtonPressed=1; else LeftButtonPressed=0; *x=regs.x.cx; *y=regs.x.dx; } int buttclicked() { union REGS regs; regs.x.ax=3; int86(0x33,®s,®s); return regs.x.bx; }



LinkBack URL
About LinkBacks




