मैं इस तरह कोड लिखने में सक्षम होना चाहता हूँ:मैं विंडो के क्लाइंट रेक्ट के सापेक्ष नियंत्रण की स्थिति कैसे प्राप्त करूं?
HWND hwnd = <the hwnd of a button in a window>;
int positionX;
int positionY;
GetWindowPos(hwnd, &positionX, &positionY);
SetWindowPos(hwnd, 0, positionX, positionY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
और यह कुछ भी नहीं है। हालांकि, मैं बाहर काम नहीं कर सकता है कि कैसे एक GetWindowPos()
समारोह है कि मुझे सही इकाइयों में जवाब देता देता है लिखने के लिए:
void GetWindowPos(HWND hWnd, int *x, int *y)
{
HWND hWndParent = GetParent(hWnd);
RECT parentScreenRect;
RECT itemScreenRect;
GetWindowRect(hWndParent, &parentScreenRect);
GetWindowRect(hWnd, &itemScreenRect);
(*x) = itemScreenRect.left - parentScreenRect.left;
(*y) = itemScreenRect.top - parentScreenRect.top;
}
अगर मैं इस सुविधा का उपयोग, मैं निर्देशांक कि के सापेक्ष हैं पाने के ऊपरी बाएं भाग माता पिता की खिड़की, लेकिन SetWindowPos()
शीर्षक पट्टी के नीचे वाले क्षेत्र के सापेक्ष निर्देशांक चाहता है (मुझे लगता है कि यह "क्लाइंट एरिया" है, लेकिन Win32 शब्दावली मेरे लिए बिल्कुल नया है)।
समाधान यह काम कर GetWindowPos()
समारोह (धन्यवाद Sergius) है:
void GetWindowPos(HWND hWnd, int *x, int *y)
{
HWND hWndParent = GetParent(hWnd);
POINT p = {0};
MapWindowPoints(hWnd, hWndParent, &p, 1);
(*x) = p.x;
(*y) = p.y;
}
क्या यह एक विंडो अनुप्रयोग है –
यह कैसे काम करता है, डायरेक्टएक्स का उपयोग क्या है। डायरेक्टएक्स में न्यूबी। मैंने यह –
करने के लिए अपना स्वयं का कार्य किया है हां यह एक विंडोज़ एप्लीकेशन है, इसलिए Win32 api का उपयोग। – Andy