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

Problem with a list control

michael_green
Beginner
352 Views
I'm using a list control having a "list" style and it's populated with 6 items. I want to be able to have the first item in the list highlighted (preselected) when the user first sees the dialog. The following is the way I've been attempting to do this:

call PopulateList(GetDlgItem(hDlg,IDC_relop1),relops,6)

item%mask = LVIF_text
item%iItem = 0
item%state = LVIS_SELECTED
item%statemask = LVIS_SELECTED

iret = SendMessage(GetDlgItem(hDlg,IDC_relop1), & LVM_SETITEMSTATE,0,loc(item))

It doesn't do anything. What am I doing wrong?

With many thanks

Mike
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
352 Views
You mixed up ListView (the control in Explorer's list pane) and List control (standard list). LVM_SETITEMSTATE is used for the former (and even there, you need LVIF_STATE in the mask), and you appear to have used the latter.
Instead, you need LB_SETCURSEL (for single-selection list) or LB_SETSEL (for multiple-selection list).
Jugoslav
0 Kudos
Reply