$TYPECHECK ON $Option ICON "\rapidq\examples\Object\examples\IconLib.ico" $Include "Rapidq.inc" $Include "\rapidq\examples\Object\QICON.inc" $Include "\rapidq\examples\Object\QCanvasEx.inc" $INCLUDE "\rapidq\examples\Object\QCOLORDIALOG.INC" $INCLUDE "\rapidq\examples\Object\QDrawFocus.INC" $INCLUDE "\rapidq\include\QFileListView.inc" $INCLUDE "\rapidq\examples\Object\QFormEx.inc" $include "\rapidq\examples\Object\QAbout.inc" $Resource CODE as "\rapidq\examples\Object\examples\IconLib.ico" $Resource ICO_DEFAUT as "\rapidq\examples\Object\examples\defaut.ico" $Resource ICO_EXE as "\rapidq\examples\Object\examples\exe.ico" $Resource ICO_DLL as "\rapidq\examples\Object\examples\dll.ico" $Resource ICO_IMG as "\rapidq\examples\Object\examples\img.ico" $Resource ICO_SMALL_DEFAUT as "\rapidq\examples\Object\examples\SmallDefaut.ico" $Resource ICO_SMALL_EXE as "\rapidq\examples\Object\examples\SmallExe.ico" $Resource ICO_SMALL_DLL as "\rapidq\examples\Object\examples\SmallDll.ico" $Resource ICO_SMALL_IMG as "\rapidq\examples\Object\examples\SmallImg.ico" declare Sub open(file as string) declare Sub draw declare sub ChangeDirectory declare sub ShowFiles declare sub ShowIco declare sub ShowIcl declare sub ShowDll declare sub ShowExe declare sub showColor declare sub SaveAs declare sub MenuMask declare sub SelectIco(button as long,x as long,y as long,shift as long) declare Sub ShowList(sender as QMenuItem) declare sub ResizeImage declare sub OnAbout const Offset=38 dim bitmap as QBITMAP bitmap.PixelFormat=pf24bit bitmap.width=32 bitmap.height=32 dim rect as QRECT dim dest as QRECT dim icon as Qicon dim Dial as QColorDialog dim ImageColor as long ImageColor=&HFFFFFF Dim SaveDialog as QSaveDialog SaveDialog.Filter="icones 16 couleurs(*.ico)|*.ico|icones 256 couleurs(*.ico)|*.ico|bitmap 24 bits(*.bmp)|*.bmp|" SaveDialog.Caption= "Sauver sous" dim popup as QPOPUPMENU dim pop1 as QMENUITEM pop1.caption="&Sauver sous..." pop1.OnClick=SaveAs popup.addItems(pop1) popup.autoPopup=true dim IconSelect as integer dim focus as QDrawFocus focus.noresize=true focus.showcursor=false dim about as QAbout const AppTitle="Icon viewer" const AppVersion="1.1" CREATE Form AS QFormEx Caption=AppTitle Width=640 Height=500 Center DeskBar=true CREATE Menu as QMAINMENU CREATE Menu1 as QMENUITEM caption="&Fichier" CREATE item11 as QMENUITEM caption="&Sauver sous..." OnClick=SaveAs END CREATE CREATE item12 as QMENUITEM caption="&Mode transparent" checked=true OnClick=MenuMask END CREATE END CREATE CREATE Menu2 as QMENUITEM caption="&Affichage" CREATE item1 as QMENUITEM caption="&Couleur de fond" OnClick=ShowColor END CREATE CREATE item2 as QMENUITEM caption="-" END CREATE CREATE item3 as QMENUITEM caption="&Fichiers ico" checked=true OnClick=ShowIco END CREATE CREATE item4 as QMENUITEM caption="&Fichiers icl" checked=true OnClick=ShowIcl END CREATE CREATE item5 as QMENUITEM caption="&Fichiers dll" checked=true OnClick=ShowDll END CREATE CREATE item6 as QMENUITEM caption="&Fichiers exe" checked=true OnClick=ShowExe END CREATE CREATE item7 as QMENUITEM caption="-" END CREATE CREATE item21 as QMENUITEM caption="&Grandes icones" Tag=1 OnClick=ShowList END CREATE CREATE item22 as QMENUITEM caption="&Petites icones" Tag=2 OnClick=ShowList END CREATE CREATE item23 as QMENUITEM caption="&Liste" Tag=3 OnClick=ShowList END CREATE CREATE item24 as QMENUITEM caption="&Détails" Tag=4 checked=true OnClick=ShowList END CREATE END CREATE CREATE Menu3 as QMENUITEM caption="&?" CREATE item31 as QMENUITEM caption="&A Propos..." OnClick=OnAbout END CREATE END CREATE END CREATE CREATE Splitter1 AS QSPLITTER Align=alLeft width=5 END CREATE CREATE DirTree AS QDirTree Align=alLeft InitialDir = CURDIR$ Width =300 OnChange=ChangeDirectory END CREATE CREATE EXEList AS QFileListView Align=alClient Width = 325 ViewStyle=vsReport ExtensionsList.AddItems ("exe","dll","icl","ico") SmallImageList.AddIcoHandle(ICO_SMALL_DEFAUT) LargeImageList.AddIcoHandle(ICO_DEFAUT) SmallImageList.AddIcoHandle(ICO_SMALL_EXE) LargeImageList.AddIcoHandle(ICO_EXE) SmallImageList.AddIcoHandle(ICO_SMALL_DLL) LargeImageList.AddIcoHandle(ICO_DLL) SmallImageList.AddIcoHandle(ICO_SMALL_IMG) LargeImageList.AddIcoHandle(ICO_IMG) SmallImageList.AddIcoHandle(ICO_SMALL_IMG) LargeImageList.AddIcoHandle(ICO_IMG) ColumnCaption(1)="Nom" ColumnCaption(2)="Taille" ColumnCaption(3)="Type" ColumnCaption(4)="Modifié" Mask = "*.dll;*.exe;*.icl;*.ico" OnFileChange=Open END CREATE CREATE Splitter2 AS QSPLITTER Align=alBottom cursor=crVSplit width=5 END CREATE CREATE box as QSCROLLBOX Align=alBottom height=150 OnResize=ResizeImage CREATE image as QCanvasEx top=0 left=0 width=box.width-4 height=box.height-4 fillrect(0,0,image.width,image.height,&HFFFFFF) PopupMenu=Popup OnPaint=Draw OnMouseDown=SelectIco END CREATE END CREATE CREATE Infos AS QSTATUSBAR SizeGrip=false AddPanels "Nombre d'icons:","selection:" Panel(0).width=200 END CREATE END CREATE Form.ShowModal Sub Open(file as string) icon.filename=file image.repaint infos.panel(0).caption="Nombre d'icons:"+str$(icon.count) infos.panel(1).caption="Selection:" End Sub Sub ResizeImage image.width=box.width-4 End Sub Sub Draw() dim i as integer dim col as integer dim x as integer dim y as integer x=0 y=0 focus.remove(image.handle) image.fillrect(0,0,image.width,image.height,ImageColor) if icon.count>1 then if icon.count*Offset>(image.width-Offset) then col=icon.count/((image.width-Offset)/Offset) if box.height<(Offset*col+Offset) then image.height=Offset*col+Offset else image.height=box.height-4 end if else image.height=box.height-4 end if for i=0 to icon.count if x+Offset>image.width then x=0 y=y+Offset end if icon.index=i image.DrawIco(x,y,0,0,Icon.handle) x=x+Offset next i else image.height=box.height-4 image.DrawIco(0,0,0,0,Icon.handle) end if End Sub SUB ChangeDirectory EXEList.Directory =DirTree.Directory END SUB Sub ShowFiles EXElist.Mask="" if item3.checked then if EXElist.Mask="" then EXElist.Mask=EXElist.Mask+"*.ico" else EXElist.Mask=EXElist.Mask+";*.ico" end if end if if item4.checked then if EXElist.Mask="" then EXElist.Mask=EXElist.Mask+"*.icl" else EXElist.Mask=EXElist.Mask+";*.icl" end if end if if item5.checked then if EXElist.Mask="" then EXElist.Mask=EXElist.Mask+"*.dll" else EXElist.Mask=EXElist.Mask+";*.dll" end if end if if item6.checked then if EXElist.Mask="" then EXElist.Mask=EXElist.Mask+"*.exe" else EXElist.Mask=EXElist.Mask+";*.exe" end if end if End Sub Sub ShowIco if item3.checked then item3.checked=false else item3.checked=true end if ShowFiles End Sub Sub ShowIcl if item4.checked then item4.checked=false else item4.checked=true end if ShowFiles End Sub Sub ShowDll if item5.checked then item5.checked=false else item5.checked=true end if ShowFiles End Sub Sub ShowExe if item6.checked then item6.checked=false else item6.checked=true end if ShowFiles End Sub Sub ShowColor Dial.style=cdNormal if Dial.Execute then ImageColor=Dial.Color image.repaint end if End Sub Function Selection(x as long,y as long)as integer dim left as integer dim top as integer dim i as integer left=0 top=0 for i=1 to icon.count if left+Offset>image.width then left=0 top=top+Offset end if if x>left and x<(left+32) and y>top and y<(top+32) then Selection=i IconSelect=i-1 rect.left=left rect.top=top rect.right=left+32 rect.bottom=top+32 focus.start(image.handle,left-1,top-1) focus.draw(image.handle,left+34,top+34,true) end if left=left+Offset next i End function Sub SelectIco(button as long,x as long,y as long,shift as long) if Selection(x,y)=0 then focus.remove(image.handle) infos.panel(1).caption="Selection:icon"+str$(Selection(x,y)) End Sub Sub MenuMask if item12.checked then item12.checked=false else item12.checked=true end if End Sub Sub ShowList(sender as QmenuItem) item21.checked=false item22.checked=false item23.checked=false item24.checked=false sender.checked=true Select Case sender.tag Case 1 ExeList.ViewStyle=vsIcon Case 2 ExeList.ViewStyle=vsSmallIcon Case 3 ExeList.ViewStyle=vsList Case 4 ExeList.ViewStyle=vsReport End Select End Sub Sub SaveAs If SaveDialog.Execute Then Select case SaveDialog.FilterIndex case 1 icon.index=IconSelect if instr(lcase$(SaveDialog.filename),".ico")=0 then icon.saveToFile(SaveDialog.filename+".ico",pf4bit,item12.checked) else icon.saveToFile(SaveDialog.filename,pf4bit,item12.checked) end if case 2 icon.index=IconSelect if instr(lcase$(SaveDialog.filename),".ico")=0 then icon.saveToFile(SaveDialog.filename+".ico",pf8bit,item12.checked) else icon.saveToFile(SaveDialog.filename,pf8bit,item12.checked) end if case 3 dest.left=0 dest.top=0 dest.right=32 dest.bottom=32 bitmap.fillrect(0,0,32,32,&HFFFFFF) Bitmap.copyRect(Dest,image,rect) if instr(lcase$(SaveDialog.filename),".bmp")=0 then Bitmap.saveToFile(SaveDialog.FileName+".bmp") else Bitmap.saveToFile(SaveDialog.FileName) end if end Select end if End Sub Sub OnAbout about.AppName=AppTitle about.AppVersion=AppVersion about.Caption="A propos" about.text="Auteur:Glodt dominique"+chr$(13)+"License libre" about.image.icohandle=Code about.EmailFont.color=&hff0000 about.email="dominique.glodt@libertysurf.fr" about.show End Sub