Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Updated 6-Jan-11 21:56pm
v4
Comments
Dalek Dave 7-Jan-11 3:33am    
Edited for Syntax and Readability.
Gokulnath007 7-Jan-11 3:46am    
Thank u...

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) );
    s.cx = (LONG)::GetSystemMetrics( SM_CXMAXTRACK );
    s.cy = (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.
 
Share this answer
 
v2
Comments
Gokulnath007 7-Jan-11 2:20am    
Yes.. Great.. Solved it... Thank u..
ShilpiP 7-Jan-11 2:23am    
I found that you have eagerness to learn things :) keep it up...
Dalek Dave 7-Jan-11 3:34am    
Good Answer.
Gokulnath007 7-Jan-11 3:49am    
Shortly I am going to release my article.. Thank u.. Shilpi
RECT screen;
::GetWindowRect(::GetDesktopWindow(), &screen);
RECT dlg;
GetWindowRect(&dlg);	
int width = dlg.right - dlg.left ;
int height = dlg.bottom - dlg.top ;	
int xlen = screen.right - width ;
int ylen = screen.bottom - height;
this->MoveWindow(xlen-2,ylen-60,width,height+30,TRUE);
 
Share this answer
 
v2
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900