Link to home
Start Free TrialLog in
Avatar of mskannan
mskannan

asked on

Detect the resolution and change it.

MY application is meant for 800*600 resolution. If the user is in any other resolution, then all my icons,pictures everything looks ugly.
So what i want is before starting the application, i will check the resolution and if it's not 800*600, then give a error message with ok and cancel options.
If the user clicks ok, then i want to change the res to 800*600 directly without going to display settings.
how to do it?
thanks in advacne.
mskannan
Avatar of caraf_g
caraf_g

STOP right there.
"If the user is in any other resolution, then all my icons,pictures everything looks ugly."

Fine. Fix your application, *NOT* your user's resolution.

Wake up to the real world.... In this day and age, people have monitors of size 17" and up. Forcing them to have 800x600 resolution is ridiculous.

Sorry..... but that honestly is the best advice anyone can give you.

Avatar of Éric Moreau
To create resolution-independant application, see this:
http://support.microsoft.com/support/kb/articles/Q182/0/70.ASP?LNG=ENG&SA=ALLKB&FR=0
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This Q comes up all the time. You should NOT automatically resize. Set your program to run and look good at a known rez and leave it at that. The users are going to higher rez to get more on the screen, it's incorrect to automatically glom up more space.

M
Exactly Exactly ex*ACT*ly..

emoreau, your code will undoubtedly work but I wish you hadn't told mskannan..

Being *ABLE* to do something does not mean you *SHOULD* do it....
caraf_g,

If you look at the comment before my answer, I gave a link to a correct way of handling this situation!
I guess everyone here went with the assumption that mskannan was forcing them to a smaller resolution?

Where I presently work, we still have a BOAT load of users that are still using 640X480 on their 17" monitors.  Unfortunately, with the complexity of the applications they're asking for.. sometimes this just doesn't give enough "Desktop Real Estate" to give them what they need.

I don't force the 800X600 resolution on them (which _IS_ the company destop standard), but I nudge them in that direction..  ;-)

Geez, yes, you're right! It never even entered my mind that someone might actually be trying to run the program in 640x480... how quaint <G>
Well sonny, I 'member the early daze of windoze. Yep, back in them daze we only had 640x480x16 colors and we were lucky to have that! All our DOS friends were stuck at 80x25 monochrome and 640x480 was *something* yessiree Bob! (Loud "ptui" sound followed by *gong* as glob of chaw hits spittoon)

(grin)

M
emoreau,

No matter what they say - Great Answer.

Both suggestions work.  He has two options.  He can pick what he wants.

Although I agree that the MS article is the better choice as changing the resolution asks for problems, I feel it is better to answer the question that was asked.

Just my thoughts, insignificant, though they may be <g>
Yes... fond memories. mark, I'm old enough to remember vaguely the ... er... what were they called again.... ZX80, wasn't it? Cute little green on black screens, and to save a 1KB program you had to connect a tape recorder with an audio tape in it to the machine. Those were the days.... I still remember when this new-fangled thing called "DOS" came out......

Must say the PC games were better back then. Ever played the original "Frogger"?
wileecoy,

I'm in no doubt that emoreau's suggestions are well thought out and work perfectly. What I am saying though is that you should not do it. Let me put it this way..... If I bought a piece of software and it would try to change my display settings to something other than *MY* preferences, I would go back to the vendor and demand my money back. Trust me, the worst thing an application can do is to mess with a user's preferences. There is nothing more guaranteed to seriously piss the punter off.
I have to agree with caraf_g, changing the rez on a user is a sure path to customer complaints and returned product.

Is a really helpful feature. You have a user that has icons all over the edges of their screen at a high rez. You step them down a notch and now their icons are either off the screen or re-arrainged. When you return the rez to its original settings (you *were* planning on restoring the settings on exit?) their set of carefully placed icons are now scattered.

Additionally yours is not the *only* program that might be active when you decide to "help" by resetting the screen size. So perhaps you wind up hiding the URHC of some program that they already have open.

One more thought, What if *every* program did this to users - you're concept is so good that everyone jumps on the automatic resize bandwagon. Only problem is that if you try an run two programs that *both* want to resize but at two different settings... then what? Screen jumping from one rez to another each time you task switch? (kind of like how DOS mode windows behave - annoying ain't it?) Or does the user get that lovely "You must reboot for these changes to take effect" every time they fire your app?

No, Make the screen look pretty at the lowest rez you feel comfortable at and live with it being smaller at higher rez's and put a "minimum rez = xxx/yyyy" label on the box.

M
So mskannan, are you satisfied?
caraf_g,

I go back earlier than the Sinclair! I started out when a 1 was a hole in a piece of paper!

