Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Line Spacing in ListBox
#4
Add this code in CB_ItemColor after sel message:
Code:
Copy      Help
,case WM_MEASUREITEM
,if(wParam=ctrlId)
,,MEASUREITEMSTRUCT& mi=+lParam
,,int hlb=id(ctrlId hDlg 1)
,,int ih=GetProp(hlb "lbItemHeight")
,,if !ih
,,,int dc=GetDC(hlb); int of=SelectObject(dc SendMessage(hlb WM_GETFONT 0 0))
,,,RECT _r; DrawText dc "J" 1 &_r DT_CALCRECT; ih=_r.bottom
,,,SetProp hlb "lbItemHeight" ih
,,,SelectObject dc of; ReleaseDC hlb dc
,,mi.itemHeight=ih+4
,

Remove style LBS_OWNERDRAWFIXED and add LBS_OWNERDRAWVARIABLE.

Add items in dialog procedure, not before ShowDialog. Example:
Function Dialog95
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str lb3
;lb3="yellow background[]blue text"
if(!ShowDialog("Dialog95" &Dialog95 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ListBox 0x54230161 0x200 6 8 96 48 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "*" "" ""

ret
;messages

CB_ItemColor hDlg message wParam lParam 3 &SampleCbItemColorProc

sel message
,case WM_INITDIALOG
,;create and set font
,__Font-- f
,f.Create("Arial" 12 1)
,f.SetDialogFont(hDlg "3")
,;add items
,int hlb=id(3 hDlg)
,LB_Add hlb "yellow background"
,LB_Add hlb "blue text"
,,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)