Mouse click as Input.

// The question is that I want the "7" will be an output to other (2nd)box
//if you press left click mouse button in the 1st box.
// the problem is the output is already displayed in the 2nd box .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include<graphics.h>
#include <windows.h>


using namespace std;
int main()
{
    initwindow(500,500);
    setcolor(RED);
    setlinestyle(0,1,4);
    settextstyle (4,HORIZ_DIR,5);
    int x,y;


    rectangle(140,130,220,180);  outtextxy(160,135,"7");
    
    rectangle(240,130,320,180); 
    x=0;y=0;
    getmouseclick(WM_LBUTTONDOWN,x,y);
    if (x>240&&x<320,y>130,y<180)
    {
     outtextxy(260,135,"7");
    }

getch();
return 0;
}
Last edited on
What is <graphics.h>? It is not a standard C++ header.

By the way, <conio.h> is non-standard and you should not use it:
https://en.wikipedia.org/wiki/Conio.h
graphics.h is where we draw our fig.
Is it a header you made yourself, or is it a library you downloaded?
Last edited on
it is a library sir. for more info click the link below.
http://www.cs.colorado.edu/~main/bgi/dev-c++/
Topic archived. No new replies allowed.