(senile sounding, high pitched voice)

Yep sonny them was 'he daze. You made programs the best way, FORTRAN-IV on 80 column cards or miles of that dad-gum ASR-33 punched paper tape. Yep, 029 keypunch, now *that* was computing power! None of this sissy boot ROM stuff, you started your 'puter in the morning by flippling toggle switches and then doing a 7-card loader IPL! This was back in the days when the Apple ][ was the cat's meow and Apple hadn't figured out LOWERCASE yet. Yessiree, my *first* home computer was a S-100 bus 1Mhz 6802 with a whopping 16k of RAM! (And we watched every byte in them daze, nothin' like being 4 bytes over the amount of RAM you had!)

Yep, had to write my own BIOS. Peripherial cards? You wanted one, you got out your wire-wrap gun and by gum you "rolled your own". For "mass storage" we had 300 baud "Kansas City" tape!

At work on the "big iron" (SEL 32/55) we had a newfangled thing, a 80Mb hard drive. Oh it were great, about the size of a "top loader" washing machine with them big 14" platters you could actually *see* the bits! (true, we had a magnetic flux viewer that you could place against media and *see* data!)

(loud maniacle cackle and toothless lip smacking sounds...)

M
Oh man.... did I turn this thread in a new direction or what?!  ;-)

HahAA!

WELL.... my daddy invented the abacus

So there.
(grin)

Yeah, but my story is *true*!

(big toothy grin)

In all honesty I started in computer in jr. high back in early 70s. Learned to program on a timeshare (now known as client/server) dialup *acoustic* modem on a IBM360-65. Had a Selectric typewriter with an "APL" ball on it. We also had a ASR-33 for dialin on another system. First "small" computer was a Wang "micro". Programmed in Basic and was small enough to fit on *two* A/V carts. Had an 8k *CORE* memory module the size of a pullman suitcase tied to the CPU that was the size of a two drawer filing cabinet. Was *hot*!

Have lost count on the number of different machines I've cut code for. Everthing from embedded 6502's to Z8000's, 68x000's, IBM, Dec, SEL, Honeywell, and every sort of PC. Seems like most folx believe that computing started with the PC...

M
I concede defeat. You are a true veteran!
(grin)

M
...but I'd still like to see you square your comment "(big toothy grin)" with "toothless lip smacking sounds..."

Sound effects are dubbed in...

M
Avatar of mskannan

ASKER

hi all,
thanks for your comments,
i also doesn't want to implement this feature in my application. I simply put that "This application needs 800*600 resolution for best performance" in the requirements section and gave the appln for the user acceptance test.
During the tests, the end users said that if the system is not running in 800*600, the appln should detect and give a warning and give the facility to change the resolution with a click of a mouse button.
So I have no option other than just lodge a protest and implement.
That's how this question propped up.
One more thing, how is the task bar afffects this screen size. Because some times task bar comes and the screen adjusts automatically and some other times even if the task bar is missing still the form size is total screen  minus taskbar?
why this behaviour?
any help.
as of emoreau's answer, it's working for me and i am awarding the points.

Thank you all for some nice discussion.

mskannan
To know real screen dimensions, use this:


Private Declare Function SystemParametersInfo _
                Lib "user32" _
                Alias "SystemParametersInfoA" _
                (ByVal uAction As Long, _
                 ByVal uParam As Long, _
                 lpvParam As Any, _
                 ByVal fuWinIni As Long _
                ) As Long

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
   
Private Const SPI_GETWORKAREA = 48

Dim lngReturn As Long
Dim WA As RECT
    'Get screen dimension
    lngReturn = SystemParametersInfo(SPI_GETWORKAREA, 0&, WA, 0&)
    WA.Left = WA.Left * Screen.TwipsPerPixelX
    WA.Right = WA.Right * Screen.TwipsPerPixelX
    WA.Top = WA.Top * Screen.TwipsPerPixelY
    WA.Bottom = WA.Bottom * Screen.TwipsPerPixelY
hi emoreau,
your code lists all the possible combinations of resolution in the user's computer.
but what i want is the current resolution the user is having and check whether it's 800*600 or give an option to change
how to change the code?
mskannan


Take Screen.Width and divide by Screen.TwipsPerPixelX and .Height divided by Screen.TwipsPerPixelY to get X and Y resolution of screen.

M
Have you looked at this condition:
        If lBits = D(lNumModes).dmBitsPerPel And _
            lWidth = D(lNumModes).dmPelsWidth And _
            lHeight = D(lNumModes).dmPelsHeight Then
            List1.ListIndex = List1.NewIndex
        End If

This line identifies the current config.