How to color two item in listbox,for example one item have a different color.Thank you
Posted on 2005-04-08 06:06:29 by yu930
This is the Listbox
Attachments:
Posted on 2005-04-08 06:22:45 by yu930
You must create an owner drawn listbox and do the text drawing yourself.

You can find example here:
http://radasm.visualassembler.com/projects/Demo.zip

KetilO
Posted on 2005-04-08 15:48:36 by KetilO
i am sorry,it can't do it.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.386
.model flat, stdcall
option casemap:none

;--------------------------------------------------------------------------------

include load.inc

;--------------------------------------------------------------------------------

IDD_DIALOG_LOAD equ 101
IDC_LIST_SHOW3 equ 1015
.data?
hList3 dd ?
.code

_DlgProc proc hdlg,uMsg,wParam,lParam
LOCAL _dbTem:BYTE
mov eax,uMsg
.if eax == WM_INITDIALOG
invoke GetDlgItem, hdlg, IDC_LIST_SHOW3
mov hList3, eax
; add text

;invoke SendMessage, hList3, LB_INSERTSTRING, -1, ADDR MenuName
invoke SendDlgItemMessage, hdlg, IDC_LIST_SHOW3, LB_ADDSTRING, 0, ADDR MenuName
invoke SendDlgItemMessage, hdlg, IDC_LIST_SHOW3, LB_SETITEMDATA, 0, 11

invoke SendDlgItemMessage, hdlg, IDC_LIST_SHOW3, LB_ADDSTRING, 0, ADDR MenuName
invoke SendDlgItemMessage, hdlg, IDC_LIST_SHOW3, LB_SETITEMDATA, 1, 0

    invoke SendDlgItemMessage, hdlg, IDC_LIST_SHOW3, LB_ADDSTRING, 0, ADDR MenuName
invoke SendDlgItemMessage, hdlg, IDC_LIST_SHOW3, LB_SETITEMDATA, 2, 25
invoke DRAWITEM,lParam

.else
mov eax, FALSE
ret
.endif
mov eax, TRUE
ret
_DlgProc endp


start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke DialogBoxParam, eax, IDD_DIALOG_LOAD, NULL, _DlgProc, 0
invoke ExitProcess, 0
end start
Posted on 2005-04-09 04:13:37 by yu930
Don't worry - you can do it.
You are probably reaching too high.
Owner-Drawn controls are not simple for beginners.
Learn common controls first.
Posted on 2005-04-09 06:56:38 by Homer
can anybody give me some advice on it,beause it is too hard.
it wil be kind of you  to give me some easy examples.Thank you!
Posted on 2005-04-11 03:37:50 by yu930

If you change your ListBox to a ListView control you can use the "custom draw" feature, which is much simpler than implementing an "owner drawn" control. Searching for CDDS_PREPAINT should give you some useful results.
Posted on 2005-04-11 04:33:26 by japheth
yu930,

Can you please don't report to moderator for no reasons?

And you are asking a difficult question, how do you expect a simple answer? Listen to Homer.
Posted on 2005-04-11 06:56:36 by roticv
i am so sorry,roticv.
I made a mistake,i don't know what is the moderator  mean.
And i want to ask for your help urgently.
Posted on 2005-04-11 07:17:57 by yu930