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?
Who is Participating?
AlexVirochovskyConnect With a Mentor Commented:
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
jessicalimAuthor Commented:
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?
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.
jessicalimAuthor Commented:
I need your help again.

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

The components like buttons, status bar, ownerdraw button, bitmap displaying... are created in different function. How should I call the functions to redraw?
I think, if you don't want delete/create, use function

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.