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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only