0% found this document useful (0 votes)
76 views1 page

Mouse PDF

The document contains code for two C++ classes - a button class and a ball class. The button class defines functions to position a button on screen and check for mouse clicks within the button area. The ball class contains a main function that initializes a graphics window, defines a ball object and button object, and animates the ball by changing its position and checking if the button is clicked to end the program.

Uploaded by

fernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views1 page

Mouse PDF

The document contains code for two C++ classes - a button class and a ball class. The button class defines functions to position a button on screen and check for mouse clicks within the button area. The ball class contains a main function that initializes a graphics window, defines a ball object and button object, and animates the ball by changing its position and checking if the button is clicked to end the program.

Uploaded by

fernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Nombre de archivo: boton.h Pelota .

cpp

#include <cstdlib> #include <cstdlib>


#include <graphics.h> #include <graphics.h>
#include <windows.h> #include <windows.h>
using namespace std; #include "boton.h"
using namespace std;
class boton
{ int main()
int xi, xf, yi, yf; { boton a;
public: int x=3,xi=4,y=3,yi=4;
void posicion (int a, int b, int c, int d) initwindow(700,500);
{ xi=a; xf=c; yi=b; yf=d;} setbkcolor(1); cleardevice();

int prueba (void) while(true)


{ if (mousex()>xi&&mousex()<xf&&mousey()>yi&&mousey()<yf&&ismouseclick(WM_LBUTTONDOWN)) {
{ clearmouseclick(WM_LBUTTONDOWN); clearmouseclick(WM_MOUSEMOVE); return 1; }
else { clearmouseclick(WM_LBUTTONDOWN); clearmouseclick(WM_MOUSEMOVE); return 0;} if(x>640||x<1) {xi=-xi;}
} if(y>440||y<1) {yi=-yi;}
x+=xi; y+=yi;
void estado(char *nom, char *nom2)
{ a.posicion(1+x,1+y,60+x,60+y);
If (mousex()>xi && mousex()<xf && mousey()>yi && mousey()<yf) a.estado("pelota.bmp","pelota.bmp");
{ readimagefile (nom, xi, yi, xf, yf); } if(a.prueba()) {break;}
else { readimagefile (nom2,xi,yi,xf,yf);}
} }
};
}

/*
void clearmouseclick( int kind );
void clearresizeevent( );
void getmouseclick( int kind, int& x, int& y );
bool ismouseclick( int kind );
bool isresizeevent( );
int mousex( );
int mousey( );
void registermousehandler( int kind, void h( int, int ) );
void setmousequeuestatus( int kind, bool status=true );

* WM_MOUSEMOVE -- mouse movement


* WM_LBUTTONDBLCLK -- left mouse button double-click
* WM_LBUTTONDOWN -- left mouse button pushed down
* WM_LBUTTONUP -- left mouse button released up
* WM_MBUTTONDBLCLK -- middle mouse button double-click (might not work!)
* WM_MBUTTONDOWN -- middle mouse button pushed down (might not work!)
* WM_MBUTTONUP -- middle mouse button released up (might not work!)
* WM_RBUTTONDBLCLK -- right mouse button double-click
* WM_RBUTTONDOWN -- right mouse button pushed down
* WM_RBUTTONUP -- right mouse button released up
*/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy