Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change Screen Resolution Dynamic

1,030 views
Skip to first unread message

Thiago Campos Pereira

unread,
Apr 27, 2005, 8:29:06 AM4/27/05
to
I am using PB 9 with Windows XP. I need that my application change the
screen resolution when start.

Anyone can help me?


stevekatz

unread,
Apr 27, 2005, 10:58:33 AM4/27/05
to
If you are referring to changing the display properties of
the monitor through the OS, I wouldn't suggest it. Your app
would not be very well behaved in that case and when the
user changes context to another running application they
will also get that screen resolution.

If you are referring to sizing your application to the
existing display properties, you can get those properties
from the environment variable which you can populate via a
call to GetEnvironment().

HTH,

steve
[TeamSybase]

Jerry Siegel

unread,
Apr 27, 2005, 11:01:38 AM4/27/05
to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_3tfc.asp

"Thiago Campos Pereira" <thi...@cataguases.com.br> wrote in message
news:426f858c@forums-2-dub...

Terry Voth

unread,
Apr 27, 2005, 2:12:05 PM4/27/05
to
**MAJOR** ditto on that. In fact, "not suggesting" it would be vastly
understating it for me. I'd consider messing with my desktop settings
a _serious crime_, worthy of discontinued use and upgrades!! <g>

Seriously, Microsoft application standards for Windows applications
would say that it is the application's responsibility to respond to
the system settings, not the other way around. How you "respond" is up
to you (I've seen some apps change their font size in proportion to
the screen size change, which struck me as incredibly dumb and
non-productive from a high-res users point of view), but you should at
least consider how the PFC Resize services
(http://pfc.codexchange.sybase.com/source/browse/pfc/pfcwnsrv/pfc_n_cst_resize.sru?rev=1.6&view=markup,
http://pfc.codexchange.sybase.com/source/browse/pfc/pfcdwsrv/pfc_n_cst_dwsrv_resize.sru?rev=1.4&view=markup)
does it. Done right, it gives the user more fields or lines or rows to
work with on screen, as you allow. Really simple illustrations of how
the resize services can be used can be seen in PBL Peeper (see below).

I'll give the "changing the resolution" idea this much: it will vastly
reduce the size of your problem. Unless you're users are forced to use
your application, you won't have any left.

Good luck,

Terry [TeamSybase] and Sequel the techno-kitten

*********************************
Click once a day to help the hungry
http://www.thehungersite.com
*********************************

Sequel's Sandbox: http://www.techno-kitten.com
Home of PBL Peeper, a free PowerBuilder Developer's Toolkit.
Version 2.2.06 now available at the Sandbox
See the PB Troubleshooting Guide at the Sandbox
^ ^
o o
=*=

Thiago Campos Pereira

unread,
Apr 27, 2005, 3:22:20 PM4/27/05
to
HI,

I can solve my question with the code below:


$PBExportHeader$w_res.srw
$PBExportComments$change resolution
forward
global type w_res from window
end type
type cb_2 from commandbutton within w_res
end type
type cb_1 from commandbutton within w_res
end type
type devmode from structure within w_res
end type
end 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 dmPanningHeight
end type

global type w_res from window
integer x = 837
integer y = 388
integer width = 795
integer height = 496
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
cb_2 cb_2
cb_1 cb_1
end type
global w_res w_res

type prototypes
FUNCTION 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 variables
on w_res.create
this.cb_2=create cb_2
this.cb_1=create cb_1
this.Control[]={this.cb_2,&
this.cb_1}
end on

on w_res.destroy
destroy(this.cb_2)
destroy(this.cb_1)
end on

type cb_2 from commandbutton within w_res
integer x = 224
integer y = 220
integer width = 297
integer height = 88
integer taborder = 2
integer textsize = -10
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "1024x768"
end type

event clicked;devmode dm
long a
string ls_nulo
setnull(ls_nulo)

//get current configuration
a = EnumDisplaySettingsA(ls_nulo,-1,dm)

if a = 0 then
messagebox('EnumDisplaySettingsA',"error")
return
end if

//set configuration
dm.dmPelsWidth = 1024
dm.dmPelsHeight = 768

//Change current configuration
a = ChangeDisplaySettingsA(dm, 0)
if a < 0 then
messagebox('ChangeDisplaySettingsA',"error")
return
end if
end event

type cb_1 from commandbutton within w_res
integer x = 224
integer y = 124
integer width = 297
integer height = 88
integer taborder = 1
integer textsize = -10
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "800x600"
end type

event clicked;devmode dm
long a
string ls_nulo
setnull(ls_nulo)

//get current configuration
a = EnumDisplaySettingsA(ls_nulo,-1,dm)

if a = 0 then
messagebox('EnumDisplaySettingsA',"error")
return
end if

//set configuration
dm.dmPelsWidth = 800
dm.dmPelsHeight = 600

//Change current configuration
a = ChangeDisplaySettingsA(dm, 0)
if a < 0 then
messagebox('ChangeDisplaySettingsA',"error")
return
end if

end event

"Thiago Campos Pereira" <thi...@cataguases.com.br> escreveu na mensagem
news:426f858c@forums-2-dub...

Vikas J

unread,
Apr 30, 2005, 2:12:50 AM4/30/05
to
Vist Sybase.com and search for Manifest files.
For PB wih XP compatiable

Thanks
Vikas


Thiago Campos Pereira <thi...@cataguases.com.br> wrote in message

news:426fe668@forums-2-dub...

> file://get current configuration


> a = EnumDisplaySettingsA(ls_nulo,-1,dm)
>
> if a = 0 then
> messagebox('EnumDisplaySettingsA',"error")
> return
> end if
>

> file://set configuration


> dm.dmPelsWidth = 1024
> dm.dmPelsHeight = 768
>

> file://Change current configuration


> a = ChangeDisplaySettingsA(dm, 0)
> if a < 0 then
> messagebox('ChangeDisplaySettingsA',"error")
> return
> end if
> end event
>
> type cb_1 from commandbutton within w_res
> integer x = 224
> integer y = 124
> integer width = 297
> integer height = 88
> integer taborder = 1
> integer textsize = -10
> integer weight = 400
> fontpitch fontpitch = variable!
> fontfamily fontfamily = swiss!
> string facename = "Arial"
> string text = "800x600"
> end type
>
> event clicked;devmode dm
> long a
> string ls_nulo
> setnull(ls_nulo)
>

> file://get current configuration


> a = EnumDisplaySettingsA(ls_nulo,-1,dm)
>
> if a = 0 then
> messagebox('EnumDisplaySettingsA',"error")
> return
> end if
>

> file://set configuration


> dm.dmPelsWidth = 800
> dm.dmPelsHeight = 600
>

> file://Change current configuration

0 new messages