Ejemplo n.º 1
0
// Dispose releases the operating system resources associated with the
// NotifyIcon.
//
// The associated Icon is not disposed of.
func (ni *NotifyIcon) Dispose() error {
	if ni.hWnd == 0 {
		return nil
	}

	nid := ni.notifyIconData()

	if !win.Shell_NotifyIcon(win.NIM_DELETE, nid) {
		return newError("Shell_NotifyIcon")
	}

	if !win.DestroyWindow(ni.hWnd) {
		return lastError("DestroyWindow")
	}
	ni.hWnd = 0

	return nil
}
Ejemplo n.º 2
0
// Dispose releases the operating system resources, associated with the
// *WindowBase.
//
// If a user closes a *MainWindow or *Dialog, it is automatically released.
// Also, if a Container is disposed of, all its descendants will be released
// as well.
func (wb *WindowBase) Dispose() {
	hWnd := wb.hWnd
	if hWnd != 0 {
		switch w := wb.window.(type) {
		case *ToolTip:
		case Widget:
			globalToolTip.RemoveTool(w)
		}

		wb.hWnd = 0
		win.DestroyWindow(hWnd)
	}

	if cm := wb.contextMenu; cm != nil {
		cm.actions.Clear()
	}

	for _, p := range wb.name2Property {
		p.SetSource(nil)
	}
}