$PBExportHeader$w_sys_printpage_value.srw
forward
global type w_sys_printpage_value from w_publ_base
end type
type cb_1 from uo_imflatbutton within w_sys_printpage_value
end type
type cb_yy from uo_imflatbutton within w_sys_printpage_value
end type
type cb_ok from uo_imflatbutton within w_sys_printpage_value
end type
type ddlb_orientation from dropdownlistbox within w_sys_printpage_value
end type
type em_column from editmask within w_sys_printpage_value
end type
type st_2 from statictext within w_sys_printpage_value
end type
type st_3 from statictext within w_sys_printpage_value
end type
type ddlb_size from dropdownlistbox within w_sys_printpage_value
end type
type em_column_width from editmask within w_sys_printpage_value
end type
type st_5 from statictext within w_sys_printpage_value
end type
type em_1 from editmask within w_sys_printpage_value
end type
type gb_1 from groupbox within w_sys_printpage_value
end type
type st_4 from statictext within w_sys_printpage_value
end type
type st_1 from statictext within w_sys_printpage_value
end type
type st_6 from statictext within w_sys_printpage_value
end type
type st_paperlist from statictext within w_sys_printpage_value
end type
type st_papersize from statictext within w_sys_printpage_value
end type
end forward

global type w_sys_printpage_value from w_publ_base
integer x = 233
integer y = 112
integer width = 2318
integer height = 708
string title = "页面设置"
boolean minbox = false
windowtype windowtype = response!
cb_1 cb_1
cb_yy cb_yy
cb_ok cb_ok
ddlb_orientation ddlb_orientation
em_column em_column
st_2 st_2
st_3 st_3
ddlb_size ddlb_size
em_column_width em_column_width
st_5 st_5
em_1 em_1
gb_1 gb_1
st_4 st_4
st_1 st_1
st_6 st_6
st_paperlist st_paperlist
st_papersize st_papersize
end type
global w_sys_printpage_value w_sys_printpage_value

type prototypes
function boolean IsWindowsNT() library "PrintCtrl.dll"
SUBROUTINE About() library "PrintCtrl.dll"
function boolean GetDefaultPrinter(ref string PrinterName, int BufferLen) library "PrintCtrl.dll" alias for "GetDefaultPrinter;Ansi"
function boolean GetPrinterPort(ref string PrinterName, ref string Port, int PortLen, ref string Driver, int DriverLen) library "PrintCtrl.dll" alias for "GetPrinterPort;Ansi"
function boolean GetPrinterList(ref string PrinterList, ref long bufferLen) library "PrintCtrl.dll" alias for "GetPrinterList;Ansi"
function boolean GetPrinterStatus(ref string Printer, ref long status) library "PrintCtrl.dll" alias for "GetPrinterStatus;Ansi"
function boolean GetPaperList(ref string Printer, ref string PaperList, ref long bufferLen) library "PrintCtrl.dll" alias for "GetPaperList;Ansi"
function boolean SetPrinterDefault(ref string Printer) library "PrintCtrl.dll" alias for "SetPrinterDefault;Ansi"
function boolean AddCustomPaper( ref string Printer, ref string PaperName, long pwidth, long pheight, long left, long right, long top, long bottom) library "PrintCtrl.dll" alias for "AddCustomPaper;Ansi"
function boolean DeleteCustomPaper(ref string Printer, ref string PaperName) library "PrintCtrl.dll" alias for "DeleteCustomPaper;Ansi"
function boolean SetUserDefinePaper(ref string Printer, ref long pWidth, ref long pHeight) library "PrintCtrl.dll" alias for "SetUserDefinePaper;Ansi"
function boolean GetUserDefinePaperMinMax(ref string Printer, ref long minWidth, ref long minHeight, ref long maxWidth, ref long maxHeight) library "PrintCtrl.dll" alias for "GetUserDefinePaperMinMax;Ansi"
function boolean GetDefaultPaper(ref string Printer, ref string PaperName, ref int nOrientation) library "PrintCtrl.dll" alias for "GetDefaultPaper;Ansi"
function boolean SetDefaultPaper(ref string Printer, ref string PaperName, int nOrientation) library "PrintCtrl.dll" alias for "SetDefaultPaper;Ansi"
function boolean GetDefaultPaper(ref string Printer, ref string PaperName,ref long nPapserSize, ref long nOrientation) library "PrintCtrl.dll" alias for "GetDefaultPaper;Ansi"
function boolean GetPaperName(ref string Printer, ref string PaperName, int PaperSize) library "PrintCtrl.dll" alias for "GetPaperName;Ansi"
function boolean GetPaperSize(ref string Printer, ref string PaperName, ref int PaperSize) library "PrintCtrl.dll" alias for "GetPaperSize;Ansi"
function boolean GetBinNameList(ref string Printer, ref string BinNameList) library "PrintCtrl.dll" alias for "GetBinNameList;Ansi"
function boolean GetBin(ref string Printer, ref string BinName, ref int Bin) library "PrintCtrl.dll" alias for "GetBin;Ansi"
function boolean GetBinName(ref string Printer, ref string BinName, int Bin) library "PrintCtrl.dll" alias for "GetBinName;Ansi"
end prototypes

