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

QuickWin ListControl in report view won´t fill in IVF14

onkelhotte
New Contributor II
408 Views

Hi there,

I´m testing the new compiler and found an unconvinient thing: My ListControl won´t fill any more, it does when I switch the compiler back to 12.1 (and do a rebuild of course).

Here is the code (dlg and IDC_LISTBOX are declared globally):

[fortran]

logical(kind=4) l
integer(kind=4) listHwnd, i
type (T_LV_ITEM) LVItem
character*10 tempString

listHwnd=getDlgItem(dlg%hwnd,IDC_LISTBOX)

LVItem%mask=LVIF_TEXT
LVItem%state=0
LVItem%statemask=0
LVItem%cchTextMax=0

l=sendMessage(listHwnd,LVM_DELETEALLITEMS,0,0)

LVItem%iSubItem=0
write(tempstring,'(2A)') 'Ca',char(0)
LVItem%pszText=LOC(tempstring)
LVItem%iItem=sendMessage(listHwnd,LVM_INSERTITEM,0,LOC(LVItem))

[/fortran]

IVF14 sets LVItem%iItem to -1. It is 0 with IVF12.1. GetLastError or GetLastErrorQQ both return 0.

Any ideas?

Thanks in advance,
Markus 

0 Kudos
1 Solution
Paul_Curtis
Valued Contributor I
408 Views

Your code looks fairly similar to mine, but I have not encountered any problems (WinAPI or anything else) in updating to IVF14.  Your code will only insert an item as the first entry in the list, whereas the standard method is to query the starting item count and then place the added item at the end of the list.  Also, handles should be specified as INTEGER(HANDLE) rather than I*4.

[fortran]

INTEGER FUNCTION ListViewAddItem (hwnd, controlId, name)

    IMPLICIT NONE

    INTEGER(HANDLE), INTENT(IN)    :: hwnd
    INTEGER, INTENT(IN)            :: controlId
    CHARACTER(LEN=*), INTENT(IN)   :: name

    INTEGER                        :: rval
    INTEGER                        :: nItems
    TYPE(T_LV_ITEM)                :: item
    CHARACTER(LEN=200)             :: buffer
    
    buffer = name
    CALL NullTerminateString (buffer)

    nItems        = ListViewGetNumItems (hwnd, controlId)
    item%mask     = LVIF_TEXT
    item%iItem    = nItems
    item%iSubitem = 0
    item%pszText  = LOC(buffer)
    
    rval = SendControlMessage(hwnd, controlId, LVM_INSERTITEM, 0, LOC(item))
    
    IF(rval /= -1) THEN
        ListViewAddItem = rval + 1
    ELSE
        CALL ControlError("ListViewAddItem", controlId, "LVM_INSERTITEM")
        ListViewAddItem = -1
    END IF

END FUNCTION ListViewAddItem

[/fortran]

View solution in original post

0 Kudos
2 Replies
Paul_Curtis
Valued Contributor I
409 Views

Your code looks fairly similar to mine, but I have not encountered any problems (WinAPI or anything else) in updating to IVF14.  Your code will only insert an item as the first entry in the list, whereas the standard method is to query the starting item count and then place the added item at the end of the list.  Also, handles should be specified as INTEGER(HANDLE) rather than I*4.

[fortran]

INTEGER FUNCTION ListViewAddItem (hwnd, controlId, name)

    IMPLICIT NONE

    INTEGER(HANDLE), INTENT(IN)    :: hwnd
    INTEGER, INTENT(IN)            :: controlId
    CHARACTER(LEN=*), INTENT(IN)   :: name

    INTEGER                        :: rval
    INTEGER                        :: nItems
    TYPE(T_LV_ITEM)                :: item
    CHARACTER(LEN=200)             :: buffer
    
    buffer = name
    CALL NullTerminateString (buffer)

    nItems        = ListViewGetNumItems (hwnd, controlId)
    item%mask     = LVIF_TEXT
    item%iItem    = nItems
    item%iSubitem = 0
    item%pszText  = LOC(buffer)
    
    rval = SendControlMessage(hwnd, controlId, LVM_INSERTITEM, 0, LOC(item))
    
    IF(rval /= -1) THEN
        ListViewAddItem = rval + 1
    ELSE
        CALL ControlError("ListViewAddItem", controlId, "LVM_INSERTITEM")
        ListViewAddItem = -1
    END IF

END FUNCTION ListViewAddItem

[/fortran]

0 Kudos
onkelhotte
New Contributor II
407 Views

Thanks Paul!

When I explicit set LVItem%iItem=0, it works.

Markus

0 Kudos
Reply