Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Avoid dipalying an icon at column 0 of a grid
#1
The routine which it follows displays perfectly information on a grid, with icons at columns 0 and 2. I am wondering about the best way to stop displaying the icon at all rows in column 0, under certain circumstances.




Code:
Copy      Help
Let me add that my best approach was to replace last statement in sub "IconCol0" as "col0[]=-1".
Any advice is much appreciated.

Function FilesBookMsGrid
Code:
Copy      Help
str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err    caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : %s" NowT si _error.place si caller

CFunctionCounter fc.Enter
if IsFunctionRunning2(si) > 1
,_s=F"Non-Thread function {si} is already running"
,Task_Message _s 0 171 2
,_s=F"<c 172>{_s}</c>   - Caller : <open>{caller}</open> "
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,res win("Files/Folders Bookmarked" "#32770")

ARRAY(str) a tmodi cod
str- slo
ARRAY(int)- col0
ARRAY(int)- manal
ARRAY(int)- col2
str- folder filnam fPath
int- ianal delSel
DlgGrid- g

;g1
a=""
tmodi=""
cod=""
manal=0
slo=""
col0=0
col2=0

GetISMFile(BkmF "$my qm$\Files\DataBases\BkmFiled.txt" 100 a tmodi)

int na=a.len
str st sl s2
DateTime x
int i lanal

for i 0 na
,st=tmodi[i]
,x=val(st 1)
,st=x.ToStr(4)
;,out F"{st} {a[i]}"
;,s2=a[i]
,cod[].left(a[i] 2)
,s2.get(a[i] 4)
;,out F"{cod[i]} {a[i]} {s2}"
,lanal=s2.FilExtAnal
,manal[]=lanal
,slo.formata("%i|%s|%s|%s[]" lanal cod[i] st s2)
,if lanal=9
,,outt F"{lanal} {s2}"

str sicos="%IconFol%\1483109857_Bookmark.ico"
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0A41 0x100 0 0 532 253 "  Files/Folders Bookmarked"
;4 QM_Grid 0x54031049 0x200 6 0 523 191 ""
;6 Edit 0x54830880 0x200 25 199 478 16 ""
;7 Button 0x54030040 0x0 5 199 16 16 ""
;8 Button 0x54030040 0x0 507 199 16 16 ""
;2 Button 0x54030000 0x4 473 235 50 14 "   Exit"
;9 Button 0x54030000 0x4 4 217 50 14 "     Find Item/Go"
;10 Button 0x54030000 0x4 57 217 50 14 "      Run Item"
;11 Button 0x54030000 0x4 110 217 50 14 "      Select to Del"
;13 Button 0x54030000 0x4 473 217 50 14 "   Scroll Down"
;5 Button 0x54030000 0x4 110 235 50 14 "      De-Select"
;3 Button 0x54030000 0x4 162 217 50 14 "      Delete Sel"
;12 Button 0x54030000 0x4 215 217 50 14 "      Foldr in Reg"
;17 Button 0x54030000 0x4 215 235 50 14 "      F in Reg - Go"
;15 Button 0x54030000 0x4 4 235 50 14 "     Find - Exit"
;16 Button 0x54030000 0x4 57 235 50 14 "     Run - Exit"
;14 Button 0x54030000 0x4 268 217 50 14 "      Working Fol"
;18 Button 0x54030000 0x4 268 235 50 14 "      W Fol - Go"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

;---> Comment 25-12-2016 07:16:20 : Καλά Χριστούγεννα
;,;;Version with QM grid, template : CNS
str controls = "4 6"
str qmg4 e6



sub.IconCol0
sub.IconCol2

int r=ShowDialog(dd &sub.DlgProc &controls 0 0 0 0 0 0 0 sicos)
if(r=3)
,goto g1
if(!r) ret

#sub DlgProc v
function# hDlg message wParam lParam

str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err    caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : <open>%s</open>%s" NowT si _error.place si caller

ARRAY(int)- col0
ARRAY(int)- col2
str- sl
int- hlb hw he it
__Hicon-- ic
DlgGrid g.Init(hDlg 4)
str- sfil sext
int- savs
DateTime tm


sel message
,case WM_INITDIALOG
,QmRegisterDropTarget(id(4 hDlg) hDlg 16)
;,g.GridStyleSet(1|8)

,;add columns
,g.ColumnsAdd("Type,4%,7[]Cd,3%,7[]BookMarked on,15%,7[]Folder / File,78%,7" 1)
,g.FromCsv(slo "|" 0)

