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.
ShivaliAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShivaliAuthor Commented:
Yes.
0
migelCommented:
hm, ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.