我有一个名为“Skylines”的窗口,我想在这个窗口内获取鼠标点击的坐标。我想将它们写在窗口的标题上,但我不明白在释放鼠标按钮后如何更改窗口的名称。
现在我已经这样做了:
void mouseOnSkylines(int evt, int x, int y, int flags, void* param)
{
char sWindowName[100];
HWND hWnd, hPar;
switch(evt)
{
case CV_EVENT_LBUTTONDOWN:
hWnd = (HWND)cvGetWindowHandle("Skylines");
hPar = GetParent(hWnd);
sprintf(sWindowName, "(%d, %d)", x, y);
SetWindowText(hPar, sWindowName);
break;
case CV_EVENT_LBUTTONUP:
hWnd = (HWND)cvGetWindowHandle("Skylines");
hPar = GetParent(hWnd);
sprintf(sWindowName, "Skylines");
SetWindowText(hPar, sWindowName);
}
}
怎样才能做得更好?