type
THideObject = class(TObject)
hHWnd : hWnd;
ID : LongInt;
HideTab : TTabSheet;
FullName : String;
end;
var
//秀丸のハンドル
HideList : TObjectList;
・・・
function EnumWindowsProc(Wnd: hWnd; ID:LongInt):Bool; stdcall;
var
bufWT : array[0..255] of char; //ウィンドウタイトル用のバッファ
bufCN : array[0..31] of char; //クラス名用のバッファ
Style : integer;
ChStyle : integer;
ChExStyle : integer;
Disable, Visible, Child: integer;
HObj : THideObject;
Winrect : TRect;
sWidth, sHeight : String;
begin;
bufWT := '';
bufCN := '';
if (GetWindowText(Wnd, bufWT, 255) <> 0) then begin; //ウィンドウタイトルがあれば
GetClassName(Wnd, BufCN, 31); //クラス名も取得して
//多分常駐秀丸はタイトルが"秀丸"のみ
if((BufCN = 'Hidemaru32Class') AND (bufWT <> '秀丸')) then begin;
//Windowスタイルをチェック
ChStyle := GetWindowLong(Wnd, GWL_STYLE);
ChExStyle := GetWindowLong(Wnd, GWL_EXSTYLE);
Disable := ChStyle and WS_DISABLED;
Visible := ChStyle and WS_VISIBLE;
Child := ChExStyle and WS_EX_MDICHILD;
//可視状態で子MDIでないものを登録
if((Disable <> WS_DISABLED) and (Visible = WS_VISIBLE) and
(Child <> WS_EX_MDICHILD)) then begin;
//可視状態の秀丸のみ登録
HideList.Capacity := HideList.Capacity + 1;
hObj := THideObject.Create;
hObj.hHWnd := Wnd;
hObj.ID := ID;
hObj.FullName := bufWT;
HideList.Add(TObject(hObj));
//MDIにする
Windows.SetParent(Wnd,TargetForm.ClientHandle);
Style:=GetWindowLong(Wnd,GWL_EXSTYLE);
Style:=Style or WS_EX_MDICHILD;
SetWindowLong(Wnd,GWL_EXSTYLE,Style);
//サイズと位置を調整する(暫定処理)
sWidth := FloatToStr(int(TargetForm.ClientWidth / 2));
sHeight := FloatToStr(int(TargetForm.ClientHeight / 2));
MoveWindow(Wnd, 0, 0, StrToInt(sWidth), StrToInt(sHeight), true);
end;
end;
end;
result := true;
end;
|