本文整理汇总了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
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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()
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
}
}
示例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)
}
示例14: setWindowFont
func setWindowFont(hwnd win.HWND, font *Font) {
win.SendMessage(hwnd, win.WM_SETFONT, uintptr(font.handleForDPI(0)), 1)
}
示例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)
}