// 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 }
func (b *nullBrush) Dispose() { if b.hBrush != 0 { win.DeleteObject(win.HGDIOBJ(b.hBrush)) b.hBrush = 0 } }
func (b *SolidColorBrush) Dispose() { if b.hBrush != 0 { win.DeleteObject(win.HGDIOBJ(b.hBrush)) b.hBrush = 0 } }
func (p *nullPen) Dispose() { if p.hPen != 0 { win.DeleteObject(win.HGDIOBJ(p.hPen)) p.hPen = 0 } }
func (p *GeometricPen) Dispose() { if p.hPen != 0 { win.DeleteObject(win.HGDIOBJ(p.hPen)) p.hPen = 0 } }
// 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) } }
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 } }