当前位置: 首页>>代码示例>>Golang>>正文


Golang win.SendMessage函数代码示例

本文整理汇总了Golang中github.com/lxn/win.SendMessage函数的典型用法代码示例。如果您正苦于以下问题:Golang SendMessage函数的具体用法?Golang SendMessage怎么用?Golang SendMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SendMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: setWindowText

func setWindowText(hwnd win.HWND, text string) error {
	if win.TRUE != win.SendMessage(hwnd, win.WM_SETTEXT, 0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text)))) {
		return newError("WM_SETTEXT failed")
	}

	return nil
}
开发者ID:henrylee2cn,项目名称:walk,代码行数:7,代码来源:window.go

示例2: onClearedPages

func (tw *TabWidget) onClearedPages(pages []*TabPage) (err error) {
	win.SendMessage(tw.hWndTab, win.TCM_DELETEALLITEMS, 0, 0)
	for _, page := range pages {
		tw.removePage(page)
	}
	tw.currentIndex = -1
	return nil
}
开发者ID:Ryanker,项目名称:walk,代码行数:8,代码来源:tabwidget.go

示例3: onPageChanged

func (tw *TabWidget) onPageChanged(page *TabPage) (err error) {
	index := tw.pages.Index(page)
	item := tw.tcitemFromPage(page)

	if 0 == win.SendMessage(tw.hWndTab, win.TCM_SETITEM, uintptr(index), uintptr(unsafe.Pointer(item))) {
		return newError("SendMessage(TCM_SETITEM) failed")
	}

	return nil
}
开发者ID:Ryanker,项目名称:walk,代码行数:10,代码来源:tabwidget.go

示例4: notifyIconWndProc

func notifyIconWndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
	// Retrieve our *NotifyIcon from the message window.
	ptr := win.GetWindowLongPtr(hwnd, win.GWLP_USERDATA)
	ni := (*NotifyIcon)(unsafe.Pointer(ptr))

	switch lParam {
	case win.WM_LBUTTONDOWN:
		ni.publishMouseEvent(&ni.mouseDownPublisher, LeftButton)

	case win.WM_LBUTTONUP:
		ni.publishMouseEvent(&ni.mouseUpPublisher, LeftButton)

	case win.WM_RBUTTONDOWN:
		ni.publishMouseEvent(&ni.mouseDownPublisher, RightButton)

	case win.WM_RBUTTONUP:
		ni.publishMouseEvent(&ni.mouseUpPublisher, RightButton)

		win.SendMessage(hwnd, msg, wParam, win.WM_CONTEXTMENU)

	case win.WM_CONTEXTMENU:
		if ni.contextMenu.Actions().Len() == 0 {
			break
		}

		win.SetForegroundWindow(hwnd)

		var p win.POINT
		if !win.GetCursorPos(&p) {
			lastError("GetCursorPos")
		}

		actionId := uint16(win.TrackPopupMenuEx(
			ni.contextMenu.hMenu,
			win.TPM_NOANIMATION|win.TPM_RETURNCMD,
			p.X,
			p.Y,
			hwnd,
			nil))
		if actionId != 0 {
			if action, ok := actionsById[actionId]; ok {
				action.raiseTriggered()
			}
		}

		return 0
	case NIN_BALLOONUSERCLICK:
		ni.balloonClickedPublisher.Publish()
	}

	return win.DefWindowProc(hwnd, msg, wParam, lParam)
}
开发者ID:joy999,项目名称:walk,代码行数:52,代码来源:notifyicon.go

示例5: setSortIcon

func (tv *TableView) setSortIcon(index int, order SortOrder) error {
	headerHwnd := win.HWND(tv.SendMessage(win.LVM_GETHEADER, 0, 0))

	idx := int(tv.toLVColIdx(index))

	for i := range tv.visibleColumns() {
		item := win.HDITEM{
			Mask: win.HDI_FORMAT,
		}

		iPtr := uintptr(i)
		itemPtr := uintptr(unsafe.Pointer(&item))

		if win.SendMessage(headerHwnd, win.HDM_GETITEM, iPtr, itemPtr) == 0 {
			return newError("SendMessage(HDM_GETITEM)")
		}

		if i == idx {
			switch order {
			case SortAscending:
				item.Fmt &^= win.HDF_SORTDOWN
				item.Fmt |= win.HDF_SORTUP

			case SortDescending:
				item.Fmt &^= win.HDF_SORTUP
				item.Fmt |= win.HDF_SORTDOWN
			}
		} else {
			item.Fmt &^= win.HDF_SORTDOWN | win.HDF_SORTUP
		}

		if win.SendMessage(headerHwnd, win.HDM_SETITEM, iPtr, itemPtr) == 0 {
			return newError("SendMessage(HDM_SETITEM)")
		}
	}

	return nil
}
开发者ID:cautonwong,项目名称:walk,代码行数:38,代码来源:tableview.go

