- 28 Marzo 2009
- 988
- 0
- Miglior risposta
- 0
il codice è questo:
/*
a simple SDI editor (like notepad). Created by
using a multiline edit control sized to the window
version 1.2 for EBASIC.
Compile with a WINDOWS target
*/
def win:window
def left,top,width,height,hprinter:int
def startpg,endpg,copies,collate:int
def filename,ln,printer:string
def file1:FILE
def buffer[32766]:ISTRING
run = 0
'Open our main window, get its client size and create the control
openwindow win,0,0,640,400,@SIZE|@MINBOX|@MAXBOX|@MAXIMIZED|@NOAUTODRAW,0,"EDITOR V1.2 By Kevin",&mainwindow
getclientsize win,left,top,width,height
control win,@EDIT,"",left,top,width,height,@CTEDITMULTI|@HSCROLL|@VSCROLL,1
BEGINMENU win
MENUTITLE "&File"
MENUITEM "&Apri\tCtrl+L",0,1
MENUITEM "&Salva\tCtrl+S",0,2
MENUITEM "&Stampa\tAlt+P",0,4
MENUITEM "&Esci\tCtrl+C",0,3
MENUTITLE "&Opzioni"
MENUITEM "Cambia Carattere\tF4",0,5
ENDMENU
'add our keyboard accelerators
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("L"),1
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("S"),2
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("C"),3
ADDACCELERATOR win,@FALT|@FVIRTKEY,ASC("P"),4
ADDACCELERATOR win,@FVIRTKEY,0x73,5:'F4 key changes font
SETCONTROLCOLOR win,1,0,RGB(255,255,255)
'process messages until somebody closes us
run = 1
waituntil run=0
closewindow win
end
'this is the handler subroutine for the window
'process @IDSIZE to size the edit control
'process the menus
'process @IDCLOSEWINDOW to quit the program
sub mainwindow
select @MESSAGE
case @IDCLOSEWINDOW
run = 0
case @IDSIZE
'size the edit control to match the client size of the window
'we use CONTROLEXISTS to verify the existance of the edit control
'because the first @IDSIZE message is sent while the window is being created
'but before we have a chance to add the edit control.
if CONTROLEXISTS(win,1)
getclientsize win,left,top,width,height
setsize win,left,top,width,height,1
endif
case @IDMENUPICK
select @MENUNUM
case 5
GOSUB changefont
case 4
'dump the edit control to the printer
GOSUB doprint
case 3
'quit the program
run = 0
case 2
'save the file
GOSUB dosave
case 1
'open a file
GOSUB doopen
endselect
endselect
return
endsub
'------------- DOOPEN ----------------
SUB doopen
filename = filerequest("Load File",win,1)
if(len(filename) > 0)
buffer = ""
if( !openfile(file1,filename,"R"))
do
if(read(file1,ln) = 0)
if len(buffer) < (32766-257)
buffer = buffer + ln + chr$(13) + chr$(10)
endif
endif
until eof(file1)
closefile file1
setcontroltext win,1,buffer
endif
endif
RETURN
endsub
'------------- DOSAVE -----------------
SUB dosave
filename = filerequest("Save File",win,0)
if(len(filename) > 0)
if(openfile(file1,filename,"W") = 0)
buffer = getcontroltext(win,1)
write file1,buffer
closefile file1
endif
endif
RETURN
endsub
'------------- DOPRINT ----------------
'prints the contents of the edit control
'using straight text printing.
'This method won't work for GDI only printers
'--------------------------------------
SUB doprint
startpg = 1
endpg = 1
copies = 1
collate = 1
printer = PRTDIALOG(win,startpg,endpg,copies,collate)
hprinter = OPENPRINTER(printer,"Document","TEXT")
if(hprinter)
buffer = getcontroltext(win,1)
WRITEPRINTER hprinter, buffer
CLOSEPRINTER hprinter
endif
RETURN
endsub
'------------- CHANGEFONT -------------
SUB changefont
DEF size,weight,flags,col:int
DEF fontname:string
size = 12
weight = 400
flags = 0
col = 0
fontname = FONTREQUEST(win,size,weight,flags,col)
if(fontname <> "")
SETFONT win,fontname,size,weight,flags,1
endif
SETCONTROLCOLOR win,1,col,RGB(255,255,255)
RETURN
endsub
che linguaggio è?
/*
a simple SDI editor (like notepad). Created by
using a multiline edit control sized to the window
version 1.2 for EBASIC.
Compile with a WINDOWS target
*/
def win:window
def left,top,width,height,hprinter:int
def startpg,endpg,copies,collate:int
def filename,ln,printer:string
def file1:FILE
def buffer[32766]:ISTRING
run = 0
'Open our main window, get its client size and create the control
openwindow win,0,0,640,400,@SIZE|@MINBOX|@MAXBOX|@MAXIMIZED|@NOAUTODRAW,0,"EDITOR V1.2 By Kevin",&mainwindow
getclientsize win,left,top,width,height
control win,@EDIT,"",left,top,width,height,@CTEDITMULTI|@HSCROLL|@VSCROLL,1
BEGINMENU win
MENUTITLE "&File"
MENUITEM "&Apri\tCtrl+L",0,1
MENUITEM "&Salva\tCtrl+S",0,2
MENUITEM "&Stampa\tAlt+P",0,4
MENUITEM "&Esci\tCtrl+C",0,3
MENUTITLE "&Opzioni"
MENUITEM "Cambia Carattere\tF4",0,5
ENDMENU
'add our keyboard accelerators
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("L"),1
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("S"),2
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("C"),3
ADDACCELERATOR win,@FALT|@FVIRTKEY,ASC("P"),4
ADDACCELERATOR win,@FVIRTKEY,0x73,5:'F4 key changes font
SETCONTROLCOLOR win,1,0,RGB(255,255,255)
'process messages until somebody closes us
run = 1
waituntil run=0
closewindow win
end
'this is the handler subroutine for the window
'process @IDSIZE to size the edit control
'process the menus
'process @IDCLOSEWINDOW to quit the program
sub mainwindow
select @MESSAGE
case @IDCLOSEWINDOW
run = 0
case @IDSIZE
'size the edit control to match the client size of the window
'we use CONTROLEXISTS to verify the existance of the edit control
'because the first @IDSIZE message is sent while the window is being created
'but before we have a chance to add the edit control.
if CONTROLEXISTS(win,1)
getclientsize win,left,top,width,height
setsize win,left,top,width,height,1
endif
case @IDMENUPICK
select @MENUNUM
case 5
GOSUB changefont
case 4
'dump the edit control to the printer
GOSUB doprint
case 3
'quit the program
run = 0
case 2
'save the file
GOSUB dosave
case 1
'open a file
GOSUB doopen
endselect
endselect
return
endsub
'------------- DOOPEN ----------------
SUB doopen
filename = filerequest("Load File",win,1)
if(len(filename) > 0)
buffer = ""
if( !openfile(file1,filename,"R"))
do
if(read(file1,ln) = 0)
if len(buffer) < (32766-257)
buffer = buffer + ln + chr$(13) + chr$(10)
endif
endif
until eof(file1)
closefile file1
setcontroltext win,1,buffer
endif
endif
RETURN
endsub
'------------- DOSAVE -----------------
SUB dosave
filename = filerequest("Save File",win,0)
if(len(filename) > 0)
if(openfile(file1,filename,"W") = 0)
buffer = getcontroltext(win,1)
write file1,buffer
closefile file1
endif
endif
RETURN
endsub
'------------- DOPRINT ----------------
'prints the contents of the edit control
'using straight text printing.
'This method won't work for GDI only printers
'--------------------------------------
SUB doprint
startpg = 1
endpg = 1
copies = 1
collate = 1
printer = PRTDIALOG(win,startpg,endpg,copies,collate)
hprinter = OPENPRINTER(printer,"Document","TEXT")
if(hprinter)
buffer = getcontroltext(win,1)
WRITEPRINTER hprinter, buffer
CLOSEPRINTER hprinter
endif
RETURN
endsub
'------------- CHANGEFONT -------------
SUB changefont
DEF size,weight,flags,col:int
DEF fontname:string
size = 12
weight = 400
flags = 0
col = 0
fontname = FONTREQUEST(win,size,weight,flags,col)
if(fontname <> "")
SETFONT win,fontname,size,weight,flags,1
endif
SETCONTROLCOLOR win,1,col,RGB(255,255,255)
RETURN
endsub
che linguaggio è?