func main() { log.Println("Start") hInstance := w32.GetModuleHandle("") log.Printf("hInstances: %x\n", hInstance) var app myAppHandler app.handler = cef2go.NewAppHandlerT(&app) var browserPHandler myBrowserProcessHandler browserPHandler.handler = cef2go.NewBrowserProcessHandlerT(&browserPHandler) app.browserProcessHandler = &browserPHandler ret := cef2go.ExecuteProcess(unsafe.Pointer(hInstance), &app) log.Printf("ExecuteResult: %d\n", ret) if ret >= 0 { return } settings := cef2go.Settings{} log.Printf("Initialize: %#v\n", settings) cef2go.Initialize(settings, &app) log.Println("Run the message loop") cef2go.RunMessageLoop() log.Println("Shutdown") cef2go.Shutdown() log.Println("Cleanup") cef2go.DumpRefs() }
func createRootWindow() w32.HWND { windowClassName, _ := syscall.UTF16PtrFromString("myWindowClass") moduleHandle := w32.GetModuleHandle("") var wc w32.WNDCLASSEX wc.Size = uint32(unsafe.Sizeof(wc)) wc.WndProc = syscall.NewCallback(WndProc) wc.Instance = moduleHandle wc.MenuName = nil wc.ClassName = windowClassName wc.Style = w32.CS_HREDRAW | w32.CS_VREDRAW if regClass := w32.RegisterClassEx(&wc); regClass == 0 { panic("Failed to register window class") } windowName, _ := syscall.UTF16PtrFromString("SimpleApp") // CreateWindowEx wh := w32.CreateWindowEx( 0, windowClassName, windowName, w32.WS_OVERLAPPEDWINDOW, w32.CW_USEDEFAULT, w32.CW_USEDEFAULT, w32.CW_USEDEFAULT, w32.CW_USEDEFAULT, 0, 0, moduleHandle, nil, ) if wh == 0 { panic("Parent.CreateWindowEX returned 0") } // ShowWindow w32.ShowWindow(wh, w32.SW_MAXIMIZE) // UpdateWindow if success := w32.UpdateWindow(wh); !success { panic("Parent.UpdateWindow returned 0") } return wh }