diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-18 02:22:27 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-18 02:22:27 -0400 |
| commit | 58e95f239940c646dce75c2b978d077884b7d215 (patch) | |
| tree | d97819143dd15c8ca25213e79e54fa1bf9fe514b /redo/table_windows.c | |
| parent | 3cad9aac25515dd3e6d526142db3e90c98d125d7 (diff) | |
Added Table.Selected()/Table.Select() and implemented them on Windows.
Diffstat (limited to 'redo/table_windows.c')
| -rw-r--r-- | redo/table_windows.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/redo/table_windows.c b/redo/table_windows.c index e10611e..a34e47a 100644 --- a/redo/table_windows.c +++ b/redo/table_windows.c @@ -122,3 +122,33 @@ void tableSetCheckboxImageList(HWND hwnd) if (SendMessageW(hwnd, LVM_SETCALLBACKMASK, LVIS_STATEIMAGEMASK, 0) == FALSE) xpanic("error marking state image list as application-managed", GetLastError()); } + +// because Go won't let me do C.WPARAM(-1) +intptr_t tableSelectedItem(HWND hwnd) +{ + return (intptr_t) SendMessageW(hwnd, LVM_GETNEXTITEM, (WPARAM) -1, LVNI_SELECTED); +} + +void tableSelectItem(HWND hwnd, intptr_t index) +{ + LVITEMW item; + LRESULT current; + + // via http://support.microsoft.com/kb/131284 + // we don't need to clear the other bits; Tables don't support cutting or drag/drop + current = SendMessageW(hwnd, LVM_GETNEXTITEM, (WPARAM) -1, LVNI_SELECTED); + if (current != (LRESULT) -1) { + ZeroMemory(&item, sizeof (LVITEMW)); + item.mask = LVIF_STATE; + item.state = 0; + item.stateMask = LVIS_FOCUSED | LVIS_SELECTED; + if (SendMessageW(hwnd, LVM_SETITEMSTATE, (WPARAM) current, (LPARAM) (&item)) == FALSE) + xpanic("error deselecting current Table item", GetLastError()); + } + ZeroMemory(&item, sizeof (LVITEMW)); + item.mask = LVIF_STATE; + item.state = LVIS_FOCUSED | LVIS_SELECTED; + item.stateMask = LVIS_FOCUSED | LVIS_SELECTED; + if (SendMessageW(hwnd, LVM_SETITEMSTATE, (WPARAM) index, (LPARAM) (&item)) == FALSE) + xpanic("error selecting new Table item", GetLastError()); +} |
