Exemplo n.º 1
0
func createIconFromResourceEx(pbIconBits *byte, cbIconBits w32.DWORD, fIcon bool, dwVersion w32.DWORD,
	cxDesired, cyDesired int32, flags uint32) (w32.HICON, error) {
	ret, _, _ := procCreateIconFromResourceEx.Call(
		uintptr(unsafe.Pointer(pbIconBits)),
		uintptr(cbIconBits),
		uintptr(w32.BoolToBOOL(fIcon)),
		uintptr(dwVersion),
		uintptr(cxDesired),
		uintptr(cyDesired),
		uintptr(flags),
	)
	if ret == 0 {
		return w32.HICON(0), syscall.GetLastError()
	}
	return w32.HICON(ret), nil
}
Exemplo n.º 2
0
// Fetch an icon handle using a ICONDIRENTRY struct
func getIconHandle(icoData []byte, dirEntry _ICONDIRENTRY) w32.HICON {
	ret, _ := createIconFromResourceEx(
		&icoData[dirEntry.dwImageOffset],
		w32.DWORD(0),
		true,
		w32.DWORD(0x30000),
		int32(dirEntry.bWidth),
		int32(dirEntry.bHeight),
		_LR_DEFAULT_COLOR)
	return w32.HICON(ret)
}