Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

How to use ListView_GetCheckState

michael_green
Beginner
1,037 Views
Hi All,

I have never used a Windows API macro before - so how do I get my program to "see" ListView_GetCheckState? I cannot get the linker to find it.

Many thanks
Mike
0 Kudos
3 Replies
tropfen
New Contributor I
1,037 Views
have you added your resource-file into your fortran source?

some thing like

INCLUDE "Resource.fd"

Frank
0 Kudos
anthonyrichards
New Contributor III
1,037 Views
It's in COMMCTRL.H in the Windows SDK and I suppose the it resides in COMCTL32.LIB. You will have to ask someone here to translate the following C++ code into the correct SENDMESSAGE command and how to recover the reply using the appropriate masking (which I think the >>12 ) -1) does, although I am not certain!.

#define ListView_GetCheckState(hwndLV, i) \
((((UINT)(SNDMSG((hwndLV), LVM_GETITEMSTATE, (WPARAM)(i), LVIS_STATEIMAGEMASK))) >> 12) -1)

0 Kudos
Paul_Curtis
Valued Contributor I
1,037 Views
Here are Fortran wrapper functions to set and retrieve the selected state of a listview item:

[bash]! ! Sets the specified item in a list view control to selected. The ! index argument is 1-based. ! SUBROUTINE ListViewSetSelectedIndex(hwnd, controlId, index) IMPLICIT NONE INTEGER(HANDLE), INTENT(IN) :: hwnd INTEGER, INTENT(IN) :: controlId INTEGER, INTENT(IN) :: index INTEGER :: rval TYPE(T_LV_ITEM) :: item item%iItem = index - 1 item%iSubitem = 0 item%mask = LVIF_STATE item%state = LVIS_SELECTED item%stateMask = LVIS_SELECTED rval = SendControlMessage (hwnd, controlId, LVM_SETITEM, 0, LOC(item)) IF (rval == -1) THEN CALL ControlError("ListViewSetSelectedIndex", controlId, & "LVM_SETITEM") END IF END SUBROUTINE ListViewSetSelectedIndex ! ! Returns the 1-based index of the currently selected item in a list view, ! or -1 if nothing is selected. ! INTEGER FUNCTION ListViewGetSelectedIndex (hwnd, controlId, top) RESULT(index) IMPLICIT NONE INTEGER(HANDLE), INTENT(IN) :: hwnd INTEGER, INTENT(IN) :: controlId INTEGER, INTENT(INOUT),OPTIONAL:: top INTEGER :: rval INTEGER :: nItems TYPE(T_LV_ITEM) :: lvitem TYPE(T_RECT) :: rect INTEGER :: i nItems = ListViewGetNumItems (hwnd, controlId) DO i = 0, nItems - 1 lvitem%mask = LVIF_STATE lvitem%iItem = i lvitem%iSubitem = 0 lvitem%stateMask = LVIS_SELECTED rval = SendControlMessage (hwnd, controlId, LVM_GETITEM, 0, LOC(lvitem)) IF(rval /= 0) THEN IF (lvitem%state == LVIS_SELECTED) THEN IF (PRESENT(top)) THEN rval = SendControlMessage (hwnd, controlId, LVM_GETITEMRECT, i, LOC(rect)) top = rect%top END IF index = i + 1 RETURN END IF ELSE CALL ControlError("ListViewGetSelectedItem", controlId, "LVM_GETITEM") END IF END DO index = -1 END FUNCTION ListViewGetSelectedIndex [/bash]
0 Kudos
Reply