Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CB Help
#1
OK, ive been spending the last two hours on this, copying exactly what i seen in the cb stuff, but how ever , i can NOT get this to show the pictures i want, what in gods name am i doing wrong, this is EXACTLY identical to the copy i used, but it will NOT work, what am i doing wrong ?



Function tesettterrrr
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 4"
str cb3 cb4
cb3 = "&TESTER []TESTER1 []TESTER2"
cb4 = "&TESTER []TESTER1 []TESTER2"
if(!ShowDialog("tesettterrrr" &tesettterrrr &controls)) ret
out cb3
out cb4
;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 ComboBox 0x54230243 0x0 30 10 96 213 ""
;4 ComboBox 0x54230243 0x0 30 36 96 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030109 "" "" ""
ret
;messages

CB_DrawImages hDlg message wParam lParam 3 "$qm$\close.ico"
CB_DrawImages hDlg message wParam lParam 4 "$qm$\member.ico"

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


CB_DrawImages


Function CB_DrawImages
Code:
Copy      Help
;/
function# hDlg message wParam lParam ctrlId $icons [flags] [imgWidth] [imgHeight] [dtFlags] ;;flags: 1 listbox (default combobox), 16 not icons (bmp, jpg, gif)

;Adds icons or bmp/jpg/gif images to a combo box or list box.

;This is what you have to do to create a combo or list box with icons or images:
;1. The dialog must be a smart dialog, ie with dialog function.
;2. In the dialog editor, add a combo or list box.
;3. In the Styles dialog:
;;;;For combo box, select CBS_OWNERDRAWFIXED and CBS_HASSTRINGS styles. Make sure that CBS_SORT is not selected (sorted combo boxes are not supported).
;;;;For list box, select LBS_OWNERDRAWFIXED and LBS_HASSTRINGS styles. Make sure that LBS_SORT is not selected (sorted list boxes are not supported).
;4. In the dialog function, insert CB_DrawImages before 'sel messages' line.

;hDlg, message, wParam, lParam - hDlg, message, wParam, lParam.
;ctrlId - combo/list box id.
;icons - list of icon files. If flag 16 used, list of image files of type bmp, jpg or gif.
;imgWidth, imgHeight - width and height of images. Default: 16 pixels.
;dtFlags - DrawText flags. Documented in the MSDN Library on the Internet. Xored with DT_NOPREFIX.


int i n il hi hb hcb; str s
hcb=id(ctrlId hDlg)
if(!imgWidth) imgWidth=16
if(!imgHeight) imgHeight=16

sel message
,case WM_CREATE
,SendMessage hcb iif(flags&1 LB_SETITEMHEIGHT CB_SETITEMHEIGHT) 0 imgHeight+2
,
,case WM_INITDIALOG
,n=numlines(icons)
,il=ImageList_Create(imgWidth imgHeight ILC_MASK|ILC_COLOR32 0 n)
,for(i 0 n)
,,s.getl(icons -i)
,,if(flags&16)
,,,hb=LoadPictureFile(s 0); if(!hb) goto g1
,,,ImageList_Add(il hb 0)
,,,if(hb) DeleteObject hb
,,else
,,,hi=GetFileIcon(s 0 (imgWidth>=24 or imgHeight>=24))
,,,;g1
,,,ImageList_ReplaceIcon(il -1 iif(hi hi _dialogicon))
,,,if(hi) DestroyIcon hi
,SetProp hcb "qm_il" il
,
,case WM_DESTROY
,ImageList_Destroy RemoveProp(hcb "qm_il")
,
,case WM_DRAWITEM
,if(wParam=ctrlId)
,,DRAWITEMSTRUCT* ds=+lParam
,,RECT r=ds.rcItem
,,;background
,,int selected=ds.itemState&(ODS_SELECTED|ODS_COMBOBOXEDIT)=ODS_SELECTED
,,FillRect ds.hDC &ds.rcItem iif(selected COLOR_HIGHLIGHT COLOR_WINDOW)+1
,,;icon
,,il=GetProp(hcb "qm_il")
,,n=ImageList_GetImageCount(il); if(ds.itemID<n) n=ds.itemID; else n-1
,,ImageList_Draw il n ds.hDC r.left+1 r.top+1 ILD_NORMAL
,,;text
,,SetBkMode ds.hDC TRANSPARENT
,,SetTextColor ds.hDC GetSysColor(iif(selected COLOR_HIGHLIGHTTEXT COLOR_WINDOWTEXT))
,,GetItemText ds.hWndItem ds.itemID s flags&1
,,r.left+imgWidth+4; r.top+2
,,DrawText ds.hDC s -1 &r dtFlags^DT_NOPREFIX
#2
Nevermind, i've figured it out now!, Lol 8)


Forum Jump:


Users browsing this thread: 1 Guest(s)