Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC Window positioning

Status
Not open for further replies.

noodles1

Programmer
Oct 31, 2001
58
I have an MFC application that is launched by another app. This MFC app is initially minimised, through the use of SW_SHOWMINIMIZED in the launch command.

I wish to be able to position the dialog of this MFC app at specific coordinates upon the first time that it is restored.

Any suggestions?
 
I placed MoveWindow() in InitDialog of the dialog class. I should have mentioned that this is a Dialog based MFC application.

The MoveWindow works.

I now need to have the restore of the window from a minimised state also locate the window according to the same rules.
 
use
GetWindowRect(..&rc...
OffsetRect(&rc, dx, dy);
MoveWindow.. //move
OffsetRect(&rc, -dx, -dy);
MoveWindow.. //move back

All you need is GetWindowRect to remember position when application starts.

Ion Filipski
1c.bmp
 
inside Mainfrm.cpp write somethign ike this:

BOOL CMainFrame::preCreateWindow(CREATESTRUCT& cs)
{
cs.x=50;
cs.y=50;
cs.cx=600;
cs.cy=600; //random values

if( !CFrameWnd::preCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return TRUE;
}

bye,
Davide
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top