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

ListControl strings

rooooger
Beginner
521 Views
I'm attempting to use a ListControl in report mode to display some information to the user; however, when I set the text there is always some extra garbage following. For example, the null-terminated string '12345'C will show something similar to '12345#@-'.
The string declaration is correct, say character(5) in this case.

Furthermore, I'm using the ListControl in a Dialog application. As I understand it, the ListControl is not well supported as such. Which leads to my second question. Is there an analog to using a DlgSetSub on this unsupported control?

Below is a few lines of the offending code, hopefully to give you an idea.
Thanks in advance.

item%Mask = LVIF_TEXT
item%iItem = j
item%pszText = loc(hStr)
item%cchTextMax = sizeof(hStr) ! ignored under LVIF_TEXT mask
item%state = 0
item%statemask = 0
item%iImage = -1

! ListView content:
item%iSubItem = 0
hStr = '12345'C
iret = DlgSendCtrlMessage(gdlg, & ! dialog
IDC_GENOTYPES_LC, & ! control id
LVM_INSERTITEM, & ! message
0, & ! wparam
loc(item)) ! lparam
item%iSubItem = 1
hStr = gStr(i)
iret = DlgSendCtrlMessage(gdlg, & ! dialog
IDC_GENOTYPES_LC, & ! control id
LVM_SETITEM, & ! message
0, & ! wparam
loc(item)) ! lparam
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
521 Views

For example, the null-terminated string '12345'C will show something similar to '12345#@-'.
The string declaration is correct, say character(5) in this case.

How do you mean correct? In this case, the correct declaration is character(6) -- and it will be so even in C language, as it has to accomodate for trailing char(0). I suspect that is the culprit.

Jugoslav

0 Kudos
Reply