Exemplo n.º 1
0
// 恢复窗口
func win_handler_restore(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
	fmt.Println("win_handler_restore")

	h := win.HWND(browser.GetWindowHandle())
	win.ShowWindow(h, win.SW_RESTORE)

	return
}
Exemplo n.º 2
0
// 最大化窗口
func win_handler_maximize(browser *cef.Browser, args []cef.V8Value) (result interface{}) {
	fmt.Println("win_handler_maximize")

	h := win.HWND(browser.GetWindowHandle())
	win.ShowWindow(h, win.SW_MAXIMIZE)

	return
}
Exemplo n.º 3
0
func win_start_browser(browser *cef.Browser, message *cef.CefProcessMessage) interface{} {
	fmt.Printf("win_start_browser\n")
	handle := browser.GetWindowHandle()
	openerHandle := browser.GetOpenerWindowHandle()
	rootHandle := browser.GetRootWindowHandle()
	fmt.Printf("win_start_browser handle=%v openerHandle=%v rootHandle=%v\n", handle, openerHandle, rootHandle)
	win.ShowWindow(win.HWND(rootHandle), win.SW_MAXIMIZE)
	return 0
}
Exemplo n.º 4
0
func (w *WindowBase) SetVisible(value bool) {
	var cmd int32
	if value {
		cmd = win.SW_SHOW
	} else {
		cmd = win.SW_HIDE
	}
	win.ShowWindow(w.hwnd, cmd)
}
Exemplo n.º 5
0
Arquivo: main.go Projeto: CodyGuo/gapp
func createWindow() win.HWND {
	var dwExStyle, dwStyle uint32 = 0, 0

	dwStyle = win.WS_OVERLAPPEDWINDOW

	if !manifest.FormFixed() {
		dwStyle |= win.WS_SIZEBOX
	}

	// 获取屏幕宽度和高度
	var x, y int32
	var width, height int32

	width = manifest.Width()
	height = manifest.Height()
	x = (win.GetSystemMetrics(win.SM_CXSCREEN) - width) / 2
	y = (win.GetSystemMetrics(win.SM_CYSCREEN)-height)/2 - 2

	renderWindow := win.CreateWindowEx(
		dwExStyle,
		syscall.StringToUTF16Ptr(nguiWindowClass),
		nil,
		dwStyle, //|win.WS_CLIPSIBLINGS,
		x,       //win.CW_USEDEFAULT,
		y,       //win.CW_USEDEFAULT,
		width,   //win.CW_USEDEFAULT,
		height,  //win.CW_USEDEFAULT,
		0,       //hwndParent
		0,
		0, //hInstance
		nil)
	if renderWindow == 0 {
		//err := errors.New("CreateWindowEx")
		return win.HWND(0)
	}

	fmt.Printf("CreateWindow x=%v y=%v width=%v height=%v renderWindow=%v renderWindow=%v\n", x, y, width, height, renderWindow, unsafe.Pointer(renderWindow))

	win.ShowWindow(renderWindow, win.SW_SHOW) //win.SW_SHOW
	win.UpdateWindow(renderWindow)

	return renderWindow
}
Exemplo n.º 6
0
Arquivo: ngui.go Projeto: CodyGuo/ngui
// 创建浏览器窗口
func (a *Application) CreateBrowserWindow(url string, captionless bool) (err error) {
	var dwExStyle, dwStyle uint32 = 0, 0
	var captionlessFlag uintptr = 0
	fmt.Printf("CreateBrowserWindow url=%v captionless=%v\n", url, captionless)

	if captionless {
		captionlessFlag = 1
		//dwExStyle = 0//win.WS_EX_LAYERED

		// 无边框效果不错。但是不能移动
		//dwStyle = win.WS_POPUP //& ^ (win.WS_CAPTION | win.WS_BORDER)

		dwStyle = win.WS_MINIMIZEBOX | win.WS_MAXIMIZEBOX | win.WS_CAPTION | win.WS_CLIPCHILDREN |
			win.WS_SYSMENU | win.WS_POPUP

	} else {
		dwStyle = win.WS_OVERLAPPEDWINDOW
	}

	if !manifest.FormFixed() {
		dwStyle |= win.WS_SIZEBOX
	}

	// 获取屏幕宽度和高度
	var x, y int32
	var width, height int32

	width = manifest.Width()
	height = manifest.Height()
	x = (win.GetSystemMetrics(win.SM_CXSCREEN) - width) / 2
	y = (win.GetSystemMetrics(win.SM_CYSCREEN)-height)/2 - 2

	renderWindow := win.CreateWindowEx(
		dwExStyle,
		syscall.StringToUTF16Ptr(nguiTransparentWindowClass),
		nil,
		dwStyle, //|win.WS_CLIPSIBLINGS,
		x,       //win.CW_USEDEFAULT,
		y,       //win.CW_USEDEFAULT,
		width,   //win.CW_USEDEFAULT,
		height,  //win.CW_USEDEFAULT,
		0,       //hwndParent
		0,
		0, //hInstance
		nil)
	if renderWindow == 0 {
		err = errors.New("CreateWindowEx")
		return
	}

	// 设置captionless标记
	win.SetProp(renderWindow, WindowProp_CaptionLess, win.HANDLE(captionlessFlag))

	if captionless {
		/*
					SetWindowLong(hWnd, GWL_STYLE,
			        GetWindowLong(hWnd, GWL_STYLE) & ~(WS_BORDER));
		*/

		// WS_BORDER Creates a window that has a border.创建一个有边界的窗口。
		// WS_EX_CLIENTEDGE Specifies that a window has a 3D look — that is, a border with a sunken edge.指定窗口具有3D外观,也即是一个下层的边缘。
		//gwlStyle := win.GetWindowLong(renderWindow, win.GWL_STYLE)
		//gwlStyle &= ^(win.WS_BORDER)
		//gwlStyle &= ^(win.WS_EX_CLIENTEDGE)
		//win.SetWindowLong(renderWindow, win.GWL_STYLE, gwlStyle)

		//gwlExStyle := win.GetWindowLong(renderWindow, win.GWL_EXSTYLE)
		//gwlExStyle |= win.WS_EX_LAYERED;
		//win.SetWindowLong(renderWindow, win.GWL_EXSTYLE, gwlExStyle)

		// HWND hWnd: 窗口句柄
		// COLORREF col: 透明化颜色
		// byte bAlpha: =0:整个窗口透明, =255 完全不透明
		// uint32 dwFlags: =1:仅颜色 col 透明, =2 :窗口按照bAlpha变量进行透明处理。
		//win.SetLayeredWindowAttributes(renderWindow, win.BS_SOLID, 0, 2)
		//win.UpdateWindow(renderWindow)
	}

	if captionless {
		//win.MoveWindow(renderWindow, x, y, width, height, false)
		//win.SetWindowPos(renderWindow, 0, x, y, width, height, win.SWP_NOZORDER|win.SWP_NOACTIVATE|win.SWP_NOSIZE)
		win.SetWindowPos(renderWindow, 0, x, y, width, height, win.SWP_FRAMECHANGED)
	} else {
		win.MoveWindow(renderWindow, x, y, width, height, false)
	}

	fmt.Printf("CreateBrowserWindow x=%v, y=%v, width=%v, height=%v\n", x, y, width, height)

	go func() {

		//browser := cef.CreateBrowser(unsafe.Pointer(hwnd), &browserSettings, url, false)
		browserSettings := cef.BrowserSettings{}
		cef.CreateBrowser(unsafe.Pointer(renderWindow), &browserSettings, url, false)

		//m_dwStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |
		//		WS_VISIBLE;
		cef.WindowResized(unsafe.Pointer(renderWindow))

		win.ShowWindow(renderWindow, win.SW_SHOW) //win.SW_SHOW
		win.UpdateWindow(renderWindow)

		//cef.WindowResized(unsafe.Pointer(renderWindow))
		// It should be enough to call WindowResized after 10ms,
		// though to be sure let's extend it to 100ms.
		//time.AfterFunc(time.Millisecond*100, func() {
		//	cef.WindowResized(unsafe.Pointer(renderWindow))
		//})
	}()

	return
}
Exemplo n.º 7
0
func (w *WindowBase) ShowNormal() {
	win.ShowWindow(w.hwnd, win.SW_SHOWNORMAL)
}
Exemplo n.º 8
0
func (w *WindowBase) ShowFullScreen() {
	win.ShowWindow(w.hwnd, win.SW_SHOWMAXIMIZED)
}
Exemplo n.º 9
0
func (w *WindowBase) ShowMaximized() {
	win.ShowWindow(w.hwnd, win.SW_MAXIMIZE)
}
Exemplo n.º 10
0
func (w *WindowBase) ShowMinimized() {
	win.ShowWindow(w.hwnd, win.SW_MINIMIZE)
}
Exemplo n.º 11
0
func (w *WindowBase) Hide() {
	win.ShowWindow(w.hwnd, win.SW_HIDE)
}
Exemplo n.º 12
0
func (w *WindowBase) Show() {
	win.ShowWindow(w.hwnd, win.SW_SHOW)
}