in dialog base

when I push button dialog maximize (except region of taskbar )

I used 'SetWindowPos'

and I want that dialog size is restore(normal dialog) when push button
again.

what is problem?

//*******

bool flag=0;

::OnMaximize()

{

CRect rectWindow;

GetClientRect(&rectWindow);

ScreenToClient(&rectWindow);

if(flag == 0)

{

CRect workarea;

SystemParametersInfo(SPI_GETWORKAREA, 0,&workarea, 0);

SetWindowPos(&wndTopMost,workarea.left,workarea.top,

workarea.Width(), workarea.Height(), SWP_SHOWWINDOW);

flag=1;

}



else

{

SetWindowPos(this,rectWindow.left,rectWindow.top,

rectWindow.Width(), rectWindow.Height(), SWP_NOZORDER);

CenterWindow();

flag=0;

}

}