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

Problem with LB_GETITEMDATA

ratzeputz
Beginner
562 Views
Hi there.
I am using ListBox Control where items will be added dynamically, depending on a selection of a DropDownList
Later, when an item of the LB is clicked, i want to display the settings of that item (it is a type) and the user should be able to change them.
Because i to have many different types with different attributes to change to, i made an array of a special type which is declared as follows:
[fortran]type FILTERTABLE
        character(32)           filterName
        character(3)            filterUsed
        character(32)           filterProps
        integer(INT_PTR_KIND()) item
end type[/fortran]
The array is build with 19 elements of this type.
The item attribute points to different structures which all does have different attributes.
Here are 2 of this types...just for better unterstanding how my array and the structures are setted up:
[fortran]type FI_SLICETHICK
        real(8) sliceThickMin
        real(8) sliceThickMax
        logical sliceThickUse
end type
type FI_MODALITY
        character(64)modality
        logical      modalityUse
end type[/fortran]
So you can understand the array as followed:
filterArr(1)%item%sliceThickMin or filterArr(2)%item%modality, and so on
When the array is built, i fill the DropDownList with the array and set the address of the item attribute with CB_SETITEMDATA
It is done as follows:
[fxfortran]do i=1, numFilters
        retlog = SendDlgItemMessage(dlg%hWnd,IDC_CMB_FILTERS,CB_INSERTSTRING,i-1,loc(filterArr(i)%filterName))
        retlog = SendDlgItemMessage(dlg%hWnd,IDC_CMB_FILTERS,CB_SETITEMDATA ,i-1,filterArr(i)%item)[/fxfortran]
[fxfortran]end do[/fxfortran]
[fxfortran]retlog = SendDlgItemMessage(dlg%hWnd,IDC_CMB_FILTERS,CB_SETCURSEL ,0,NULL)[/fxfortran]
Next step of the circle is, that the user will see all available Filters by their name in the DropDownList, which is working like a charm.
By choosing one, and clicking a button, the Filter will be added to the ListBox, which is done as follows:
[fortran].....

selectedIndex = SendDlgItemMessage(xWnd%hWnd,IDC_CMB_FILTERS,CB_GETCURSEL ,0,0)
retlog = XCtlGet(xWnd,IDC_LBX_FILTERS,numItems, CTL_NUMITEMS)
itemAddr = SendDlgItemMessage(xWnd%hWnd,IDC_CMB_FILTERS,CB_GETITEMDATA ,0,0)

....
retlog = XCtlSet(xWnd, IDC_LBX_FILTERS , XItem(filterArr(i)), numItems+1)
iRet = SendDlgItemMessage(xWnd%hWnd,IDC_LBX_FILTERS,LB_SETITEMDATA ,numItems+1,itemAddr)
....[/fortran]
[fortran]retlog = XCtlSet(xWnd, IDC_LBX_FILTERS, XLV_AUTOHDR, CTL_RECTS)
iRet = SendDlgItemMessage(xWnd%hWnd,IDC_CMB_FILTERS,CB_DELETESTRING ,selectedIndex,0) 
retlog = SendDlgItemMessage(xWnd%hWnd,IDC_CMB_FILTERS,CB_SETCURSEL ,0,0)[/fortran]
This also seems working well, because i do not get error messages.
Now to my real problem:
I want to give the user the chance, to edit the filter later, when one of them is selected by clicking one of the ListBox items.
My routine is coded as follows:
[fortran]....
retlog = XCtlGet(xWnd, h_id, iSel, CTL_SELECTION) 

if (SIZE(iSel) .GE. 1) then
     numItems = 0
     retlog = XCtlGet(xWnd,IDC_LBX_FILTERS,numItems, CTL_NUMITEMS)

     itemAddr = SendDlgItemMessage(xWnd%hWnd,IDC_LBX_FILTERS,LB_GETITEMDATA ,iSel(1),0)

.....[/fortran]
And at the point, where i want to find out the address of the item (remembering, that i stored it as a pointer within the type) the return value is always 0. I searched google a few hours now and dont getting any idea what i am doing wrong. itemAddr is declared as integer.
Maybe because i am using xEffort?...But it cant be the reason, because on the DropDownList its working with no errors.
I tried the same with the DropDownList (CB_GETITEMDATA) and the value of itemAddr is matching the value of the item attribute...so the address here is correct and later when i declare a type and point it to this address, i can see and change all attributes of that type.
Why not on the ListBox?
Any suggestions?
Best Regards
Oliver
0 Kudos
0 Replies
Reply