Click here to Skip to main content
11,920,772 members (59,275 online)
Rate this:
Please Sign up or sign in to vote.
See more: VC8.0 C++
How do I place the dialog at the right bottom in the MFC dialog base?

The position should remain the same when it is used with the other monitors too.

What I mean is, the dialog should be in the right bottom of the window above the taskbar. RIGHTBOTTOM in all the monitors.
Posted 6-Jan-11 20:16pm
Edited 6-Jan-11 22:56pm
Gokulnath007 7-Jan-11 3:46am
Thank u...
Dalek Dave 7-Jan-11 3:33am
Edited for Syntax and Readability.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There is an API to display dialog in center of the screen i.e. CenterWindow() but
I don't know if there is direct API to display it at bottom right corner.
My suggestion is first calculate the screen coordinates

void GetScreenSizeInPixels( SIZE& s)
    ZeroMemory( &s, sizeof(SIZE) ); = (LONG)::GetSystemMetrics( SM_CXMAXTRACK ); = (LONG)::GetSystemMetrics( SM_CYMAXTRACK );

Than calculate the Dialog size using GetClientRect and than calculate the position and now use SetWindowPos with property SWP_NOSIZE.

May be this will help you.
Gokulnath007 7-Jan-11 2:20am
Yes.. Great.. Solved it... Thank u..
Shilpi Boosar 7-Jan-11 2:23am
I found that you have eagerness to learn things :) keep it up...
Gokulnath007 7-Jan-11 3:49am
Shortly I am going to release my article.. Thank u.. Shilpi
Dalek Dave 7-Jan-11 3:34am
Good Answer.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

RECT screen;
::GetWindowRect(::GetDesktopWindow(), &screen);
RECT dlg;
int width = dlg.right - dlg.left ;
int height = dlg.bottom - ;	
int xlen = screen.right - width ;
int ylen = screen.bottom - height;
Richard MacCutchan 7-Jan-11 4:13am
Added <pre> tags for readability.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 548
1 Dave Kreskowiak 245
2 phil.o 170
3 KrunalRohit 134
4 F-ES Sitecore 130
0 OriginalGriff 6,778
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,203
3 George Jonsson 2,815
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web03 | 2.8.151120.1 | Last Updated 7 Jan 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100