• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

Screen Resolution Independent Dialog

I'm designing a dialog based application in VC++6.0. I want my dialog and all types of controls on the dialog to resize and reposition such that the dialog takes the fullscreen irrespective of the screen resolution. I will also be loading bitmaps on the dialog controls like buttons, Static Text.
In other words if my current screen resolution is 640*480 and my dialog occupies the full screen then if I change the screen resolution to 800*600 or more then the dialog should again occupy the full screen and the control should also resize and reposition proportionately.
Something like DOS based games which occupy the fullscreen irrespective of the resolution and takes the full control.
0
Shivali
Asked:
Shivali
  • 7
  • 6
  • 3
1 Solution
 
migelCommented:
Hi!
Try this:
1 get current resolution
2. Calc coeff curr_res/base_res (for x and y coords)
3. dynamically resize dialog itself in OnInitDialog (by MoveWindow())
4. resize all dialog child
to done step 4 you can use this method:
{
HWND hWndChild = ::GetWindow(m_hWnd, GW_CHILD);
while(hWndChild)
{
RECT rc;
::GetWindowRect(hWndChild, &rc);
ScreenToClient(&rc);
rc.left *=  coeff_x; //calculed at the step 1
rc.top *= coeff_y;
rc.right *= coeff_x;
rc.bottom *= coeff_y;
::MoveWindow(hWndChild, rc.left, rc.top, rc-right-rc.left, rc.bottom-rc.top, FALSE);
hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT);
}
hope this helps.
PS. but font remains the same that was for base resolution.
0
 
chensuCommented:
Take a look at the following articles.

SclblDlg.exe Demonstrates Scaleable Controls in Dialog
http://support.microsoft.com/support/kb/articles/q112/6/39.asp 

NSViews
http://www.special-events.com/NSViews.htm

You can get the screen size by using the following code.

int nWidth = ::GetSystemMetrics(SM_CXSCREEN),
    nHeight = ::GetSystemMetrics(SM_CYSCREEN);

And you need to capture the WM_DISPLAYCHANGE message.

ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)

LRESULT CMyDialog::OnDisplayChange(WPARAM wParam, LPARAM lParam)
{
    int nBitsPerPixel = wParam;
    int nxScreen = LOWORD(lParam), nScreen = HIWORD(lParam);
}
0
 
ShivaliAuthor Commented:
Hi!
The logic which migel has suggested is working fine but the problem is not fully solved. The problem is that  i want to load bitmaps on the button but if i use CBitmapButton class the button takes the size of the bitmap if SizeToContent is given, so resizing the button does not resize the bitmap , so it does not make a difference. I want an algo which resizes the bitmap depending on the button size rather then the button taking the bitmap size.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
chensuCommented:
Then you have to derive your own class from CButton and implement an owner-drawn button.
0
 
ShivaliAuthor Commented:
Hi,
Chensu has suggested owner draw button, that is fine but then how do i make the buttons take the shape of the buttons?
0
 
migelCommented:
0
 
ShivaliAuthor Commented:
Hi, Sorry i made a mistake in my previous comment, look i have the code for resizing the dialog and the controls but the bitmap which i want to load on the controls like a button should resize also, which is not happenning , now how do i do that. The button resizes but the bitmap loaded on it does not rsize with the button.
0
 
migelCommented:
Ok;
onwerdarwButton + StretchBlt
0
 
ShivaliAuthor Commented:
Hi Migel,
    I would like to give u the 100 points b'coz ur resizing is working fine.

Thanx
Shivali

0
 
migelCommented:
Hi!
just accept my cooment as answer
0
 
ShivaliAuthor Commented:
Hi Migel,
In the option's for accepting the answer
Chensu's name is displayed so If I accept, Chensu will get the points and not u.

-Shivali

0
 
migelCommented:
hmm
may be you have to reject proposed answer before?
0
 
migelCommented:
Can i answer?
0
 
ShivaliAuthor Commented:
Yes.
0
 
migelCommented:
hm, ?
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 7
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now