#7080
kshi
参加者

改良版?です。
単一ウィンドウ→上下に並べる→左右に並べる
をトグルします。

単一ウィンドウに戻ったあと、元の文書をアクティブにするのは難しいですね。
[前のグループへ移動]やSetForegroundなど、ウィンドウ制御系のコマンドを使い
まわすと一応可能なのですが、うまく使いこなせていないのか、どうもEmEditor
が不安定になるようです。状況は特定できていません。

文書のIDのようなプロパティを元に、document.Activate(ID) 一発で戻れると便
利な気がしました。

var h = new ActiveXObject(“htmlfile”);
var sWidth = h.Script.screen.availWidth; //スクリーンの有効な横幅
var sHeight = h.Script.screen.availHeight; //スクリーンの有効な縦幅

var aWnd = anotherWindow(/- EmEditor$/, Window);

if (aWnd == Window) {
editor.ExecuteCommandByID(4394); //新しい水平グループ
} else {
if (Window.Width == sWidth) {
editor.ExecuteCommandByID(4243); //左右に並べる
} else {
editor.ExecuteCommandByID(4407); //タブ有効化&ウィンドウ結合
// SetPosition(0, 0, sWidth, sHeight); //最大化
SetPosition(sWidth/8, 0, sWidth * 3/4, sHeight); //横幅 3/4
}
}

function anotherWindow(regExpCaption, wSelf) {
var wnds = new Enumerator(shell.windows);
for( ; !wnds .atEnd(); wnds.moveNext() ) {
wnd = wnds.item();
if( wnd.Caption.search(regExpCaption) >= 0) {
if (wnd.Caption != wSelf.Caption) {
return wnd;
}
}
}
return wSelf;
}