Hi, I have a POINT and a set of data get from a vector function that contained hwnd and rect.
std::vector<VECDATA> vecListData;
myVec->emplace_back(VECDATA(hwnd, rect));
1 2 3 4
for (UINT i = 0; i < vecListData.size(); i++) {
//do the stuff
}
I would like to get the hwnd based on which rect (rect.left & rect.top) is the nearest to POINT (pt.x & pt.y). Generally, is to compare which object is the nearest object to the POINT.
To know which object is the nearest, each of the rect will have a subtraction with the POINT. Then, store the results as a set of values. At the end, we get the hwnd based on the minimum value.
Is it possible? Any idea? I'm using Visual Studio 2008, Visual C++ MFC Application.
I'm not sure how to define this line to get the largest distance (rect center and point) among those vector data. Since the calculation only start in for loop? Sorry I'm not sure how to apply the numeric_limits.