求助list view control绘制表格
问题:使用list view control 绘制表格,能够画出表头,可是显示不了内容。求教代码如下:
TYPE(T_LVCOLUMN) lvc
TYPE(T_LVITEM) lvi
character(len=Len("序号")),dimension(3)::header=["序号","姓名","年龄"]
character(len=4):: pszText
lret=DlgInit(IDD_test, gdlg)
if (lret == FALSE) goto 9999
lret = DlgModeless(gdlg)
hListView=getDlgItem(gdlg%hwnd,IDC_LISTCONTROL)
lret= sendmessage(hListView,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_GRIDLINES)
lvc%mask=IOR(IOR(LVCF_WIDTH,LVCF_TEXT),LVCF_SUBITEM)
lvc%cx=50
do i=1,3
pszText=header(i)
! iret = MessageBox(null, pszText, "Error"C, MB_OK)
lvc%pszText=LOC(pszText)
lvc%iSubItem=i-1
lret= sendmessage(hListView,LVM_INSERTCOLUMN,i-1,LOC(lvc))
end do
!上面的代码可以显示出表头"序号","姓名","年龄"
!下面的代码用来添加项目,程序没有报错,可以没有显示出来任何一个“小明”
lvi%mask=LVIF_TEXT
pszText="小明"C
lvi%pszText =LOC("小明"C)
! lvi%iItem= sendmessage(hListView,LVM_GETITEMCOUNT,0,0);
lvi%iItem=0
lvi%iSubItem=0;
lret=sendmessage(hListView,LVM_SETITEM,0,LOC(lvi))
if (lret == -1) then
goto 9999
else
lvi%mask=LVIF_TEXT
lvi%pszText =LOC("小明"C)
lvi%iSubItem=1;
lret =sendmessage(hListView,LVM_SETITEMTEXT,1,LOC(lvi))
end if
if (lret == -1) then
goto 9999
else
lvi%pszText =LOC("小明"C)
lvi%iSubItem=2;
lret =sendmessage(hListView,LVM_SETITEMTEXT,2,LOC(lvi))
end if
return
9999 iret = MessageBox(null, "Error initializing dlg"C, "Error"C, MB_OK)
return
自己解决了 不厌其烦的说:不要用 Fortran 做原生Win32API 的 UI
页:
[1]