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

Nenhum comentário: