/* Mouse Programming - part 1 by MyCFiles.com - Change The
Graphic “PATH” Befor Executing on line 214(like C:\\TC\\BGI) */
#include<graphics.h>
#include<stdio.h>
32766,// 0111111111111110 this mask is and’ed
32766,// 0111111111111110 with screen
32766,// 0111111111111110
32766,// 0111111111111110
32766,// 0111111111111110
32766,// 0111111111111110
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ GLOBAL VARS ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
BOOLEAN lPress = 0,rPress = 0;
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ BUTTON STRUCTURE ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
BOOLEAN isPressed,isReleased;
ÍÍÍÍÍÍÍÍÍÍÍ OUR MOUSE FUNCTIONS ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
==> better write a mouse.h out of these functions
asm mov ax , 00h // initialise mouse driver
asm mov ax , 01h // display mouse
void SlaveMouse(int x,int y,int xmax,int ymax) {
asm int 33h // slave in x and xmax
asm int 33h // slave in y and ymax
void ChangeCursor(unsigned Marr[8][4],int hx,int hy) {
unsigned sgm = FP_SEG(Marr); // get the segment
unsigned off = FP_OFF(Marr); // get the offset
asm mov bx , hx // our x hotspot
asm mov cx , hy // our y hotspot
asm mov ax , sgm // Load segment ...
asm mov es , ax // ...in es (remember mov es,off is not possible)
asm mov dx , off // Load dx with offset
void addButton(BUTTON b[],int size) {
int currentcolor = getcolor();
for(i = 0; i < size ; i++,b++ ) {
Maxx = b->xmax = x + textwidth(str);
Maxy = b->ymax = y + textheight(str);
line(x,y,Maxx+5,y); // First WHITE horizontal line
line(x,y+1,Maxx+5,y+1); // Second WHITE horizontal line
line(x,y,x,Maxy+5); // First WHITE verticle line
line(x-1,y,x-1,Maxy+5); // Second DARKGRAY verticle line
line(x+1,Maxy+4,Maxx+5,Maxy+4);// Double lined downward horizontal line
line(x,Maxy+5,Maxx+5,Maxy+5); // Downward DARKGRAY horizontal line
line(x,y,Maxx+5,y); // Third BLACK horizontal above line
line(Maxx+5,Maxy+5,Maxx+5,y); // Third verticle DARKGRAY line
int x= b->x,y=b->y,xmax =b->xmax,ymax=b->ymax;
int currentcolor = getcolor();
line(x,y,xmax+5,y); // First WHITE horizontal line
line(x,y+1,xmax+5,y+1); // Second WHITE horizontal line
line(x,y,x,ymax+5); // First WHITE verticle line
line(x,y,xmax+5,y); // First WHITE horizontal line
line(x,y+1,xmax+5,y+1); // Second WHITE horizontal line
line(x,y,x,ymax+5); // First WHITE verticle line
int Checkbutton(BUTTON *b,int size) {
for(i=0; i < size;i++,b++) {
GetStatus(); // get the current status of mouse
if(mX > b->x && mY > b->y &&
mX < b->xmax+5 && mY < b->ymax+5) {
if (lPress || rPress) { // if button clicked
Banim(b); // then animate
return i; // return the index of button clicked
else{ // blue out the button
outtextxy(b->x+4,b->y+3,b->Label);
delay(b->xmax-b->x); // to avoid flicker
outtextxy(b->x+4,b->y+3,b->Label);
void message(char *str) { // display our message
setfillstyle(SOLID_FILL,RED);
initgraph(&gd,&gm,"C:\\TC\\BGI"); /*add your bgi file path */
SetMouse(); // initialize and show mouse
settextstyle(SMALL_FONT,HORIZ_DIR,6);
/////////////////////////// FILL BUTTON STRUCTURE ////////////////////
b[0].x = 240;b[0].y = 50;
strcpy(b[0].Label," C ");
b[1].x = 250;b[1].y = 100;
strcpy(b[1].Label," C++ ");
b[2].x = 280; b[2].y = 150;
strcpy(b[2].Label," JAVA ");
b[3].x = 270; b[3].y = 205;
strcpy(b[3].Label," ASSEMBLY ");
b[4].x = 265;b[4].y = 260;
strcpy(b[4].Label," MY C FILES ");
b[5].x = 570;b[5].y = 10;
strcpy(b[5].Label,"exit");
addButton(b,6); // add Button’s to Screen
ChangeCursor(mouse,3,4); // change default cursor
//////////////////////// SOMEWHAT O..K POLLING //////////////////////
x = Checkbutton(b,6); // get the button index
case 0: message("you liked C");
case 1: message("you liked C++");
case 2: message("you liked JAVA");
case 3: message("you liked ASSEMBLY ");
case 4: message("you liked MY C FILES");
closegraph(); // don’t forget
3 comments:
Hey man i like your works. i have add your site links in my bookmarks widgets of my sites as "some more stuff on C programming language"
on http://shareprogrammingtips.com/
Thank you jiagr.. :)
check out....http://c-gui-thunderbolt.page.tl/C-GUI-Home.htm
Post a Comment