type variables
datawindow obj_dw
string dft_printername
long orientation_selected

end variables

forward prototypes
public subroutine wf_getpapersize ()
public subroutine wf_getpaperlist ()
end prototypes

public subroutine wf_getpapersize ();String printername
String papername
Boolean rt

if ddlb_size.text = '[默认]' then
	em_1.Text = '0'
	return 
end if

printername = dft_printername
IF printername = "" THEN
	st_papersize.Text = "请选择一个打印机！"
	RETURN
END IF

papername = ddlb_size.text
IF papername = "" THEN
	st_papersize.Text = "请选择一个纸张！"
	RETURN
END IF
Int size = 0
rt = GetPaperSize(REF printername, REF papername, REF size)
IF rt THEN
	em_1.Text = String(size)
ELSE
	st_papersize.Text = "函数调用错误"
END IF

end subroutine

public subroutine wf_getpaperlist ();String printerName
String paperList
Long bufferlen = 0
Boolean rt
Long p1,p2
p1 = 1
p2 = 0


printerName = dft_printername
IF printerName = "" THEN
	st_paperlist.Text = "请选择一个打印机！"
	RETURN
END IF
ddlb_size.AddItem('[默认]')
rt = GetPaperList(REF printerName, REF paperList, REF bufferlen)
If (NOT rt) AND bufferlen > 0 THEN
	paperList = Space(bufferlen)
	rt = GetPaperList(REF printerName, REF paperList, REF bufferlen)
	IF rt THEN
		p2 = Pos(paperList,"~t",p1)
		DO WHILE p2 > 0
			ddlb_size.AddItem(Mid(paperList,p1,p2 - p1))
			p1 = p2+1
			p2 = Pos(paperList,"~t",p1)
		LOOP
	END IF
ELSE
	st_paperlist.Text = "调用函数出错！"
END IF



end subroutine

on w_sys_printpage_value.create
int iCurrent
call super::create
this.cb_1=create cb_1
this.cb_yy=create cb_yy
this.cb_ok=create cb_ok
this.ddlb_orientation=create ddlb_orientation
this.em_column=create em_column
this.st_2=create st_2
this.st_3=create st_3
this.ddlb_size=create ddlb_size
this.em_column_width=create em_column_width
this.st_5=create st_5
this.em_1=create em_1
this.gb_1=create gb_1
this.st_4=create st_4
this.st_1=create st_1
this.st_6=create st_6
this.st_paperlist=create st_paperlist
this.st_papersize=create st_papersize
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_1
this.Control[iCurrent+2]=this.cb_yy
this.Control[iCurrent+3]=this.cb_ok
this.Control[iCurrent+4]=this.ddlb_orientation
this.Control[iCurrent+5]=this.em_column
this.Control[iCurrent+6]=this.st_2
this.Control[iCurrent+7]=this.st_3
this.Control[iCurrent+8]=this.ddlb_size
this.Control[iCurrent+9]=this.em_column_width
this.Control[iCurrent+10]=this.st_5
this.Control[iCurrent+11]=this.em_1
this.Control[iCurrent+12]=this.gb_1
this.Control[iCurrent+13]=this.st_4
this.Control[iCurrent+14]=this.st_1
this.Control[iCurrent+15]=this.st_6
this.Control[iCurrent+16]=this.st_paperlist
this.Control[iCurrent+17]=this.st_papersize
end on

