Mouse position: Difference between revisions

Content added Content deleted
m (→‎{{header|Rust}}: Update to Rust 0.9)
Line 653: Line 653:
Prints current location of the mouse cursor relative to any active window.
Prints current location of the mouse cursor relative to any active window.
This example relies on the Windows API.
This example relies on the Windows API.
<lang Rust>// rust 0.9-pre
<lang Rust>// rustc 0.9 (7613b15 2014-01-08 18:04:43 -0800)


use std::libc::types::os::arch::extra::{BOOL, HANDLE};
use std::libc::{BOOL, HANDLE, LONG};
use std::ptr::mut_null;
use std::ptr::mut_null;


type LONG = i32;
type HWND = HANDLE;
type HWND = HANDLE;


Line 669: Line 668:
#[link_name = "user32"]
#[link_name = "user32"]
extern "system" {
extern "system" {
pub fn GetCursorPos(lpPoint:&mut POINT) -> BOOL;
fn GetCursorPos(lpPoint:&mut POINT) -> BOOL;
pub fn GetForegroundWindow() -> HWND;
fn GetForegroundWindow() -> HWND;
pub fn ScreenToClient(hWnd:HWND, lpPoint:&mut POINT);
fn ScreenToClient(hWnd:HWND, lpPoint:&mut POINT);
}
}