diff --git a/newctrl/container_windows.c b/newctrl/container_windows.c index bdb2e08..7910b92 100644 --- a/newctrl/container_windows.c +++ b/newctrl/container_windows.c @@ -57,6 +57,15 @@ HWND newContainer(void) return hwnd; } +RECT containerBounds(HWND hwnd) +{ + RECT r; + + if (GetClientRect(hwnd, &r) == 0) + xpanic("error getting container client rect for container.bounds()", GetLastError()); + return r; +} + void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY, LONG *internalLeading) { HDC dc; diff --git a/newctrl/container_windows.go b/newctrl/container_windows.go index 5a0336d..31963e0 100644 --- a/newctrl/container_windows.go +++ b/newctrl/container_windows.go @@ -57,6 +57,11 @@ func (c *container) parent() *controlParent { return &controlParent{c.hwnd} } +func (c *container) bounds(d *sizing) (int, int, int, int) { + r := C.containerBounds(c.hwnd) + return int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top) +} + // For Windows, Microsoft just hands you a list of preferred control sizes as part of the MSDN documentation and tells you to roll with it. // These sizes are given in "dialog units", which are independent of the font in use. // We need to convert these into standard pixels, which requires we get the device context of the OS window. diff --git a/newctrl/winapi_windows.h b/newctrl/winapi_windows.h index c045f70..e6858e5 100644 --- a/newctrl/winapi_windows.h +++ b/newctrl/winapi_windows.h @@ -125,6 +125,7 @@ extern void tableSelectItem(HWND, intptr_t); #define containerclass L"gouicontainer" extern DWORD makeContainerWindowClass(char **); extern HWND newContainer(); +extern RECT containerBounds(HWND); extern void calculateBaseUnits(HWND, int *, int *, LONG *); // area_windows.c