Esempio n. 1
0
// 移动窗口
func win_handler_startDrag(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
	fmt.Println("win_handler_startDrag")

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

	var pt win.POINT
	win.GetCursorPos(&pt)

	isDrag = true

	win.PostMessage(h, win.WM_LBUTTONDOWN, win.HTCAPTION, uintptr(win.MAKELONG(uint16(pt.X), uint16(pt.Y))))

	return
}
Esempio n. 2
0
File: ngui.go Progetto: 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
}