1. LV header images example
- Posted by jordah ferguson <jorfergie03 at yahoo.com> Aug 25, 2002
- 505 views
Hi Derek, Attached is a simple program that places an image on a Listview Header. However when it does so, the lv column affected gets a one-pixel width. I don't experience this when i use direct API. I'll probably figure this out later but just incase you know why this is happening inform me. The icon is loaded at run-time. -----X Cut here include win32lib.ew constant lvcolumn_mask = allot(Long), lvcolumn_fmt = allot(Long), lvcolumn_cx = allot(Long), lvcolumn_pszText = allot(Lpsz), lvcolumn_cchTextMax = allot(Long), lvcolumn_iSubItem = allot(Long), lvcolumn_iImage = allot(Long), lvcolumn_iOrder = allot(Long), sizeof_lvcolumn = allotted_size(), LVCFMT_IMAGE = #0800, LVCFMT_COL_HAS_IMAGES = #8000 global procedure SetColumnImage(atom lv,integer col,integer img) atom MemAddr,void MemAddr = acquire_mem(0,sizeof_lvcolumn) store(MemAddr,lvcolumn_mask, or_bits(LVCF_FMT,LVCF_IMAGE)) store(MemAddr,lvcolumn_fmt,or_bits(LVCFMT_IMAGE,LVCFMT_COL_HAS_IMAGES)) store(MemAddr,lvcolumn_iImage,img-1) void = sendMessage(lv,LVM_SETCOLUMN,col-1,MemAddr) release_mem(MemAddr) end procedure constant Win = create(Window,"Test for Listview Column",0,Default,Default,300,200,0), Lst = create(ListView,{"Names","Age"},Win,10,10,280,160,or_all({LVS_SHOWSELALWAYS,LVS_SHAREIMAGELISTS,LVS_REPORT})) constant TempIcoFile = getenv("TMP")&"\\cirico.tmp" -- Converted Using Enclude (C) Jordah Ferguson 2002 in RDS archives -- Contacts: jorfergie03 at yahoo.com constant aleph={'A','B','C','D','E','F','G','H','I','J','K','L','M', 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 'a','b','c','d','e','f','g','h','i','j','k','l','m', 'n','o','p','q','r','s','t','u','v','w','x','y','z', '0','1','2','3','4','5','6','7','8','9','+','/'} constant drem ={64,16,4} constant dmul ={4,16,64} constant ddiv ={16,4,1} constant nc3 ={3,1,2} constant ldrop={2,1,1} global function decode64(sequence in) integer len,oidx,case3,tmp sequence result sequence ccha len=length(in) if len >0 then if remainder(len,4)!=0 then puts(1,"Decode64: len not 4n") abort(1) end if oidx=(len/4)*3 case3=3 while in[len]='=' do oidx-=1 case3=nc3[case3] len-=1 end while ccha=repeat(0,256) for i=1 to 64 do ccha[aleph[i]]=i-1 end for result=repeat('?',oidx) for i=oidx to 1 by-1 do tmp=remainder(ccha[in[len-1]],drem[case3])*dmul[case3] tmp+=floor(ccha[in[len]]/ddiv[case3]) result[i]=tmp len-=ldrop[case3] case3=nc3[case3] end for return result else return {} end if end function sequence aa_ico aa_ico = decode64( "AAABAAEADQ0AAAEACAAsBQAAFgAAACgAAAANAAAAGgAAAAEACAAAAAAABAEAAAAAAAAAAAAAAAEA"& "AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA"& "/wD/AP//AAD///8ABgYGABISEgAfHx8ALCwsADk5OQBFRUUAUlJSAF9fXwBsbGwAeHh4AIWFhQCS"& "kpIAn5+fAKurqwC4uLgAxcXFANLS0gDe3t4A6+vrAPj4+ADw+/8ApKCgAMDcwADwyqYAAAA+AAAA"& "XQAAAHwAAACbAAAAugAAANkAAADwACQk/wBISP8AbGz/AJCQ/wC0tP8AABQ+AAAeXQAAKHwAADKb"& "AAA8ugAARtkAAFXwACRt/wBIhf8AbJ3/AJC1/wC0zf8AACo+AAA/XQAAVHwAAGmbAAB+ugAAk9kA"& "AKrwACS2/wBIwv8AbM7/AJDa/wC05v8AAD4+AABdXQAAfHwAAJubAAC6ugAA2dkAAPDwACT//wBI"& "//8AbP//AJD//wC0//8AAD4qAABdPwAAfFQAAJtpAAC6fgAA2ZMAAPCqACT/tgBI/8IAbP/OAJD/"& "2gC0/+YAAD4UAABdHgAAfCgAAJsyAAC6PAAA2UYAAPBVACT/bQBI/4UAbP+dAJD/tQC0/80AAD4A"& "AABdAAAAfAAAAJsAAAC6AAAA2QAAAPAAACT/JABI/0gAbP9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8AB///AAf//wAH//8=") function Return_Icon_Handle(sequence data) atom handle,ic,void handle = open(TempIcoFile,"wb") puts(handle,data) close(handle) ic = extractIcon(TempIcoFile) void = deleteFile(TempIcoFile) return ic end function atom icon1,void icon1 = Return_Icon_Handle(aa_ico) -- Release internal memory aa_ico = {} -- Set the Icons in win32libs default image list constant img1 = addIcon(icon1) -- Delete the resource void = w32Func(xDeleteObject,{icon1}) procedure w32HOpen_Win(atom id,integer event,sequence params) SetColumnImage(Lst,1,img1) end procedure setHandler(Win,w32HOpen,routine_id("w32HOpen_Win")) WinMain(Win,0) -------X End Cut here Also, there seems to be a lot of flickering when you click,drag the headers....... Derek, The below code found in struct_LVCOLUMN() is not needed. Usually text length is needed when you are receiving info but once setting you need not specify. if sequence(text) then store( LV_COLUMN, LVCOLUMN_cchTextMax, length( text )) end if Jordah Ferguson.
2. Re: LV header images example
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 25, 2002
- 464 views
Jordah, there is a bug in the definition of the flags. Currently in win32lib, it reads... LVCF_IMAGE = 10, LVCF_ORDER = 20, but should read LVCF_IMAGE = #10, LVCF_ORDER = #20, Also, I don't see any flickering on my machine. I set the length field in the routine because I don't know how the structure will be used after it is allocated. Its a safety thing. It does no harm. ---------------- cheers, Derek Parnell