,ic=GetIcon("%IconFol%\leftarrow.ICO")
,SendMessage(id(7 hDlg) BM_SETIMAGE IMAGE_ICON ic)
,ic=GetIcon("%IconFol%\rightarrow.ICO")
,SendMessage(id(8 hDlg) BM_SETIMAGE IMAGE_ICON ic)
,
,__Font-- f
,f.Create("Tahoma" 9)
,f.SetDialogFont(hDlg "6")
,hw=hDlg
,__ImageList- f_il.Load("$my qm$\imagelists\FilMngmnt.bmp")
,DT_SetButtonIcon hDlg f_il F"9=55 15=55 10=39 16=39 3=64 13=52 2=42 11=62 5=63 12=2 14=4 17=66 18=68"

;,Column0 icons
;,g.SetImagelist(f_il 0)
,
;,Column2 icons
;$BkM
,__ImageList- ilx
,__Stream x
,str fil="C:\Documents and Settings\S.E.Simopoulos\My QM\imagelists\Extensions.txt"
,int fl=0x00000002 ;;STGM_READ
,if(!FileExists(fil))
,,_s=F"File does not exist : <c 172>{fil}</c>   - Caller : <open>{caller}</open> "
,,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,mac "Warning_QM" si 0
,,end
,x.CreateOnFile(fil fl)
,ilx=ImageList_Read(x)
,g.SetImagelist(ilx 0)
,ARRAY(int)+ arrintSelectedRows.create(g.RowsCountGet)

,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
;OutWinMsg message wParam lParam

sel wParam
,
,case 12
,rget _s "ses_last_dir"
,sub.PrepareFol(_s hDlg)

,case 17
,rget _s "ses_last_dir"
,sub.PrepareFol(_s hDlg)
,sub.fRun
,DT_Ok hDlg

,case 14
,rget _s "ses_work_dir"
,sub.PrepareFol(_s hDlg)

,case 18
,rget _s "ses_work_dir"
,sub.PrepareFol(_s hDlg)
,sub.fRun
,DT_Ok hDlg

,case 9
,_s.getwintext(id(6 hDlg))
,if empty(_s)
,,beeS 1431 75
,,Task_Message "You must select a row-file first" 0 171 2
,,ret
,sub.fFind

,case 15
,_s.getwintext(id(6 hDlg))
,if empty(_s)
,,beeS 1431 75
,,Task_Message "You must select a row-file first" 0 171 2
,,ret
,sub.fFind
,DT_Ok hDlg
,

,case 10
,_s.getwintext(id(6 hDlg))
,if empty(_s)
,,beeS 1431 75
,,Task_Message "You must select a row-file first" 0 171 2
,,ret
,sub.fRun

,case 16
,_s.getwintext(id(6 hDlg))
,if empty(_s)
,,beeS 1431 75
,,Task_Message "You must select a row-file first" 0 171 2
,,ret
,sub.fRun
,DT_Ok hDlg
,

,case 11
,delSel=1
,
,case 3 ;;Get-Delete Selected
,delSel=0
,ARRAY(int) arrintGetSelectedRows
,int TotSelectedRows = g.RowsSelectedGet(arrintGetSelectedRows)
,outt F"Total Selected Rows = {TotSelectedRows}"
,if TotSelectedRows=0
,,beeS 1431 75
,,Task_Message "Nothing selected to delete" 0  171 2
,,ret
,;out F"Length3 = {arrintGetSelectedRows.len}"    
,int    i=mes(F"Delete Selected {TotSelectedRows} ?" "Confirm to Delete" "YN")
,if i<>89; ret

,str s1 s3 ak
,,
,for _i 0 arrintGetSelectedRows.len
,,int iro=arrintGetSelectedRows[_i]
,,s1=g.CellGet(iro 1)
,,s3=g.CellGet(iro 3)
,,ak.from(s1 "  " s3)
,,outt F"Del: {iro} - {ak}"
,,;ARRAY(str) tzu
,,;BkmF.GetAll(tzu)
,,;for int'm 0 tzu.len
,,,;out F"{m} - {tzu[m]}"
,,
,,BkmF.Remove(ak)
,,err
,,,_s=F"{_error.description} : <c 172>Info</c> - Caller : <open>{caller}</open> "
,,,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,,mac "Warning_QM" si 0
,,,end
,,if _hresult
,,,_s=F"Entry not deleted : <c 172> {ak}</c>   - Caller : <open>{caller}</open> "
,,,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,,mac "Warning_QM" si 0
,,,end

,SaveISMFile(BkmF "$my qm$\Files\DataBases\BkmFiled.txt") ;;files
,DT_Ok hw 3

,case 5
;,out F"Length1 = {arrintGetSelectedRows.len}"    
,g.RowSelect(-1)
;,out F"Length2 = {arrintGetSelectedRows.len}"    
,
,case 7
,,he=id(6 hDlg)
,,SetFocus he
,,SendMessage he EM_SETSEL  0 0

