O Exemplo abaixo, mostra como criar uma DataWindow/DataStore dinamicamente, a partir de um SQL.
string VLSerror_syntaxfromSQL, VLSerror_create, VLSnew_syntax, VLSMsgErr, VLSDescricao, VLSLinha Long VLLRow, VLLCodigo, VLLRet, vltotitens
// botão p/ seleção de ocorrências if dwo.name = 'b_ocorr' then lb_ocorr.Visible = True // sql p exibição das ocorrências no listbox VISnew_sql = 'select distinct mi.num_seq_ocorr_prioritaria codigo, oc.dsc_res_ocorr descricao ' + & 'from movto_inspecao mi, ocorrencia oc ' + & 'where mi.num_seq_ocorr_prioritaria = oc.num_seq_ocorr ' + & 'and mi.num_seq_ocorr_prioritaria is not null ' + & 'and mi.cod_proj = ' + String(VILProjOrig) end if
// botão p/ seleção de impedimentosif dwo.name = 'b_imped' then lb_imped.Visible = True // sql p exibição das impedimentos no listbox VISnew_sql = 'select distinct mi.cod_imp_insp codigo, im.dsc_imp_insp descricao ' + & 'from movto_inspecao mi, impedimento_inspecao im ' + & 'where mi.cod_imp_insp = im.cod_imp_insp ' + & 'and mi.cod_imp_insp is not null ' + & 'and mi.cod_proj = ' + String(VILProjOrig)
end if
// Monta dinamicamente o objeto datastore contendo as ocorrências ou impedimentos p/ seleçãoVLSnew_syntax = wtr_trans.SyntaxFromSQL(VISnew_sql, "", VLSerror_syntaxfromSQL)if Len(VLSerror_syntaxfromSQL) > 0 then VLSMsgErr = 'Erro: '+ VLSerror_syntaxfromSQL f_msg(VLSMsgErr, stopsign!) return 1else VLLRet = VIDSSelecao.Create(VLSnew_syntax, VLSerror_create) if Len(VLSerror_create) > 0 or VLLRet <> 1 THEN VLSMsgErr = 'Erro: '+ VLSerror_create f_msg(VLSMsgErr, stopsign!) return 1 end ifend if
VIDSSelecao.SetTransObject(wtr_trans)VIDSSelecao.Retrieve()
Blog criado para documentar e disseminar o conhecimento tecnológico adquirido por Thiago Campos Pereira e colaboradores.
sexta-feira, abril 29, 2005
Site do Celso Cortes
Excelente site de tecnologia contendo informações diversas sobre tecnologia. Vale a pena fazer uma visita!
quarta-feira, abril 27, 2005
PowerBuilder - Mudança de automática da Resolução do Monitor
Na CFLCL, houve a necessidade de se mudar a resolução de todos os monitores, automáticamente, para a configuração 1024X 768.
Para isso, usamos o sequinte código abaixo.
$PBExportHeader$w_res.srw$PBExportComments$change resolutionforwardglobal type w_res from windowend typetype cb_2 from commandbutton within w_resend typetype cb_1 from commandbutton within w_resend typetype devmode from structure within w_resend typeend forward
type devmode from structure character dmdevicename[32] integer dmspecversion integer dmdriverversion integer dmsize integer dmdriverextra long dmfields integer dmorientation integer dmpapersize integer dmpaperlength integer dmpaperwidth integer dmscale integer dmcopies integer dmdefaultsource integer dmprintquality integer dmcolor integer dmduplex integer dmyresolution integer dmttoption integer dmcollate character dmformname[32] integer dmlogpixels long dmbitsperpel long dmpelswidth long dmpelsheight long dmdisplayflags long dmdisplayfrequency long dmicmmethod long dmicmintent long dmmediatype long dmdithertype long dmreserved1 long dmreserved2 long dmPanningWidth long dmPanningHeightend type
global type w_res from windowinteger x = 837integer y = 388integer width = 795integer height = 496boolean titlebar = truestring title = "Untitled"boolean controlmenu = trueboolean minbox = trueboolean maxbox = trueboolean resizable = truecb_2 cb_2cb_1 cb_1end typeglobal w_res w_res
type prototypesFUNCTION long ChangeDisplaySettingsA (ref devmode lpst, ulong Flags) & LIBRARY "USER32.DLL"FUNCTION long EnumDisplaySettingsA (string lpszDeviceName,long iModeNum,ref devmode lpst) & LIBRARY "USER32.DLL" end prototypes
type variables
end variableson w_res.createthis.cb_2=create cb_2this.cb_1=create cb_1this.Control[]={this.cb_2,&this.cb_1}end on
on w_res.destroydestroy(this.cb_2)destroy(this.cb_1)end on
type cb_2 from commandbutton within w_resinteger x = 224integer y = 220integer width = 297integer height = 88integer taborder = 2integer textsize = -10integer weight = 400fontpitch fontpitch = variable!fontfamily fontfamily = swiss!string facename = "Arial"string text = "1024x768"end type
event clicked;devmode dmlong astring ls_nulosetnull(ls_nulo)
//get current configurationa = EnumDisplaySettingsA(ls_nulo,-1,dm)
if a = 0 then messagebox('EnumDisplaySettingsA',"error") returnend if
//set configurationdm.dmPelsWidth = 1024dm.dmPelsHeight = 768
//Change current configurationa = ChangeDisplaySettingsA(dm, 0)if a < 0 then messagebox('ChangeDisplaySettingsA',"error") returnend if end event
type cb_1 from commandbutton within w_resinteger x = 224integer y = 124integer width = 297integer height = 88integer taborder = 1integer textsize = -10integer weight = 400fontpitch fontpitch = variable!fontfamily fontfamily = swiss!string facename = "Arial"string text = "800x600"end type
event clicked;devmode dmlong astring ls_nulosetnull(ls_nulo)
//get current configurationa = EnumDisplaySettingsA(ls_nulo,-1,dm)
if a = 0 then messagebox('EnumDisplaySettingsA',"error") returnend if
//set configurationdm.dmPelsWidth = 800dm.dmPelsHeight = 600
//Change current configurationa = ChangeDisplaySettingsA(dm, 0)if a < 0 then messagebox('ChangeDisplaySettingsA',"error") returnend if
end event
Para isso, usamos o sequinte código abaixo.
$PBExportHeader$w_res.srw$PBExportComments$change resolutionforwardglobal type w_res from windowend typetype cb_2 from commandbutton within w_resend typetype cb_1 from commandbutton within w_resend typetype devmode from structure within w_resend typeend forward
type devmode from structure character dmdevicename[32] integer dmspecversion integer dmdriverversion integer dmsize integer dmdriverextra long dmfields integer dmorientation integer dmpapersize integer dmpaperlength integer dmpaperwidth integer dmscale integer dmcopies integer dmdefaultsource integer dmprintquality integer dmcolor integer dmduplex integer dmyresolution integer dmttoption integer dmcollate character dmformname[32] integer dmlogpixels long dmbitsperpel long dmpelswidth long dmpelsheight long dmdisplayflags long dmdisplayfrequency long dmicmmethod long dmicmintent long dmmediatype long dmdithertype long dmreserved1 long dmreserved2 long dmPanningWidth long dmPanningHeightend type
global type w_res from windowinteger x = 837integer y = 388integer width = 795integer height = 496boolean titlebar = truestring title = "Untitled"boolean controlmenu = trueboolean minbox = trueboolean maxbox = trueboolean resizable = truecb_2 cb_2cb_1 cb_1end typeglobal w_res w_res
type prototypesFUNCTION long ChangeDisplaySettingsA (ref devmode lpst, ulong Flags) & LIBRARY "USER32.DLL"FUNCTION long EnumDisplaySettingsA (string lpszDeviceName,long iModeNum,ref devmode lpst) & LIBRARY "USER32.DLL" end prototypes
type variables
end variableson w_res.createthis.cb_2=create cb_2this.cb_1=create cb_1this.Control[]={this.cb_2,&this.cb_1}end on
on w_res.destroydestroy(this.cb_2)destroy(this.cb_1)end on
type cb_2 from commandbutton within w_resinteger x = 224integer y = 220integer width = 297integer height = 88integer taborder = 2integer textsize = -10integer weight = 400fontpitch fontpitch = variable!fontfamily fontfamily = swiss!string facename = "Arial"string text = "1024x768"end type
event clicked;devmode dmlong astring ls_nulosetnull(ls_nulo)
//get current configurationa = EnumDisplaySettingsA(ls_nulo,-1,dm)
if a = 0 then messagebox('EnumDisplaySettingsA',"error") returnend if
//set configurationdm.dmPelsWidth = 1024dm.dmPelsHeight = 768
//Change current configurationa = ChangeDisplaySettingsA(dm, 0)if a < 0 then messagebox('ChangeDisplaySettingsA',"error") returnend if end event
type cb_1 from commandbutton within w_resinteger x = 224integer y = 124integer width = 297integer height = 88integer taborder = 1integer textsize = -10integer weight = 400fontpitch fontpitch = variable!fontfamily fontfamily = swiss!string facename = "Arial"string text = "800x600"end type
event clicked;devmode dmlong astring ls_nulosetnull(ls_nulo)
//get current configurationa = EnumDisplaySettingsA(ls_nulo,-1,dm)
if a = 0 then messagebox('EnumDisplaySettingsA',"error") returnend if
//set configurationdm.dmPelsWidth = 800dm.dmPelsHeight = 600
//Change current configurationa = ChangeDisplaySettingsA(dm, 0)if a < 0 then messagebox('ChangeDisplaySettingsA',"error") returnend if
end event
Assinar:
Postagens (Atom)