Beispiel #1
0
func (window *Win32Window) GetHDC() unsafe.Pointer {
	if window.hdc != nil {
		return unsafe.Pointer(&window.hdc)
	}

	window.hdc = C.GetDC(window.hwnd)

	px := C.PIXELFORMATDESCRIPTOR{
		dwFlags:    0x00000001 | 0x00000020 | 0x00000004,
		iPixelType: 0,
		cColorBits: 32,
		cDepthBits: 32,
		iLayerType: 0,
	}

	px.nSize = (C.WORD)(unsafe.Sizeof(px))

	pxFormat := C.ChoosePX(window.hdc, &px)
	if pxFormat == 0 {
		return nil
	}

	res := C.SetPixelFormat(window.hdc, pxFormat, &px)
	if res == 0 {
		return nil
	}

	return unsafe.Pointer(&window.hdc)
}