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



Posted on 1999-07-17
Medium Priority
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?
Question by:jessicalim
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
LVL 14

Accepted Solution

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

Author Comment

ID: 1403237
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?
LVL 14

Expert Comment

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.

Author Comment

ID: 1403239
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?
LVL 14

Expert Comment

ID: 1403240
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


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.…
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