,case 8
,,he=id(6 hDlg)
,,SetFocus he
,,SendMessage he EM_SETSEL 1000000000 1000000000

,case 13
,sub.ScrollDown hDlg
,
,case IDCANCEL
,DT_Cancel hDlg
,
,case IDOK
,DT_Ok hDlg

,
ret 1
;messages3
;OutWinMsg message wParam lParam

NMHDR* nh=+lParam
sel nh.idFrom
,case 4
,GRID.QM_NMLVDATA* cd=+nh
,NMLVDISPINFO* di=+nh
,NMLISTVIEW* nlv=+nh
,NMITEMACTIVATE* na=+nh

,sel nh.code
,,
,,;These notifications are from QM_Grid.
,,;All text coming from QM_Grid is in QM format (UTF-8 or ANSI, depending on QM Unicode mode).

;,,QMi SingleClickToMultiSelectDlgGridRow
,,case NM_DBLCLK
,,sel nh.idFrom
,,,case 4
,,,fPath=g.CellGet(na.iItem 3)
,,,outt F"Row click:  {na.iItem} - {fPath}"    
,,,fPath.setwintext(id(6 hw))
,,,folder.getpath(fPath)
,,,filnam.getfilename(fPath 1)
,,,ianal=val(g.CellGet(na.iItem 0))
,,,sub.fRun
,,,

,,case NM_CLICK
,,if delSel
,,,if(arrintSelectedRows[na.iItem])
,,,,arrintSelectedRows[na.iItem] = 0
,,,else
,,,,arrintSelectedRows[na.iItem] = 1
,,,for _i 0 g.RowsCountGet
,,,,if(arrintSelectedRows[_i])
,,,,,g.RowSelect(_i 1)        
,,,,,
,,if na.iItem>=0
,,,fPath=g.CellGet(na.iItem 3)
,,,outt F"Row click:  {na.iItem} - {fPath}"    
,,,fPath.setwintext(id(6 hw))
,,,folder.getpath(fPath )
,,,filnam.getfilename(fPath 1)
,,,ianal=val(g.CellGet(na.iItem 0))

,,
,,case LVN_ITEMACTIVATE ;;when user clicks or double clicks a row (depends on list view extended style), and it does not begin cell edit mode
,,outt F"item activated: {na.iItem} {na.iSubItem}"
,,if na.iItem>=0
,,,it=na.iItem
;............... At present inactive
,,,,,
,,,,,
,,case LVN_COLUMNCLICK ;;click header
,,g.Sort(4|0x10000 nlv.iSubItem)
,,
,,
,,case LVN_BEGINLABELEDIT ;;when begins cell edit mode
,,out "begin edit: item=%i subitem=%i text=%s" di.item.iItem di.item.iSubItem di.item.pszText
,,if di.item.iSubItem=2
,,,g.SetButtonProp(1 "Browse...")
,,
,,case LVN_ENDLABELEDIT ;;when ends cell edit mode
,,out "end edit: item=%i subitem=%i text=%s" di.item.iItem di.item.iSubItem di.item.pszText
,,savs=1
,,;out di.item.iItem ;; row
,,;out di.item.iSubItem ;; column
,,if di.item.iSubItem=2
,,,fPath=di.item.pszText
,,,FileGetAttributes(fPath 0 tm)
,,,err
,,,,_s=F"{_error.description} : <c 172>''{fPath}''</c> - Caller : <open>{caller}</open> "
,,,,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,,,mac "Warning_QM" si 0
,,,,ret
,,,tm.UtcToLocal
,,,_s=tm.ToStr(4)
,,,g.CellSet(di.item.iItem 1 _s)
,,,sext.GetFilenameExt(fPath)
,,,if empty(sext)
,,,,sext="empty"
,,,col0[]=ReadExtGiveIl(sext)

,,
,,case GRID.LVN_QG_BUTTONCLICK ;;when user clicks button
,,out "button: item=%i subitem=%i text=%s" cd.item cd.subitem cd.txt
,,if cd.subitem=2
,,,if(OpenSaveDialog(0 _s)) _s.setwintext(cd.hctrl)
,,,
,,,
,,case LVN_GETDISPINFOW
,,NMLVDISPINFOW& ddi=+nh

,,LVITEMW& u=ddi.item
,,if u.iSubItem=0
;,,,out F"Disp: {u.iItem} {u.iSubItem}"
,,,u.mask|LVIF_IMAGE
,,,int icu=iif(u.iItem<col0.len  col0[u.iItem] 0)
,,,u.iImage=icu

