Thursday, August 14, 2008

Adjust CRM Windows Position and Size

CRM Form windows have fixed width and height that cover most of the user screen. There are cases when an entity contains only a small set of fields and you want to adjust the window layout (Position and Size) in order to make it more usable. Now, this is more of a reactive approach because the form first loads in its original size and only then the script kicks in and changes that for us. So until ms adds this as an OOB (“out of box”) feature you can use the following script in your onload event.

function OnCrmPageLoad()
//AdjustWindow( 300 , 400 , false , 10 , 20 );
AdjustWindow( 300 , 400 , true );

function AdjustWindow( width , height , center , posX , posY )
if( center == true )
posX = (screen.width - width)/2;
posY = (screen.height - height)/2;

window.resizeTo( width , height );
window.moveTo( posX , posY );



Rashed said...

Nice post...

Anonymous said...

Is there a way to center a Lookup Dialog box?

Adi Katz said...

You need to override the showModalDialog function and add the center=1 parameter to the window features.