MDI子視窗的排列 |
尚未結案
|
ericaleu
一般會員 發表:6 回覆:1 積分:1 註冊:2004-06-21 發送簡訊給我 |
|
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi ericaleu, 1.Add a timer on the mainform,set enabled to false & interval to 100
2.add below codes on it's OnTimer event
procedure TMainForm.Timer1Timer(Sender: TObject); begin TTimer(Sender).Enabled := False; MainForm.TileMode := tbHorizontal; MainForm.Tile; end;3.add below codes on MDIChild's on close event ... implementation uses MAIN; {$R *.dfm} ... procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction); begin Mainform.Timer1.Enabled := True; Action := caFree; end;---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman |
wameng
版主 發表:31 回覆:1336 積分:1188 註冊:2004-09-16 發送簡訊給我 |
|
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi All, 感謝 wameng 版大指教,讓小弟又多學了一招!! 昨天本來是把重新排列的程式碼寫在 MDIChild 的 OnClose 事件上,但發現有一個小問題,亦即重新排列的程式碼會先被觸發後再關掉該 MDIChild,導致螢幕上會有一個空洞(不知該如何形容),效果相當於排列後再關掉一個 MDIChild(先排再關,而非先關再排),所以才會運用 Timer 的方法來進行,不知如何克服此問題? ----------------------------------
小弟才疏學淺,若有謬誤尚請不吝指教
----------------------------------
------
Fishman |
ericaleu
一般會員 發表:6 回覆:1 積分:1 註冊:2004-06-21 發送簡訊給我 |
|
StrongLemon
高階會員 發表:10 回覆:166 積分:105 註冊:2004-04-18 發送簡訊給我 |
您好:請參見範例,重點在於FormDestroy時把自己的FormStyle設成fsNormal,
這樣他就不會在MDIChild中了。
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; Form1.Memo1.Lines.Add('FormClose'); end; procedure TForm2.FormDestroy(Sender: TObject); begin Self.FormStyle:=fsNormal; Form1.TileMode := tbHorizontal; Form1.Tile; Form1.Memo1.Lines.Add('FormDestroy'); Form1.Memo1.Lines.Add(IntToStr(Form1.MDIChildCount)); end; |
Miles
尊榮會員 發表:27 回覆:662 積分:622 註冊:2002-07-12 發送簡訊給我 |
Hi ericaleu 你好:
參考http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20290095.html
以下是我New一個MDI Project的程式碼, 要修改部分用紅字標出
private { Private declarations } FClientInstance : TFarProc; FPrevClientProc : TFarProc; procedure ClientWndProc(var aMessage: TMessage); public { Public declarations } end; procedure TMainForm.ClientWndProc(var aMessage: TMessage); begin case aMessage.Msg of WM_MDIDESTROY: begin aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, Msg, wParam,lParam); MainForm.Tile; end; else aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, Msg, wParam,lParam); end; end; procedure TMainForm.FormShow(Sender: TObject); begin FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC)); FClientInstance := MakeObjectInstance(ClientWndProc); SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance)); end; procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction); begin SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FPrevClientProc)); end;我不是高手, 高手是正在銀幕前微笑的人.
------
我不是高手, 高手是正在銀幕前微笑的人. |
smallfox
高階會員 發表:2 回覆:113 積分:128 註冊:2003-02-19 發送簡訊給我 |
改良Fishman的做法: 1.在Mainform的FormCreate事件中 ...
procedure TForm1.FormCreate(Sender: TObject);
begin
MdiCnt:=0; // 暫存已開啟的MDICHILD數量
Timer1.Interval:=500; // 設定半秒檢查一次MDICHILD數量的變化
end; 2.在Timer1的Timer1Timer事件中 ...
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (MdiCnt<>Form1.MDIChildCount) then begin
Form1.TileMode:=tbHorizontal;
Form1.Tile;
MdiCnt:=Form1.MDIChildCount;
end;
end; 3.在MDICHLID的FormClose事件中..
procedure TfmChild_1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end; 試試看這樣的效果如何 .....
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |