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

How to color columns in a ListView

michael_green
Beginner
907 Views
Hi All,

Does anyone have any Fortran snippets for coloring individual columns ina ListView. There's plenty out there in VB, C#, and other alien languages, but nothing I can use.

Many thanks in advance,
Mike
0 Kudos
2 Replies
Paul_Curtis
Valued Contributor I
907 Views
Here is a distilled-down code sample showing how to color individual items in a listview.

[bash]INTEGER FUNCTION DialogProc (hwnd, msg, wParam, lParam) RESULT (res) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : '_DialogProc@16' :: DialogProc !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : 'DialogProc' :: DialogProc !DEC$ ENDIF IMPLICIT NONE SAVE INTEGER(HANDLE), INTENT(IN) :: hwnd INTEGER(UINT), INTENT(IN) :: msg INTEGER(fWPARAM), INTENT(IN) :: wParam INTEGER(fLPARAM), INTENT(IN) :: lParam INTEGER :: rval, jdex INTEGER(HANDLE) :: hwndControl INTEGER :: controlId INTEGER :: code ! listview message structure TYPE(T_NMLVCUSTOMDRAW) :: nmlvcd POINTER (lParam, nmlvcd) ! Windows message processing SELECT CASE (msg) !... many CASEs omitted ... CASE (WM_NOTIFY) controlId = wParam SELECT CASE (controlId) CASE (IDC_INPUTLIST, IDC_OUTPUTLIST) ! listview controls SELECT CASE (nmlvcd%nmcd%hdr%code) ! process customdraw messages CASE (NM_CUSTOMDRAW) SELECT CASE (nmlvcd%nmcd%dwDrawStage) CASE (CDDS_PREPAINT) rval = SetWindowLong (hwnd, DWL_MSGRESULT, CDRF_NOTIFYITEMDRAW) CASE (IOR(CDDS_ITEM, CDDS_PREPAINT)) jdex = nmlvcd%nmcd%lItemlParam !== io-list "data" attribute nmlvcd%clrText = darkblue ! text foreground color ! item background color from its data attrribute IF (jdex >= 1) THEN nmlvcd%clrTextBk = palegreen ELSE nmlvcd%clrTextBk = pink END IF rval = SetWindowLong (hwnd, DWL_MSGRESULT, CDRF_NEWFONT) CASE DEFAULT rval = SetWindowLong (hwnd, DWL_MSGRESULT, CDRF_DODEFAULT) END SELECT END SELECT res = 1 END SELECT [/bash]
0 Kudos
michael_green
Beginner
907 Views
Hi Paul,

Many thanks for that - it was almost perfect from the start. With just a little R&D based on the clues in your code I now have exactly what I wanted.

Thanks again.
Mike
0 Kudos
Reply