Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Screen Resolution
Message
From
03/11/2012 09:32:53
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turkey
 
 
To
03/11/2012 02:52:54
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Miscellaneous
Thread ID:
01556346
Message ID:
01556353
Views:
72
Lparameters lnWidth, lnHeight
If Pcount() # 2
If Vartype(_Screen.LastWidth)="U"
Return
Else
lnWidth=_Screen.LastWidth
lnHeight=_Screen.lastHeight
Endif
Endif
Clear
#Define ENUM_CURRENT_SETTINGS -1
#Define CDS_UPDATEREGISTRY = 0x01
#Define CDS_TEST 0x02
#Define DISP_CHANGE_SUCCESSFUL 0
#Define DISP_CHANGE_RESTART 1
#Define DISP_CHANGE_FAILED -1
#Define DM_PELSWIDTH 0x00080000
#Define DM_PELSHEIGHT 0x00100000

Declare Integer EnumDisplaySettings In win32API ;
string deviceName,;
integer modeNum, ;
string @ lpdevMode

Declare Long ChangeDisplaySettings In win32API ;
string lpDevMode, ;
integer dwflags

lpdevMode = Replicate(Chr(0),512)

EnumDisplaySettings(0,ENUM_CURRENT_SETTINGS,@lpdevMode)

* Save previous resolution

_Screen.AddProperty("LastWidth",CToBin(Substr(m.lpdevMode,109,4),"4RS"))
_Screen.AddProperty("LastHeight",CToBin(Substr(m.lpdevMode,113,4),"4RS"))
* Check if not the same, no use to change when the same
If _Screen.LastWidth # m.lnWidth or _Screen.LastHeight # m.lnHeight
Wait Window "Ekran çözünürlüğü ayarlanıyor..." At Srows()/2,Scols()/2-10 Nowait
lpdevMode = Stuff(m.lpdevMode,41,4,BinToC(DM_PELSWIDTH+DM_PELSHEIGHT,"4RS"))
lpdevMode = Stuff(m.lpdevMode,109,4,BinToC(lnWidth,"4RS"))
lpdevMode = Stuff(m.lpdevMode,113,4,BinToC(lnHeight,"4RS"))
result = ChangeDisplaySettings(m.lpdevMode,CDS_TEST)
If !( result = DISP_CHANGE_SUCCESSFUL )
*Wait Window "Mode not supported." Timeout 1
Return .F.
Else
ChangeDisplaySettings(m.lpdevMode,0)
Endif
Endif
Return
Endfunc

*!* Source Code From Cetin BASOZ
*!* To use it, just place it somewhere in your app like this:
*!* ChangeRes(1024,768)
*!* That means I am forcing the screen to have a resolution of 1024x768. When I exit my main form, in the unload event I place this:
*!* ChangeRes(_Screen.LastWidth,_Screen.lastHeight)
*!* And that would restore the previous screen resolution.
Previous
Reply
Map
View

Click here to load this message in the networking platform