aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/win32/ffi.rs6
-rw-r--r--src/win32/mod.rs24
2 files changed, 28 insertions, 2 deletions
diff --git a/src/win32/ffi.rs b/src/win32/ffi.rs
index 4a3ce7e..857b838 100644
--- a/src/win32/ffi.rs
+++ b/src/win32/ffi.rs
@@ -603,6 +603,9 @@ extern "system" {
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162719(v=vs.85).aspx
pub fn FillRect(hDC: HDC, lprc: *const RECT, hbr: HBRUSH) -> libc::c_int;
+ // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx
+ pub fn GetClientRect(hWnd: HWND, lpRect: *mut RECT) -> BOOL;
+
// http://msdn.microsoft.com/en-us/library/dd144871(v=vs.85).aspx
pub fn GetDC(hWnd: HWND) -> HDC;
@@ -618,6 +621,9 @@ extern "system" {
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx
pub fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> *const libc::c_void;
+ // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx
+ pub fn GetWindowRect(hWnd: HWND, lpRect: *mut RECT) -> BOOL;
+
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx
pub fn LoadLibraryW(lpFileName: LPCWSTR) -> HMODULE;
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index b5e507b..8f3ae91 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -222,11 +222,31 @@ impl Window {
}
pub fn get_inner_size(&self) -> (uint, uint) {
- unimplemented!()
+ use std::{mem, os};
+ let mut rect: ffi::RECT = unsafe { mem::uninitialized() };
+
+ if unsafe { ffi::GetClientRect(self.window, &mut rect) } == 0 {
+ fail!("GetClientRect failed: {}", os::error_string(os::errno() as uint));
+ }
+
+ (
+ (rect.right - rect.left) as uint,
+ (rect.bottom - rect.top) as uint
+ )
}
pub fn get_outer_size(&self) -> (uint, uint) {
- unimplemented!()
+ use std::{mem, os};
+ let mut rect: ffi::RECT = unsafe { mem::uninitialized() };
+
+ if unsafe { ffi::GetWindowRect(self.window, &mut rect) } == 0 {
+ fail!("GetWindowRect failed: {}", os::error_string(os::errno() as uint));
+ }
+
+ (
+ (rect.right - rect.left) as uint,
+ (rect.bottom - rect.top) as uint
+ )
}
pub fn set_inner_size(&self, x: uint, y: uint) {