I've just recently learned how to get my mouse position but if I move my window it is having a problem. Example, I want to draw a dot in the position of the mouse coordinate (x = 100, y = 100) so the system will draw at that coordinate in the window and that's the problem because, the mouse position is read according to the position of the SCREEN instead of the WINDOW. If I can somehow get the mouse coordinate according to the window instead of the screen that would fix the problem.
#include<graphics.h>
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
initwindow(800,600);
POINT CursorPosition;
while(1)
{
GetCursorPos(&CursorPosition);
cout << CursorPosition.x << endl;
cout << CursorPosition.y << endl;
if(GetAsyncKeyState(VK_LBUTTON)) {
bar(CursorPosition.x, CursorPosition.y, CursorPosition.x+50,
CursorPosition.y+50);
}
delay(5);
Sleep(5);
system("cls");
}
}