Facing issues with maximize/minimize functions in window

Hi Team.

I am creating a window inside a viewport that is attached to viewport div. The viewport div is nested inside a main div. Now when the main div acts as the default div where all other divs are placed and based on its dimensions, all other elements are resized/rearranged. However, I am facing issue resizing the window placed inside the viewport div. I have placed a sample code below. On onmaximize event, the code get the width of the main div and applies to viewport div and using setdimension, sets the width for the window. However, when the setdimension function is called from the onmaximize event, the onminimize event is called and the window doesnt resize eventually.

dhxWin = new dhtmlXWindows();
dhxWin.attachViewportTo(“ViewPort”);
win = dhxWin.createWindow(“Window”, 10, 10, 625, 250);
win.setText(“Window”);

win.attachEvent(“onMinimize”, function (win) {
$(‘#maindiv’).removeClass(“someclass”).addClass(“somenewclass”);
$(“#ViewPort”).width($(“#maindiv”).width());
win.minimize();
win.setDimension($(“#ViewPort”).width());
});

win.attachEvent(“onMaximize”, function (win) {
$(‘#maindiv’).removeClass(“somenewclass”).addClass(“someclass”);
$(“#ViewPort”).width($(“#maindiv”).width());
win.maximize();
win.setDimension($(“#ViewPort”).width());
});

It is the expected scenario. The maximize and setDimension functions are mutually exclusive. First one resizes a window to maximum size ( size of a viewport ), while the second one sets a width of a window to some fixed size.