Ejemplo n.º 1
1
// 为窗口设置新的尺寸
func win_handler_sizeTo(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
	fmt.Println("win_handler_sizeTo")
	width := cef.V8ValueToInt32(args[0])
	height := cef.V8ValueToInt32(args[1])

	h := win.HWND(browser.GetWindowHandle())
	var rect win.RECT
	win.GetWindowRect(h, &rect)

	fmt.Printf("win_handler_sizeTo Left=%v,Right=%v,Width=%v,Height=%v\n", rect.Left, rect.Top, width, height)
	win.MoveWindow(h, rect.Left, rect.Top, width, height, true)

	//result = 1

	return
}
Ejemplo n.º 2
0
// 为窗口设置新的位置
func win_handler_moveTo(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
	fmt.Println("win_handler_moveTo")
	left := cef.V8ValueToInt32(args[0])
	top := cef.V8ValueToInt32(args[1])

	fmt.Printf("win_handler_moveTo left=%v,top=%v\n", left, top)

	h := win.HWND(browser.GetWindowHandle())

	var rect win.RECT
	win.GetWindowRect(h, &rect)
	width := int32(rect.Right - rect.Left)
	height := int32(rect.Bottom - rect.Top)

	fmt.Printf("win_handler_moveTo Left=%v,Right=%v,Width=%v,Height=%v\n", left, top, width, height)
	win.MoveWindow(h, left, top, width, height, true)

	return
}
Ejemplo n.º 3
0
Archivo: ngui.go Proyecto: CodyGuo/ngui
func TransparentWndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
	switch msg {
	case win.WM_CREATE:
		//a := *(*uintptr)(unsafe.Pointer(lParam))
		//fmt.Printf("WM_CREATE %v\n", a)
		result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	//case win.WM_NCPAINT:
	//	result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	case win.WM_LBUTTONDOWN:
		//fmt.Printf("WM_LBUTTONDOWN\n")
		if isEnableDrag {
			win.SetCapture(hwnd)

			win.GetWindowRect(hwnd, &rcWindow)
			win.GetCursorPos(&dragPoint)

			isDrag = true
		}
		result = 0
	case win.WM_LBUTTONUP:
		if win.GetCapture() == hwnd {
			win.ReleaseCapture()
		}
		isDrag = false
		result = 0
	case win.WM_NCCALCSIZE:
		wpCaptionLess := uintptr(win.GetProp(hwnd, WindowProp_CaptionLess))
		//fmt.Printf("wpCaptionLess=%v\n", wpCaptionLess)
		if wpCaptionLess == 1 && win.BOOL(wParam) == win.TRUE {
			var size_param *win.NCCALCSIZE_PARAMS = (*win.NCCALCSIZE_PARAMS)(unsafe.Pointer(lParam))
			size_param.Rgrc[2] = size_param.Rgrc[1]
			size_param.Rgrc[1] = size_param.Rgrc[0]
			result = 0
		} else {
			result = win.DefWindowProc(hwnd, msg, wParam, lParam)
		}
	//case win.WM_NCHITTEST:
	//x := win.LOWORD(uint32(lParam))
	//y := win.HIWORD(uint32(lParam))
	//s := fmt.Sprintf("WM_NCHITTEST x,y=%v,%v\n", x, y)

	//result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	case win.WM_MOUSEMOVE:
		//fmt.Printf("WM_MOUSEMOVE\n")
		if isDrag {
			var pe win.POINT
			win.GetCursorPos(&pe) // The new position for cursor pointer

			left := rcWindow.Left + (pe.X - dragPoint.X) // The horizontal position of the new window
			top := rcWindow.Top + (pe.Y - dragPoint.Y)   // The vertical position of the new windows

			//win.MoveWindow(hwnd,reWindow.Left,reWindow.Top,reWindow.Right,reWindow.Bottom,true);// Moving window
			win.SetWindowPos(hwnd, 0, left, top, 0, 0, win.SWP_NOSIZE|win.SWP_NOZORDER)
		}
	case win.WM_SIZE:
		// 最小化时不能调整Cef窗体,否则恢复时界面一片空白
		if wParam == win.SIZE_RESTORED || wParam == win.SIZE_MAXIMIZED {
			cef.WindowResized(unsafe.Pointer(hwnd))
		}
	case win.WM_CLOSE:
		win.DestroyWindow(hwnd)
	case win.WM_DESTROY:
		cef.QuitMessageLoop()
	default:
		result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	}
	//result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	return
}
Ejemplo n.º 4
0
func (w *WindowBase) Bounds() Rect {
	var rect win.RECT
	win.GetWindowRect(w.hwnd, &rect)
	return rectFromRECT(rect)
}