示例#1
0
文件: icon.go 项目: wangch/walk
// create an Alpha Icon or Cursor from an Image
// http://support.microsoft.com/kb/318876
func createAlphaCursorOrIconFromImage(im image.Image, hotspot image.Point, fIcon bool) (win.HICON, error) {
	hBitmap, err := hBitmapFromImage(im)
	if err != nil {
		return 0, err
	}
	defer win.DeleteObject(win.HGDIOBJ(hBitmap))

	// Create an empty mask bitmap.
	hMonoBitmap := win.CreateBitmap(int32(im.Bounds().Dx()), int32(im.Bounds().Dy()), 1, 1, nil)
	if hMonoBitmap == 0 {
		return 0, newError("CreateBitmap failed")
	}
	defer win.DeleteObject(win.HGDIOBJ(hMonoBitmap))

	var ii win.ICONINFO
	if fIcon {
		ii.FIcon = win.TRUE
	}
	ii.XHotspot = uint32(hotspot.X)
	ii.YHotspot = uint32(hotspot.Y)
	ii.HbmMask = hMonoBitmap
	ii.HbmColor = hBitmap

	// Create the alpha cursor with the alpha DIB section.
	hIconOrCursor := win.CreateIconIndirect(&ii)

	return hIconOrCursor, nil
}
示例#2
0
文件: pen.go 项目: wangch/walk
func (p *nullPen) Dispose() {
	if p.hPen != 0 {
		win.DeleteObject(win.HGDIOBJ(p.hPen))

		p.hPen = 0
	}
}
示例#3
0
文件: pen.go 项目: wangch/walk
func (p *GeometricPen) Dispose() {
	if p.hPen != 0 {
		win.DeleteObject(win.HGDIOBJ(p.hPen))

		p.hPen = 0
	}
}
示例#4
0
文件: brush.go 项目: wangch/walk
func (b *nullBrush) Dispose() {
	if b.hBrush != 0 {
		win.DeleteObject(win.HGDIOBJ(b.hBrush))

		b.hBrush = 0
	}
}
示例#5
0
文件: brush.go 项目: wangch/walk
func (b *SolidColorBrush) Dispose() {
	if b.hBrush != 0 {
		win.DeleteObject(win.HGDIOBJ(b.hBrush))

		b.hBrush = 0
	}
}
示例#6
0
文件: font.go 项目: wangch/walk
// Dispose releases the os resources that were allocated for the Font.
//
// The Font can no longer be used for drawing operations or with GUI widgets
// after calling this method. It is safe to call Dispose multiple times.
func (f *Font) Dispose() {
	for dpi, hFont := range f.dpi2hFont {
		if dpi != 0 {
			win.DeleteObject(win.HGDIOBJ(hFont))
		}

		delete(f.dpi2hFont, dpi)
	}
}
示例#7
0
文件: bitmap.go 项目: wangch/walk
func (bmp *Bitmap) Dispose() {
	if bmp.hBmp != 0 {
		win.DeleteObject(win.HGDIOBJ(bmp.hBmp))

		win.GlobalUnlock(bmp.hPackedDIB)
		win.GlobalFree(bmp.hPackedDIB)

		bmp.hPackedDIB = 0
		bmp.hBmp = 0
	}
}