新手hello world,获得鼠标相对坐标求助

#include"stdio.h"
#include"stdlib.h"
#include"windows.h"
int main()
{
	SetConsoleTitle("Hello,world!");
	POINT*ptrpos=(POINT*)malloc(sizeof(POINT));
	LPRECT rect=(LPRECT)malloc(sizeof(LPRECT));
	HWND hwdn=FindWindow(NULL,"Hello,world!");
	while(1)
	{
		Sleep(500);
		GetWindowRect(hwdn,rect);
		GetCursorPos(ptrpos);
		printf("%d\n",ptrpos->x-rect->left);
	}
}

我想得到光标相对于窗口的横坐标,但是这样输出是负的,弱弱地求助下

可以再获取窗口的坐标,两个坐标做一个减法,就得到光标在窗口中的位置了

修改如下:

#include"stdio.h"
#include"stdlib.h"
#include"windows.h"
#include <tchar.h>
int main()
{
	TCHAR tit[50];
	_tcscpy(tit,_TEXT("Hello,world!"));
	SetConsoleTitle(tit);
	POINT*ptrpos=(POINT*)malloc(sizeof(POINT));
	LPRECT rect=(LPRECT)malloc(sizeof(LPRECT));
	HWND hwdn=FindWindow(NULL,tit);
	while(1)
	{
		Sleep(500);
		GetWindowRect(hwdn,rect);
		GetCursorPos(ptrpos);
		printf("%d\n",ptrpos->x-rect->left);
	}
}