github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/src/cef/cef_windows.go (about)

     1  // Copyright (c) 2014 The cef2go authors. All rights reserved.
     2  // License: BSD 3-clause.
     3  // Website: https://github.com/CzarekTomczak/cef2go
     4  
     5  package cef
     6  
     7  /*
     8  #cgo CFLAGS: -I./../../
     9  #cgo LDFLAGS: -L./../../Release -llibcef
    10  #include <stdlib.h>
    11  #include "string.h"
    12  #include "include/capi/cef_app_capi.h"
    13  */
    14  import "C"
    15  import "unsafe"
    16  
    17  func FillMainArgs(mainArgs *C.struct__cef_main_args_t,
    18          appHandle unsafe.Pointer) {
    19      Logger.Println("FillMainArgs")
    20      mainArgs.instance = (C.HINSTANCE)(appHandle)
    21  }
    22  
    23  func FillWindowInfo(windowInfo *C.cef_window_info_t, hwnd unsafe.Pointer) {
    24      Logger.Println("FillWindowInfo")
    25      var rect C.RECT
    26      C.GetWindowRect((C.HWND)(hwnd),
    27              (*C.struct_tagRECT)(unsafe.Pointer(&rect)))
    28      windowInfo.style = C.WS_CHILD | C.WS_CLIPCHILDREN | C.WS_CLIPSIBLINGS |
    29              C.WS_TABSTOP | C.WS_VISIBLE
    30      windowInfo.parent_window = (C.HWND)(hwnd)
    31      windowInfo.x = C.int(rect.left)
    32      windowInfo.y = C.int(rect.top)
    33      windowInfo.width = C.int(rect.right - rect.left)
    34      windowInfo.height = C.int(rect.bottom - rect.top)
    35  }
    36  
    37  func WindowResized(hwnd unsafe.Pointer) {
    38      var rect C.RECT;
    39      C.GetClientRect((C.HWND)(hwnd),
    40              (*C.struct_tagRECT)(unsafe.Pointer(&rect)))
    41      var hdwp C.HDWP = C.BeginDeferWindowPos(1)
    42      var cefHwnd C.HWND = C.GetWindow((C.HWND)(hwnd), C.GW_CHILD)
    43      hdwp = C.DeferWindowPos(hdwp, cefHwnd, nil,
    44              C.int(rect.left), C.int(rect.top),
    45              C.int(rect.right - rect.left),
    46              C.int(rect.bottom - rect.top),
    47              C.SWP_NOZORDER)
    48      C.EndDeferWindowPos(hdwp)
    49  }