예제 #1
0
파일: ngui.go 프로젝트: CodyGuo/ngui
// 主进程
func (a *Application) Exec() {
	manifest.Load()
	MustRegisterWindowClass(nguiWindowClass)
	nguiTransparentWindowClass = _NguiTransparentWindowClass + strconv.Itoa(os.Getpid())
	MustRegisterTransparentWindowClass(nguiTransparentWindowClass)

	exitCode := cef.ExecuteProcess(unsafe.Pointer(hInstance))
	if exitCode >= 0 {
		return
	}

	cef.OnContextInitialized = func() {
		a.createWindow()
	}
	cef.OnOpenWindow = func(url string) {

	}

	settings := cef.Settings{}
	//settings.SingleProcess = 1	// 单进程模式
	settings.CachePath = manifest.CachePath()      // Set to empty to disable
	settings.LogSeverity = cef.LOGSEVERITY_DEFAULT // LOGSEVERITY_VERBOSE
	//settings.LocalesDirPath = releasePath + "/locales"
	settings.Locale = manifest.Locale() //"zh-CN"
	settings.BrowserSubprocessPath = manifest.BrowserSubprocessPath()
	//settings.RemoteDebuggingPort = 7000
	cef.Initialize(settings)

	cef.RunMessageLoop()
	cef.Shutdown()
	os.Exit(0)
}
예제 #2
0
파일: ngui.go 프로젝트: CodyGuo/ngui
// 渲染进程
func (a *Application) ExecuteProcess() {
	/*
			HINSTANCE hInstance = GetModuleHandle(0);
		    CefMainArgs args(hInstance);
		    CefRefPtr<CefApp> app(new TestApp);
		    return CefExecuteProcess(args, app.get(), 0);
	*/
	manifest.Load()
	//MustRegisterWindowClass(nguiWindowClass)
	nguiTransparentWindowClass = _NguiTransparentWindowClass + strconv.Itoa(os.Getpid())
	MustRegisterTransparentWindowClass(nguiTransparentWindowClass)

	cef.ExecuteProcess(unsafe.Pointer(hInstance))

	settings := cef.Settings{}
	//settings.SingleProcess = 1	// 单进程模式
	settings.CachePath = manifest.CachePath()      // Set to empty to disable
	settings.LogSeverity = cef.LOGSEVERITY_DEFAULT // LOGSEVERITY_VERBOSE
	//settings.LocalesDirPath = releasePath + "/locales"
	settings.Locale = manifest.Locale() //"zh-CN"
	settings.BrowserSubprocessPath = manifest.BrowserSubprocessPath()
	//settings.RemoteDebuggingPort = 7000
	cef.Initialize(settings)

	cef.RunMessageLoop()
	cef.Shutdown()
	os.Exit(0)
}
예제 #3
0
파일: main.go 프로젝트: CodyGuo/gapp
func main() {
	runtime.GOMAXPROCS(4)

	exitCode := cef.ExecuteProcess(unsafe.Pointer(hInstance))
	if exitCode >= 0 {
		return
	}

	// 启动本地Web服务器
	go func() {
		startAppServer()
	}()

	cef.OnContextInitialized = func() {
		window := createWindow()
		createBrowser(window, manifest.FirstPage()) // http://www.baidu.com/
	}

	cef.OnOpenWindow = func(url string) {
		window := createWindow()
		createBrowser(window, url)
		windowHolders[url] = window
	}

	settings := cef.Settings{}
	//settings.SingleProcess = 1                     // 单进程模式
	settings.CachePath = manifest.CachePath()      // Set to empty to disable
	settings.LogSeverity = cef.LOGSEVERITY_DEFAULT // LOGSEVERITY_VERBOSE
	//settings.LocalesDirPath = releasePath + "/locales"
	settings.Locale = manifest.Locale() //"zh-CN"
	settings.BrowserSubprocessPath = manifest.BrowserSubprocessPath()
	//settings.RemoteDebuggingPort = 7000
	cef.Initialize(settings)

	cef.RunMessageLoop()
	cef.Shutdown()
	os.Exit(0)
}