' coded by Mesut Akcan 15 July 00
$optimize on
$typecheck on
$include "rapidq.inc"
DECLARE SUB ShellExecute LIB "SHELL32" ALIAS "ShellExecuteA" _
(HWnd AS LONG, lpOperation AS STRING, lpFile AS STRING, _
lpParameters AS STRING, lpDirectory AS STRING, nShowCmd AS LONG)
DECLARE FUNCTION NViewLibLoad LIB "NVIEWLIB" ALIAS "NViewLibLoad" _
(FileName AS STRING, Progress AS INTEGER) AS INTEGER
'DECLARE FUNCTION GetWidth LIB "NVIEWLIB" ALIAS "GetWidth" AS INTEGER
'DECLARE FUNCTION GetHeight LIB "NVIEWLIB" ALIAS "GetHeight" AS INTEGER
declare sub frmresize
declare sub dtreeChange
declare sub flClick
declare sub imgCenter
declare sub frmKeyDown (Key AS Word, Shift AS INTEGER)
DECLARE SUB mnu_EditDfEditor_Click (Sender as QMENUITEM)
DECLARE SUB mnu_ViewDfViewer_Click (Sender as QMENUITEM)
DECLARE SUB mnu_Move_Click (Sender as QMENUITEM)
DECLARE SUB mnu_Copy_Click (Sender as QMENUITEM)
DECLARE SUB mnu_Delete_Click (Sender as QMENUITEM)
DECLARE SUB mnu_Exit_Click (Sender as QMENUITEM)
DECLARE SUB mnu_more_Click (Sender as QMENUITEM)
DECLARE SUB mnu_less_Click (Sender as QMENUITEM)
DECLARE SUB mnu_actual_Click
DECLARE SUB mnu_bestfit_Click
DECLARE SUB mnu_About_Click (Sender as QMENUITEM)
dim applicationtitle as string , imgMask as string
applicationtitle = "Picture Viwer v0.0.7 BETA"
imgMask = "*.JPG;*.JIF;*.GIF;*.BMP;*.DIB;*.RLE;*.TGA;*.PCX"
CREATE Form AS QFORM
Caption = applicationtitle
Width = 528
Height = 426
KeyPreview = 1
onkeydown = frmKeyDown
Center
CREATE mnuMain as QMAINMENU
CREATE mnu_File as QMENUITEM
Caption = "&File"
CREATE mnu_EditDfEditor as QMENUITEM
Caption = "&Edit with default editor"
onclick = mnu_EditDfEditor_Click
END CREATE
CREATE mnu_ViewDfViewer as QMENUITEM
Caption = "&View with default viewer"
shortcut = "Enter"
onclick = mnu_ViewDfViewer_Click
END CREATE
CREATE mnu_e as QMENUITEM
Caption = "-"
END CREATE
CREATE mnu_Move as QMENUITEM
Caption = "&Move"
onclick = mnu_Move_Click
END CREATE
CREATE mnu_Copy as QMENUITEM
Caption = "&Copy"
onclick = mnu_Copy_Click
END CREATE
CREATE mnu_Delete as QMENUITEM
Caption = "&Delete"
shortcut ="Del"
onclick = mnu_Delete_Click
END CREATE
CREATE mnu_e2 as QMENUITEM
Caption = "-"
END CREATE
CREATE mnu_Exit as QMENUITEM
Caption = "E&xit"
onclick = mnu_Exit_Click
END CREATE
END CREATE
CREATE mnu_Zoom as QMENUITEM
Caption = "&Zoom"
CREATE mnu_more as QMENUITEM
Caption = "&More Numpad +"
onclick = mnu_more_Click
END CREATE
CREATE mnu_less as QMENUITEM
Caption = "&Less Numpad -"
onclick = mnu_less_Click
END CREATE
CREATE mnu_e3 as QMENUITEM
Caption = "-"
END CREATE
CREATE mnu_actual as QMENUITEM
Caption = "&Actual size Numpad *"
onclick = mnu_actual_Click
END CREATE
CREATE mnu_bestfit as QMENUITEM
Caption = "&Best fit Numpad /"
onclick = mnu_bestfit_Click
END CREATE
CREATE mnu_e4 as QMENUITEM
Caption = "-"
END CREATE
CREATE mnu_auto_bf as QMENUITEM
Caption = "&Auto best fit"
' onclick = mnu_auto_bf_Click
END CREATE
CREATE mnu_e5 as QMENUITEM
Caption = "-"
END CREATE
CREATE mnu_thumbnail as QMENUITEM
Caption = "&Thumbnail"
' onclick = mnu_thumbnail_Click
END CREATE
END CREATE
CREATE mnu_About as QMENUITEM
Caption = "&About"
onclick = mnu_About_Click
END CREATE
END CREATE
'------------------------------ MENU END -------------
CREATE Panel1 AS QPANEL
Width = 161
Height = 399
BorderStyle = 1
Align = 3
CREATE dtree AS Qdirtree '------ dir Tree
Left = 2
Top = 2
Width = 153
Height = 170
OnChange = dtreeChange
END CREATE
CREATE FileListBox1 AS QFILELISTBOX '-- Filelist
Left = 2
Top = 196
Width = 153
Height = 196
mask = imgMask
showicons = 1
OnClick = flClick
END CREATE
END CREATE
CREATE ScrollBox1 AS QSCROLLBOX '--- ScrollBox
AutoScroll = 1
Align = 5
CREATE Image1 AS QIMAGE ' --- Ýmage
AutoSize = 1
END CREATE
END CREATE
CREATE stbar as qstatusbar ' --- statusbar
addpanels = "","",""
panel(0).width = 70
panel(1).width = 140
END CREATE
onresize = frmresize
END CREATE
' ======================================================
' ======================================================
dim act_W as short , act_H as short
image1.textout (1,1,"Picture Viewer",&HFF,&HFFFFFF)
image1.textout (1,15,"v 0.0.7 beta",&HFF,&HFFFFFF)
Form.ShowModal
sub frmresize ' ---------- FRM_SIZE
with panel1
dtree.height = .height/2 - 5
filelistbox1.top = .height/2
filelistbox1.height = .height/2 - 7
end with
call imgCenter
end sub
sub flClick ' -------- File_Click
dim f as qfilestream , fsize as long , fstext as string
f.open(FileListBox1.filename,fmOpenRead) : fsize = f.size : f.close
if fsize < &H400 then
fstext = str$(fsize) + " bytes"
elseif fsize<&H100000 then
fstext = str$(int(fsize/&H400*100)/100) + " Kbytes"
else
fstext = str$(int(fsize/&H100000*100)/100) + " MBytes"
end if
with image1
filelistbox1.cursor = crHourGlass : .handle = ""
stbar.panel(1).caption = "" : stbar.panel(0).caption = ""
.handle = NViewLibLoad (FileListBox1.filename, 0)
stbar.panel(1).caption = fstext
act_w = .width : act_H = .height
stbar.panel(0).caption = str$(act_w) + "x" + str$(act_H)
filelistbox1.cursor = crDefault
call imgCenter
end with
end sub
sub imgCenter '------- img Center
with image1
.left = scrollbox1.width / 2 - .width / 2
.top = scrollbox1.height / 2 - .height / 2
end with
end sub
' ------- Frm KeyDown
sub frmKeyDown (Key AS Word, Shift AS INTEGER)
dim ratio as single
with image1
select case key
case 27 : application.terminate ' esc
case 109 ' ---
if .height<10 or .width<10 then exit sub
ratio = 0.5
case 107 ' +++
if (.width / act_w)>10 then exit sub
ratio = 2
case 106 : call mnu_actual_Click ' ***
case 111 : call mnu_bestfit_Click ' ///
end select
if ratio <> 0 then
.height = .height * ratio
.width = .width * ratio
.stretch = 1
call imgCenter
end if
end with
end sub
SUB mnu_EditDfEditor_Click (Sender as QMENUITEM)
ShellExecute 0, "Edit", filelistbox1.filename, "", "", 1
END SUB
SUB mnu_ViewDfViewer_Click (Sender as QMENUITEM)
ShellExecute 0, "Open", filelistbox1.filename, "", "", 1
END SUB
SUB mnu_Move_Click (Sender as QMENUITEM)
END SUB
SUB mnu_Copy_Click (Sender as QMENUITEM)
END SUB
SUB mnu_Delete_Click (Sender as QMENUITEM) ' ----- DELETE ------
dim fname as string , r as long , i as short
fname = filelistbox1.filename
r = messagebox("Do you wish to delete " + chr$(13) + fname ,"Delete file", 52)
if r = 6 then ' Yes
with filelistbox1
i = .itemindex
kill (fname)
.mask= ""
.mask= imgMask
if i = .itemcount then i--
.itemindex = i
call flClick
end with
end if
END SUB
' ----- actual size
SUB mnu_actual_Click
image1.width = act_W
image1.height = act_H
call imgCenter
end sub
' ----- best fit
SUB mnu_bestfit_Click (Sender as QMENUITEM)
Dim ratio as double
if act_W > act_H then ratio = (scrollbox1.Width-10)/act_W
if act_H >= act_W then ratio = (scrollbox1.height-10)/act_H
with image1
.width = act_W*ratio
.height = act_H*ratio
.stretch = 1
end with
call imgCenter
end sub
sub dtreeChange : filelistbox1.directory = dtree.directory : end sub
sub mnu_more_Click (Sender as QMENUITEM):call frmKeyDown(107,0):end sub'+++
sub mnu_less_Click (Sender as QMENUITEM):call frmKeyDown(109,0):end sub'---
SUB mnu_About_Click (Sender as QMENUITEM)
showmessage applicationtitle + chr$(13) + "Mesut Akcan" + chr$(13) + "http://kaynak.cjb.net"
END SUB
SUB mnu_Exit_Click (Sender as QMENUITEM):application.terminate:END SUB