$IFDEF FRANCAIS
CONST lkfile="data\Liens.txt"
$ELSE
CONST lkfile="data\Links.txt"
$ENDIF
DECLARE SUB lkinit
DECLARE SUB lknewclic
DECLARE SUB linksclic
DECLARE SUB lkkeydown(key AS WORD, shift AS INTEGER)
DECLARE SUB DragAcceptFiles LIB "SHELL32" ALIAS "DragAcceptFiles" (hWnd AS LONG, Accept AS LONG)
CONST lkmarginW=0.04
CONST lkVunit=20
CREATE largeimageslist AS QIMAGELIST
width=32 : height=32
clear
END CREATE
CREATE paths AS QSTRINGLIST
duplicates=dupAccept
clear
END CREATE
CREATE LkPanel AS QPANEL
PARENT=Tab
left=4 : top=28
COLOR=colorfond
visible=false
borderstyle=0 : bevelouter=0 : bevelinner=0
CREATE links AS QLISTVIEW
viewstyle=vsIcon
ondblclick=linksclic
COLOR=&hffffff
borderstyle=1
font=appsmallfont
largeimages=largeimageslist
END CREATE
CREATE lknew AS QBUTTON
CAPTION=s_New
onclick=lknewclic
END CREATE
END CREATE
SUB lkinit
lkpanel.width=panelwidth: lkpanel.height=panelheight
WITH links
.left=panelwidth*lkmarginW/2
.top=lkVunit*3
.width=panelwidth*(1-lkmarginW)
.height=panelheight-links.top-lkVunit
END WITH
WITH lknew
.left=links.left : .top=lkVunit
.width=links.width * 0.1 : .height=lkVunit
END WITH
DragAcceptFiles(Form.Handle, 1)
fileprint.enabled=false
editnew.enabled=true
edituse.enabled=false
menuicon.enabled=false
editall.enabled=false
editfind.enabled=false
editfindnext.enabled=false
setfocus(links.handle)
END SUB
CONST MAX_PATH = 260
CONST SHGFI_DISPLAYNAME = &H200
TYPE SHFILEINFO
hIcon AS LONG
iIcon AS LONG
dwAttributes AS LONG
szDisplayName AS STRING * MAX_PATH
szTypeName AS STRING * 80
END TYPE
DECLARE FUNCTION SHGetFileInfo LIB "shell32.dll" ALIAS "SHGetFileInfoA" (BYVAL pszPath AS STRING, BYVAL dwFileAttributes AS LONG, psfi AS SHFILEINFO, BYVAL cbFileInfo AS LONG, BYVAL uFlags AS LONG) AS LONG
FUNCTION getdisplayname(s AS STRING) AS STRING
DIM myfi AS shfileinfo
l=SHGetFileInfo(s,0,myfi,SIZEOF(myfi),SHGFI_DISPLAYNAME)
getdisplayname=IIF(l=0,"Nom non trouvé",myfi.szDisplayName)
END FUNCTION
DECLARE FUNCTION ExtractAssociatedIcon LIB "shell32.dll" ALIAS "ExtractAssociatedIconA" (BYVAL hInst AS LONG, byref lpIconPath AS STRING, byref lpiIcon AS WORD) AS LONG
DECLARE FUNCTION ImageList_AddIcon LIB "comctl32.dll" ALIAS "ImageList_AddIcon" (BYVAL himl AS LONG, BYVAL hIcon AS LONG) AS INTEGER
SUB lkaddlink(ss AS STRING)
DIM s AS STRING, iconh AS LONG, lpiIcon AS WORD, iconstr AS STRING
IF (FILEEXISTS(ss)=false)AND(DIREXISTS(ss)=false) THEN
SHOWMESSAGE(s_filenotfound)
EXIT SUB
END IF
s=getdisplayname(ss)
links.additems(s)
paths.additems(ss)
iconstr=ss
iconh=ExtractAssociatedIcon(application.handle,iconstr,lpiIcon)
IF iconh=0 THEN
SHOWMESSAGE("Icône non trouvée")
ELSE
myimageindex=ImageList_AddIcon(largeimageslist.handle, iconh)
links.item(links.itemcount-1).imageindex=myimageindex
END IF
END SUB
SUB openlinks
DIM loadedlinks AS QSTRINGLIST
DIM s AS STRING
IF FILEEXISTS(lkfile)=false THEN EXIT SUB
CHDIR appdir
loadedlinks.loadfromfile(lkfile)
nblinks=loadedlinks.itemcount
FOR i=0 TO nblinks-1
s=loadedlinks.item(i)
lkaddlink(s)
NEXT
END SUB
SUB linksclic
DIM ss AS STRING
i=links.itemindex
IF i<0 THEN EXIT SUB
ss=paths.item(i)
IF ss="" THEN EXIT SUB
IF shellexecute(form.handle,"",ss,"","",SW_SHOW) <=32 THEN SHOWMESSAGE(s_filenotfound)
END SUB
SUB lknewclic
DIM OpenDialog AS QOPENDIALOG
IF OpenDialog.EXECUTE THEN
lkaddlink(opendialog.filename)
END IF
END SUB
SUB lksave
DIM file AS QFILESTREAM
CHDIR appdir
paths.savetofile(lkfile)
DragAcceptFiles(Form.Handle, 0)
END SUB
SUB LKdelete
i=links.itemindex
IF i<0 THEN EXIT SUB
paths.delitems(i)
links.delitems(i)
END SUB
SUB lkcut
clipboard.text=paths.item(links.itemindex)
lkdelete
END SUB
SUB lkcopy
clipboard.text=paths.item(links.itemindex)
END SUB
SUB lkpaste
lkaddlink(clipboard.text)
END SUB
SUB lkpageup
END SUB
SUB lkpagedown
END SUB
SUB lkkeydown(key AS WORD, shift AS INTEGER)
SELECT CASE key
CASE 33 : lkpageup
CASE 34 : lkpagedown
END SELECT
END SUB
SUB lkprint
SHOWMESSAGE(s_addontprint)
END SUB
|