on w_sys_printpage_value.destroy
call super::destroy
destroy(this.cb_1)
destroy(this.cb_yy)
destroy(this.cb_ok)
destroy(this.ddlb_orientation)
destroy(this.em_column)
destroy(this.st_2)
destroy(this.st_3)
destroy(this.ddlb_size)
destroy(this.em_column_width)
destroy(this.st_5)
destroy(this.em_1)
destroy(this.gb_1)
destroy(this.st_4)
destroy(this.st_1)
destroy(this.st_6)
destroy(this.st_paperlist)
destroy(this.st_papersize)
end on

event open;call super::open;s_print_value s_print
s_print = Message.PowerObjectParm

obj_dw = s_print.obj_dw
dft_printername = s_print.dft_printername

IF obj_dw.DataObject = '' THEN RETURN
IF dft_printername = '' THEN
	String printerName
	Boolean rt
	//	printerName = space(255)
	//	rt = GetDefaultPrinter(ref printerName, 255)
	//	if rt then	
	//		dft_printername = trim(printerName)
	//	else
	//		dft_printername = ''
	//	end if
	
	String ls_fullstring = PrintGetPrinter()
	
	String ls_name, ls_driver, ls_port, ls_temp
	
	Long ll_placell_place,ll_place
	ll_placell_place = Pos (ls_fullstring, "~t")
	ls_name = Left(ls_fullstring, ll_place -1)
	ls_temp = Mid(ls_fullstring, ll_place +1)
	ll_place = Pos (ls_temp, "~t")
	ls_driver = Left(ls_temp, ll_place -1)
	ls_port = Mid(ls_temp, ll_place +1)
	
	dft_printername = ls_driver
	
//	MessageBox(ls_driver,ls_fullstring)
END IF

wf_getpaperlist()

Int ls_int_1,ls_int_2
String ls_papername

ls_int_1 = Integer(String( obj_dw.Object.datawindow.Print.orientation )) + 1
ddlb_orientation.SelectItem( ls_int_1 )

ls_int_2 = Integer(String( obj_dw.Object.datawindow.Print.paper.size ))
em_1.Text = String( obj_dw.Object.datawindow.Print.paper.size )

IF ls_int_2 = 0 THEN
	ddlb_size.SelectItem( 1 )
ELSE
//	IF GetPaperName(REF dft_printername, REF ls_papername, ls_int_2) THEN
//		ddlb_size.SelectItem( ddlb_size.FindItem(ls_papername,1) )
//	END IF
END IF
em_column.Text = String(obj_dw.Object.datawindow.Print.Columns )
em_column_width.Text = String(obj_dw.Object.datawindow.Print.Columns.Width )

orientation_selected = ls_int_1






end event

type cb_func from w_publ_base`cb_func within w_sys_printpage_value
boolean visible = false
integer x = 91
integer y = 484
boolean enabled = false
end type

type cb_exit from w_publ_base`cb_exit within w_sys_printpage_value
integer x = 1701
integer y = 484
end type

type cb_1 from uo_imflatbutton within w_sys_printpage_value
integer x = 1312
integer y = 484
integer width = 311
integer height = 96
integer taborder = 110
string text = "打印设置"
end type

event clicked;call super::clicked;PRINTSETUP()
end event

type cb_yy from uo_imflatbutton within w_sys_printpage_value
integer x = 923
integer y = 484
integer width = 311
integer height = 96
integer taborder = 100
string text = "应用"
end type

event clicked;call super::clicked;
obj_dw.Modify("datawindow.print.orientation="+string(orientation_selected - 1))
obj_dw.Object.datawindow.Print.paper.size = Integer(em_1.Text)
obj_dw.object.datawindow.print.columns=integer(em_column.text)
obj_dw.object.datawindow.print.columns.width=intEGER(em_column_width.text)

SetProfileString(sys_inifilename,'REPORT_PRINTPAGESET','PAPER_SIZE',em_1.Text)
SetProfileString(sys_inifilename,'REPORT_PRINTPAGESET','ORIENTATION',string(orientation_selected - 1))

