Re: Center an SDI application on startup

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




Mark F. wrote:
"JoeB" <joe@xxxxxxxxxx> wrote in message
news:ukwuA$HkGHA.984@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

How simple is it to center an SPI application when it starts up in a
non-maximized window?


J

Here is another cool trick to center the mainframe at 90% of the screen
size. The code is added in the PreCreateWindow function.

--- snip ---
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;

// add this ------------------------------
int xSize = ::GetSystemMetrics(SM_CXSCREEN);
int ySize = ::GetSystemMetrics(SM_CYSCREEN);
cs.cx = xSize * 9 / 10;
cs.cy = ySize * 9 / 10;
cs.x = (xSize - cs.cx) / 2;
cs.y = (ySize - cs.cy) / 2;
// ---------------------------------------

return CMDIFrameWnd::PreCreateWindow(cs);
}


One minor thing to note on this is that this is for MDI and not SDI. OP
will need to change the base class call appropriately.

----
Ajay

.



Relevant Pages

  • Re: Center an SDI application on startup
    ... How simple is it to center an SPI application when it starts up in a ... Here is another cool trick to center the mainframe at 90% of the screen ...
    (microsoft.public.vc.mfc)
  • Re: Case sensitive TSQL syntax
    ... Thanx Uri that did the trick. ... > You can use ALTER DATABASE ... ... When I take those same procedure to a clients machine I get ...
    (microsoft.public.sqlserver.programming)
  • Re: Center an SDI application on startup
    ... Seems like a lot of trouble to go through when CenterWindow() works really ... well for any CWnd object. ... Here is another cool trick to center the mainframe at 90% of the screen ...
    (microsoft.public.vc.mfc)
  • Re: New Throw Invented
    ... I'm not much of a handler...but isn't the purpose of a fake to trick ... the mark into thinking you're throwing something that you're not going ...
    (rec.sport.disc)
  • Re: Play All Videos In Folder
    ... then add the closing Quotation ... mark. ... That "trick" to paste a path does not work for me on Win2k ...
    (rec.video.desktop)