| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "unsafe" |
| 7 | |
| 8 | "golang.org/x/sys/windows" |
| 9 | ) |
| 10 | |
| 11 | type _ICoreWebView2Controller2Vtbl struct { |
| 12 | _IUnknownVtbl |
| 13 | GetIsVisible ComProc |
| 14 | PutIsVisible ComProc |
| 15 | GetBounds ComProc |
| 16 | PutBounds ComProc |
| 17 | GetZoomFactor ComProc |
| 18 | PutZoomFactor ComProc |
| 19 | AddZoomFactorChanged ComProc |
| 20 | RemoveZoomFactorChanged ComProc |
| 21 | SetBoundsAndZoomFactor ComProc |
| 22 | MoveFocus ComProc |
| 23 | AddMoveFocusRequested ComProc |
| 24 | RemoveMoveFocusRequested ComProc |
| 25 | AddGotFocus ComProc |
| 26 | RemoveGotFocus ComProc |
| 27 | AddLostFocus ComProc |
| 28 | RemoveLostFocus ComProc |
| 29 | AddAcceleratorKeyPressed ComProc |
| 30 | RemoveAcceleratorKeyPressed ComProc |
| 31 | GetParentWindow ComProc |
| 32 | PutParentWindow ComProc |
| 33 | NotifyParentWindowPositionChanged ComProc |
| 34 | Close ComProc |
| 35 | GetCoreWebView2 ComProc |
| 36 | GetDefaultBackgroundColor ComProc |
| 37 | PutDefaultBackgroundColor ComProc |
| 38 | } |
| 39 | |
| 40 | type ICoreWebView2Controller2 struct { |
| 41 | vtbl *_ICoreWebView2Controller2Vtbl |
| 42 | } |
| 43 | |
| 44 | func (i *ICoreWebView2Controller2) AddRef() uintptr { |
| 45 | ret, _, _ := i.vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 46 | |
| 47 | return ret |
| 48 | } |
| 49 | |
| 50 | func (i *ICoreWebView2Controller2) GetDefaultBackgroundColor() (*COREWEBVIEW2_COLOR, error) { |
| 51 | |
| 52 | var backgroundColor *COREWEBVIEW2_COLOR |
| 53 | hr, _, _ := i.vtbl.GetDefaultBackgroundColor.Call( |
| 54 | uintptr(unsafe.Pointer(i)), |
| 55 | uintptr(unsafe.Pointer(&backgroundColor)), |
| 56 | ) |
| 57 | if windows.Handle(hr) != windows.S_OK { |
| 58 | return nil, windows.Errno(hr) |
| 59 | } |
| 60 | return backgroundColor, nil |
| 61 | } |
| 62 | |
| 63 | func (i *ICoreWebView2Controller2) PutDefaultBackgroundColor(backgroundColor COREWEBVIEW2_COLOR) error { |
| 64 | |
| 65 | // Cast to a uint32 as that's what the call is expecting |
| 66 | col := *(*uint32)(unsafe.Pointer(&backgroundColor)) |
| 67 | |
| 68 | hr, _, _ := i.vtbl.PutDefaultBackgroundColor.Call( |
| 69 | uintptr(unsafe.Pointer(i)), |
| 70 | uintptr(col), |
| 71 | ) |
| 72 | if windows.Handle(hr) != windows.S_OK { |
| 73 | return windows.Errno(hr) |
| 74 | } |
| 75 | return nil |
| 76 | } |
| 77 |