It returns the size of the operating system's screen
elements. There are 34 different values returned by
sysmetric() - sysmetric(1) through sysmetric(34)
Although feasable with a few API Calls, I would not recommend changing the screen resolution with VFP, you can encounter an video card that cannot support it, or just frustrate the user that has set his monitor the way he wants it, I would suggest you desig your application to suit the lowest common denominator (most likely 800X600 or something close to that).
Mike Gagnon
If you want to get the best response to a question, please check out FAQ184-2483 first.
As an addition to what Mike already said, when the display setting is change, icon position on the desktop also change. Some users can get mad when an application change the display resolution without his/her permission.
Do it at your own risk!
Here is the code:
--------------
Local lnReturn, lnWidth, lnHeight, lnScrInfo
Local lnhDC, lnBPP, lnPELsWidth, lnPELsHeight
Local lcPELsWidth, lcPELsHeight
Local DeviceMode, OldDeviceMode
Declare Long EnumDisplaySettings in User32 ;
String cDeviceName, Long nGraphicsMode, String @cDevMode
Declare Long ChangeDisplaySettings in User32 ;
String cDevMode, Long nFlags
Declare Integer SendMessage in User32 ;
Long nhWnd, Integer Msg, Integer wParam, Long lParam
DeviceMode = left(DeviceMode, 108) + ;
lcPELsWidth + lcPELsHeight + right(DeviceMode, 8)
lnReturn = ChangeDisplaySettings(DeviceMode, 4)
Do case
Case (lnReturn == 0) && success
ChangeDisplaySettings(DeviceMode, 1)
*** Notify all the windows that display settings has changed
lnScrInfo = lnHeight * 2^lnBPP + lnWidth
SendMessage(0xFFFF, 0x7E, lnBPP, lnScrInfo)
MessageBox('Display Settings has been changed' ;
+ chr(13) + 'Press any key to Reset', 64, ;
' Reset Display Settings')
And in addition to AirCon's post vis-a-vis messing
up the user's desktop icons, the positions are stored
in a registry key; the name of which I forget.
It might be possible to grab and store that key, make
the screen changes, and then reset the saved key upon
exit.
Of course that won't help if the user mimimizes your app
and wants to do something on the desktop.
Darrell
'We all must do the hard bits so when we get bit we know where to bite'
To give my reason for the question. . .
I bought a new "flat" screen 700-1 contrast 19". . .they are getting down into my price range!!!
It asks for 1280x1024. . .not just 1024 x768 if I have on anything less than 1280x1024. . .
Would you believe that it looks and has the best clarity at the 1280x1024. . .( and I thought I needed to upgrade my classes. . .)1014x768 looks ok and works, but 800x600 looks a little funky. . .and 620x480 looks terrible. . .
this ties into my previous question today regarding setviewport and the use of scrollbars on the form, thinking maybe I shd just evolve to the 1024x768 and get the advantage of all the desktop real estate
. . .with the price of flat screens coming down makes me think that is where the world is headed.
Getting back to the previous posts, you can change
the screen resolution in mid-stream, but you may
run into problems with recalcitrant applications
when it comes to resetting their own resolution.
And as stated by myself and AirCon, the end users may
get pretty upset if you mess up their desktop icon
positions. There is probably a way to determine the
names and positions of the desktop items, as I eluded to
in my last post, and to align them temporarily or
permanently based on their density and position, but
I've never done it.
Have fun.
Darrell
'We all must do the hard bits so when we get bit we know where to bite'
One workaround to your screen resolution problem might be to size your forms accordingly. You can programmatically resize the form and the controls on a form as the Atkins/Kramek/Schummer book by Hentenwerke shows. Another possibility I've used is to have one form for 'small screens' and one for 'big screens' with controls closer together,etc., and call one or the other form accordingly.
But generally I think your client will be happier if you make your app fit his condition rather than vice versa.
Hey I was on vacation. That is why it took so long to reply. Thanks for the tips from Aircon, Mike, Darrelblackhawk & Sermac.
One of my user set his screen in low resolution. In his screen my app looks funny. He dont want to change his resolution due to his strange screen saver. May be a push from the top will change his mind.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.