C++ Programming Blog

 
 
 
#include <conio.h>
#include<win_mous.cpp>// Needed for mouse & win functions
#define OK (x>=170 && x<=210 && y>=290 && y<=310)
#define CANCEL (x>=280 && x<=330 && y>=290 && y<=310)
#define PUSHME (x>=170 && x<=330 && y>=150 && y<=250)
int x,y,b;
void Press(int sx,int sy,int ex,int ey)
{
 hidemouse();
 Button(\"\",sx,sy,ex,ey,PUSH);
 showmouse();
 while(b==1)
 getmouse(&b,&x,&y);
 hidemouse();
 Button(\"\",sx,sy,ex,ey,UNPUSH);
 showmouse();
}
void main()
{
 G();
 setfillstyle(1,3);
 bar(0,0,640,480);
 Win(\"Windows 98\",100,100,430,370,1);
 Button(\"Ok\",170,290,210,310,DRAW);
 Button(\"Cancel\",280,290,330,310,DRAW);
 Button(\"Push Me\",170,150,330,250,DRAW);
 showmouse();
 while(!kbhit())
 {
 getmouse(&b,&x,&y);
 if(b==1)
 {
    if OK
    {
        Press(170,290,210,310);
        break;
    }
    if CANCEL
    {
        Press(280,290,330,310);
        break;
    }
    if PUSHME  Press(170,150,330,250);
 }
 }
 closegraph();
}

 
 
Didn't find what you were looking for? Find more on Program of simple windows & buttons