示例6: onRemovedPage

func (tw *TabWidget) onRemovedPage(index int, page *TabPage) (err error) {
	err = tw.removePage(page)
	if err != nil {
		return
	}

	win.SendMessage(tw.hWndTab, win.TCM_DELETEITEM, uintptr(index), 0)

	if tw.pages.Len() > 0 {
		tw.currentIndex = 0
		win.SendMessage(tw.hWndTab, win.TCM_SETCURSEL, uintptr(tw.currentIndex), 0)
	} else {
		tw.currentIndex = -1
	}
	tw.onSelChange()

	return

	// FIXME: Either make use of this unreachable code or remove it.
	if index == tw.currentIndex {
		// removal of current visible tabpage...
		tw.currentIndex = -1

		// select new tabpage if any :
		if tw.pages.Len() > 0 {
			// are we removing the rightmost page ?
			if index == tw.pages.Len()-1 {
				// If so, select the page on the left
				index -= 1
			}
		}
	}

	tw.SetCurrentIndex(index)
	//tw.Invalidate()

	return
}
开发者ID:Ryanker,项目名称:walk,代码行数:38,代码来源:tabwidget.go

示例7: onSelChange

func (tw *TabWidget) onSelChange() {
	pageCount := tw.pages.Len()

	if tw.currentIndex > -1 && tw.currentIndex < pageCount {
		page := tw.pages.At(tw.currentIndex)
		page.SetVisible(false)
	}

	tw.currentIndex = int(win.SendMessage(tw.hWndTab, win.TCM_GETCURSEL, 0, 0))

	if tw.currentIndex > -1 && tw.currentIndex < pageCount {
		page := tw.pages.At(tw.currentIndex)
		page.SetVisible(true)
		page.Invalidate()
	}

	tw.currentIndexChangedPublisher.Publish()
}
开发者ID:Ryanker,项目名称:walk,代码行数:18,代码来源:tabwidget.go

示例8: imageIndex

func (tw *TabWidget) imageIndex(image *Bitmap) (index int32, err error) {
	index = -1
	if image != nil {
		if tw.imageList == nil {
			if tw.imageList, err = NewImageList(Size{16, 16}, 0); err != nil {
				return
			}

			win.SendMessage(tw.hWndTab, win.TCM_SETIMAGELIST, 0, uintptr(tw.imageList.hIml))
		}

		// FIXME: Protect against duplicate insertion
		if index, err = tw.imageList.AddMasked(image); err != nil {
			return
		}
	}

	return
}
开发者ID:Ryanker,项目名称:walk,代码行数:19,代码来源:tabwidget.go

示例9: NewTabWidget

func NewTabWidget(parent Container) (*TabWidget, error) {
	tw := &TabWidget{currentIndex: -1}
	tw.pages = newTabPageList(tw)

	if err := InitWidget(
		tw,
		parent,
		tabWidgetWindowClass,
		win.WS_VISIBLE,
		win.WS_EX_CONTROLPARENT); err != nil {
		return nil, err
	}

	succeeded := false
	defer func() {
		if !succeeded {
			tw.Dispose()
		}
	}()

	tw.SetPersistent(true)

	tw.hWndTab = win.CreateWindowEx(
		0, syscall.StringToUTF16Ptr("SysTabControl32"), nil,
		win.WS_CHILD|win.WS_CLIPSIBLINGS|win.WS_TABSTOP|win.WS_VISIBLE,
		0, 0, 0, 0, tw.hWnd, 0, 0, nil)
	if tw.hWndTab == 0 {
		return nil, lastError("CreateWindowEx")
	}
	win.SendMessage(tw.hWndTab, win.WM_SETFONT, uintptr(defaultFont.handleForDPI(0)), 1)

	setWindowFont(tw.hWndTab, tw.Font())

	tw.MustRegisterProperty("HasCurrentPage", NewReadOnlyBoolProperty(
		func() bool {
			return tw.CurrentIndex() != -1
		},
		tw.CurrentIndexChanged()))

	succeeded = true

	return tw, nil
}
开发者ID:Ryanker,项目名称:walk,代码行数:43,代码来源:tabwidget.go

