Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GetSystemMetics

Posted on 1999-07-17
5
Medium Priority
?
220 Views
Last Modified: 2013-12-03
I am building an interface by windows programming in C. I want my interface can be displayed beautifully in any pc's resolution (640x480, 800x600, 1024x768 etc). So, I used GetSystemMetrics to get the winWidth n winHeight. But, the problem is when I change all the components' location and structure of the interface into fraction like

hButton = createWindow("BUTTON",...,...,...,...,....,... 3*winWidth/16, 4*winHeight/25, 18*winWidth/80,....,....);  

the interface can't be displayed well in other pc. The structure of the interface destroy if the interface been displayed in other resolution. My pc's resolution is 800x600.

How am I want to display the interface well in any pc's resolution?
I create some graphics components (buttons, radion buttons, track bars etc) in resource file. The position of the components in the interface is set by numbers. But now I want to change it to
n*winWidth/m, x*winHeight/y which, n, m, x, y is any numbers so that the graphics components also can be displayed well in other pc's resolution also.

What should I do?
 
0
Comment
Question by:jessicalim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 100 total points
ID: 1403236
I think, you have only one real Solution: make 3 Types of every Dialog
in you RC file and load one or other according  
current Resolution!
There are some attempts(in EE) change
Dialog by Resolution and all failed!
This solution of course works, but demands from you
*3 job.
Other solution(not so good): change current resolution
to you preferable and after end of programm
return back Old(use ChangeDisplaySetting : See Windows Doc)
Good Luck, Alex
0
 

Author Comment

by:jessicalim
ID: 1403237
Alex,
How about the components which I created by using CreateWindow("Button",......) in the main window? How should I make them as flexible as possible by following the different resolution?
Can I use any ratio which is counted from the window width and window height?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1403238
In you oun window you can use this mechanism, i hope.
But you must react to message WM_CHANGERESOLUTION,
if user change current resolution.This reaction , i think,
must be : delete and rebuid all controls.
0
 

Author Comment

by:jessicalim
ID: 1403239
Alex,
I need your help again.
There is no WM_RESOLUTIONCHANGE, but the WM_DISPLAYCHANGE.

Below is part of the source code:
case WM_DISPLAYCHANGE:
fChanged = (BOOL)wParam;
szScreen.cx = LOWORD(lParam);
szScreen.cy = HIWORD(lParam);
winWidth = szScreen.cx;
winHeight = szScreen.cy;
if (fChanged) {
      // I tried to do something here. I want the interface change       
             //the size here. But, what should I add?
}
else {
      MessageBeep(0);
}
break;            

The components like buttons, status bar, ownerdraw button, bitmap displaying... are created in different function. How should I call the functions to redraw?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1403240
I think, if you don't want delete/create, use function
MoveWindow

BOOL MoveWindow(

    HWND  hWnd,      // handle of of you control
    int  X,      // horizontal position
    int  Y,      // vertical position
    int  nWidth,      // width
    int  nHeight,      // height
    BOOL  bRepaint = TRUE       // repaint flag
   );      
For define old Position
use GetWindowRect(hWnd, &lpRect);
and , for Example, make scaling old Position to new with
float koeef = (float)nNewXScreen/(float)nOldXScreen;
Can be, it helps.
Best Regards, Alex


0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question