end event

type cb_ok from uo_imflatbutton within w_sys_printpage_value
integer x = 535
integer y = 484
integer width = 311
integer height = 96
integer taborder = 90
boolean default = true
end type

event clicked;call super::clicked;
obj_dw.Modify("datawindow.print.orientation="+String(orientation_selected - 1))
obj_dw.Object.datawindow.Print.paper.size = Integer(em_1.Text)
obj_dw.Object.datawindow.Print.Columns = Integer(em_column.Text)
obj_dw.Object.datawindow.Print.Columns.Width = Integer(em_column_width.Text)

SetProfileString(sys_inifilename,'REPORT_PRINTPAGESET','PAPER_SIZE',em_1.Text)
SetProfileString(sys_inifilename,'REPORT_PRINTPAGESET','ORIENTATION',String(orientation_selected - 1))
Close(PARENT)


end event

type ddlb_orientation from dropdownlistbox within w_sys_printpage_value
integer x = 379
integer y = 84
integer width = 306
integer height = 304
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
string item[] = {"(默认)","横向","纵向"}
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;orientation_selected=index
end event

type em_column from editmask within w_sys_printpage_value
integer x = 379
integer y = 168
integer width = 306
integer height = 80
integer taborder = 50
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "1"
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "###0"
end type

event modified;IF LONG(THIS.TEXT)<=0 THEN 
	CB_OK.ENABLED=FALSE
ELSE
	CB_OK.ENABLED=TRUE
END IF
end event

type st_2 from statictext within w_sys_printpage_value
integer x = 55
integer y = 176
integer width = 315
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
boolean enabled = false
string text = "打印列数:"
alignment alignment = right!
boolean focusrectangle = false
end type

type st_3 from statictext within w_sys_printpage_value
integer x = 55
integer y = 88
integer width = 315
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
boolean enabled = false
string text = "纸张放置:"
alignment alignment = right!
boolean focusrectangle = false
end type

type ddlb_size from dropdownlistbox within w_sys_printpage_value
integer x = 1083
integer y = 84
integer width = 1093
integer height = 1000
integer taborder = 30
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;wf_getpapersize()

end event

type em_column_width from editmask within w_sys_printpage_value
integer x = 379
integer y = 252
integer width = 306
integer height = 80
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "1.0"
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "######0"
end type

event modified;IF LONG(THIS.TEXT)<=0 THEN 
	CB_OK.ENABLED=FALSE
ELSE
	CB_OK.ENABLED=TRUE
END IF
end event

type st_5 from statictext within w_sys_printpage_value
integer x = 64
integer y = 360
integer width = 672
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
boolean enabled = false
string text = "[3400单位约A4纸宽(21cm)]"
alignment alignment = right!
boolean focusrectangle = false
end type

type em_1 from editmask within w_sys_printpage_value
integer x = 1083
integer y = 168
integer width = 201
integer height = 80
integer taborder = 30
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "none"
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "###0"
end type

type gb_1 from groupbox within w_sys_printpage_value
integer x = 800
integer y = 16
integer width = 1399
integer height = 268
integer taborder = 50
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "纸张参数"
end type

type st_4 from statictext within w_sys_printpage_value
integer x = 55
integer y = 260
integer width = 315
integer height = 60
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
boolean enabled = false
string text = "次列纸边距:"
alignment alignment = right!
boolean focusrectangle = false
end type

type st_1 from statictext within w_sys_printpage_value
integer x = 818
integer y = 176
integer width = 247
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "纸张Size"
alignment alignment = right!
boolean focusrectangle = false
end type

type st_6 from statictext within w_sys_printpage_value
integer x = 818
integer y = 88
integer width = 247
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "纸张列表"
alignment alignment = right!
boolean focusrectangle = false
end type

type st_paperlist from statictext within w_sys_printpage_value
integer x = 818
integer y = 320
integer width = 1362
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 255
long backcolor = 134217739
alignment alignment = right!
boolean focusrectangle = false
end type

type st_papersize from statictext within w_sys_printpage_value
integer x = 818
integer y = 388
integer width = 1362
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 255
long backcolor = 134217739
alignment alignment = right!
boolean focusrectangle = false
end type

