- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
have you added your resource-file into your fortran source?
some thing like
INCLUDE "Resource.fd"
Frank
some thing like
INCLUDE "Resource.fd"
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
#define ListView_GetCheckState(hwndLV, i) \
((((UINT)(SNDMSG((hwndLV), LVM_GETITEMSTATE, (WPARAM)(i), LVIS_STATEIMAGEMASK))) >> 12) -1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
[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]

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page