Example #1
0
// Get the current position of the mouse in desktop coordinates
func getMousePosition() (x, y int) {
	x, y = -1, -1
	var point C.POINT
	if C.__GetCursorPos(&point) == 0 {
		C.GetLastError()
		return
	}
	return int(point.x), int(point.y)
}
Example #2
0
// Get the current position of the mouse in window coordinates
func (wi *windowInternal) getMousePosition() (x, y int, err ThreadError) {
	if !wi.window.IsValid() {
		// TODO ERROR
		return
	}

	var point C.POINT
	if C.__GetCursorPos(&point) == 0 {
		err = NewThreadError(fmt.Errorf("GetCursorPos (%d)", C.GetLastError()), false)
		return
	}

	if C.__ScreenToClient(wi.window.Handle, &point) == 0 {
		err = NewThreadError(fmt.Errorf("ScreenToClient (%d)", C.GetLastError()), false)
		return
	}
	return int(point.x), int(point.y), nil
}