示例10: SetCurrentIndex

func (tw *TabWidget) SetCurrentIndex(index int) error {
	if index == tw.currentIndex {
		return nil
	}

	if index < 0 || index >= tw.pages.Len() {
		return newError("invalid index")
	}

	ret := int(win.SendMessage(tw.hWndTab, win.TCM_SETCURSEL, uintptr(index), 0))
	if ret == -1 {
		return newError("SendMessage(TCM_SETCURSEL) failed")
	}

	// FIXME: The SendMessage(TCM_SETCURSEL) call above doesn't cause a
	// TCN_SELCHANGE notification, so we use this workaround.
	tw.onSelChange()

	return nil
}
开发者ID:Ryanker,项目名称:walk,代码行数:20,代码来源:tabwidget.go

示例11: onInsertedPage

func (tw *TabWidget) onInsertedPage(index int, page *TabPage) (err error) {
	item := tw.tcitemFromPage(page)

	if idx := int(win.SendMessage(tw.hWndTab, win.TCM_INSERTITEM, uintptr(index), uintptr(unsafe.Pointer(item)))); idx == -1 {
		return newError("SendMessage(TCM_INSERTITEM) failed")
	}

	page.SetVisible(false)

	style := uint32(win.GetWindowLong(page.hWnd, win.GWL_STYLE))
	if style == 0 {
		return lastError("GetWindowLong")
	}

	style |= win.WS_CHILD
	style &^= win.WS_POPUP

	win.SetLastError(0)
	if win.SetWindowLong(page.hWnd, win.GWL_STYLE, int32(style)) == 0 {
		return lastError("SetWindowLong")
	}

	if win.SetParent(page.hWnd, tw.hWnd) == 0 {
		return lastError("SetParent")
	}

	if tw.pages.Len() == 1 {
		page.SetVisible(true)
		tw.SetCurrentIndex(0)
	}

	tw.resizePages()

	page.tabWidget = tw

	page.applyFont(tw.Font())

	return
}
开发者ID:Ryanker,项目名称:walk,代码行数:39,代码来源:tabwidget.go

示例12: resizePages

func (tw *TabWidget) resizePages() {
	var r win.RECT
	if !win.GetWindowRect(tw.hWndTab, &r) {
		lastError("GetWindowRect")
		return
	}

	p := win.POINT{
		r.Left,
		r.Top,
	}
	if !win.ScreenToClient(tw.hWnd, &p) {
		newError("ScreenToClient failed")
		return
	}

	r = win.RECT{
		p.X,
		p.Y,
		r.Right - r.Left + p.X,
		r.Bottom - r.Top + p.Y,
	}
	win.SendMessage(tw.hWndTab, win.TCM_ADJUSTRECT, 0, uintptr(unsafe.Pointer(&r)))

	for _, page := range tw.pages.items {
		if err := page.SetBounds(
			Rectangle{
				int(r.Left - 2),
				int(r.Top),
				int(r.Right - r.Left + 2),
				int(r.Bottom - r.Top),
			}); err != nil {

			return
		}
	}
}
开发者ID:Ryanker,项目名称:walk,代码行数:37,代码来源:tabwidget.go

示例13: windowText

func windowText(hwnd win.HWND) string {
	textLength := win.SendMessage(hwnd, win.WM_GETTEXTLENGTH, 0, 0)
	buf := make([]uint16, textLength+1)
	win.SendMessage(hwnd, win.WM_GETTEXT, uintptr(textLength+1), uintptr(unsafe.Pointer(&buf[0])))
	return syscall.UTF16ToString(buf)
}
开发者ID:henrylee2cn,项目名称:walk,代码行数:6,代码来源:window.go

示例14: setWindowFont

func setWindowFont(hwnd win.HWND, font *Font) {
	win.SendMessage(hwnd, win.WM_SETFONT, uintptr(font.handleForDPI(0)), 1)
}
开发者ID:henrylee2cn,项目名称:walk,代码行数:3,代码来源:window.go

示例15: SendMessage

// SendMessage sends a message to the window and returns the result.
func (wb *WindowBase) SendMessage(msg uint32, wParam, lParam uintptr) uintptr {
	return win.SendMessage(wb.hWnd, msg, wParam, lParam)
}
开发者ID:henrylee2cn,项目名称:walk,代码行数:4,代码来源:window.go


注:本文中的github.com/lxn/win.SendMessage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。