,,if u.iSubItem=2 ;; Select column to show icon here
,,,u.mask|LVIF_IMAGE
,,,u.iImage=col2[u.iItem]        


#sub IconCol0 v
;Routine called initially
;,FilExtAnal
;;0 : file has no extension - 59
;;1 : file has a normal extension, othen than lnk - 58
;;2 : file is a shortcut of a file without extension - use bullet (nap)
;;3 : file is a shortcut of a normal file - 56
;;4 : file is folder - 2
;;5 : file is folder link - 37
;;6 : File is a shortcut - No target is found - 61
;;7 : file is a QM shortcut - Parameter line is returned as target - 57
;;8 : not used
;;9 : item does not exist - 60

;Code - Numbres in "$my qm$\imagelists\FilMngmnt.bmp" - "$my qm$\imagelists\Extensions.npp"
;0 - 59 - 4 ;; $documents$\Local Settings\sysman\icons\Ico\empty.ico
;1 -  - 5 ;; $documents$\Local Settings\sysman\icons\Ico\send-file-multi-size_rb.ico
;2 - 0 - 0 ;; $documents$\Local Settings\sysman\icons\Ico\bullet_QM.ico
;3 - 56 - 6;; $documents$\Local Settings\sysman\icons\Ico\Shortcut2.ico
;4 -  - 7 ;; $documents$\Local Settings\sysman\icons\Ico\folder-multi-sizeRB.ico
;5 - 37 - 8 ;; $documents$\Local Settings\sysman\icons\Ico\GoTo1.ico
;6 - 61 - 9 ;; $documents$\Local Settings\sysman\icons\Ico\qm6.ico
;7 - 57 - 10 ;; $documents$\Local Settings\sysman\icons\Ico\qm_exe_2.ico
;8  - 59 - 4 ;; Not used
;9 - 60 - 11;; $documents$\Local Settings\sysman\icons\Ico\delete.ico

ARRAY(int) nanal
nanal[]=4
nanal[]=5
nanal[]=0
nanal[]=6
nanal[]=7
nanal[]=8
nanal[]=9
nanal[]=10
nanal[]=4
nanal[]=11

int ie
for ie 0 manal.len
,_i=manal[ie]
,col0[]=nanal[_i]
,
ret

#sub IconCol2 v
;Routine called initially
str sext
int ie
for ie 0 a.len
,_s.GetFilenameExt(a[ie])
,if empty(_s)
,,sext="empty"
,else
,,sext=_s
,col2[]=ReadExtGiveIl(sext)

ret

#sub LvItemFromPoint
function# hlv int&subItem

;Sends LVM_HITTEST and returns item index of listview item from mouse.
;subItem - receives subitem index.

LVHITTESTINFO ht
xm &ht.pt hlv 1
SendMessage(hlv LVM_SUBITEMHITTEST 0 &ht)
subItem=ht.iSubItem
outt F"{subItem} - {ht.iItem}"
ret ht.iItem

#sub ScrollDown
function hw

Acc a.Find(hw "PUSHBUTTON" "Line down" "class=QM_Grid[]id=4" 0x1025 0)
if a.NotFound; ret
a.Mouse(0)
int y cy
a.Location(0 y 0 cy)
mou+ 0 -(cy/2)-1

key+ S
lef
key- S

#sub fRun v

str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err    caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : <open>%s</open>%s" NowT si _error.place si caller

if empty(fPath)
,_s="Empty Path"
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,beeS 1431 75
,Task_Message _s 0 171 2
,ret
out ianal
sel ianal

,case 1
,run fPath

,case 3
,SHORTCUTINFO sii
,GetShortcutInfoEx(fPath &sii)
,err
,,_s=_error.description
,,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,mac "Warning_QM" si
,,end
,str starget=sii.target
,run starget

,
,
,case 4
,run fPath "" "Explore" "" 3|0x1000

,case else
,_s="Please examine analysis type of this item"
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,beeS 1431 75
,Task_Message _s 0 171 2

ret

#sub fFind v

str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err    caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : <open>%s</open>%s" NowT si _error.place si caller

if ianal=9
,_s="File does not exist on disk"
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,beeS 1431 75
,Task_Message _s 0 171 2
,ret

RestoreLastExplorer ;;(1)

GetFilInExplorer folder filnam
ret

#sub PrepareFol v
function str'pFol int'hw

pFol.setwintext(id(6 hw))
ianal=4
fPath=pFol
folder.getpath(fPath)
filnam.getfilename(fPath 1)
outt F"{fPath} - {folder} - {filnam}"

ret


Forum Jump:


Users browsing this thread: 1 Guest(s)