想請問一下那一個form event 是mouse drag move? |
尚未結案
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
unisabilly
一般會員 發表:19 回覆:20 積分:17 註冊:2004-05-20 發送簡訊給我 |
SamSam1230 你好:
不是很清楚你的問題,但是如果要Mouse Drag and Drop 來說 你要先把Properties 裡面的Drag Mode 先改成 dmAutomatic ...
舉個例子來說,如果要把ListBox1 裡面的東西可以 拉到 ListBox2裡面
你先把ListBox1 和ListBox2 的 Drag Mode 改成 dmAutomatic,
然後在ListBox 的Event裡面的OnDragOver跟OnDragDrop輸入妳需求的程式碼即可,最簡單的範例:
procedure TForm1.ListBox2DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin accept := (source is Tlistbox); end; procedure TForm1.ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer); var index : integer; begin index := TlistBox(Source).ItemIndex; if index <> -1 then begin TListBox(Sender).Items.Add(TListBox(Source).Items[index]); TListBox(Source).Items.Delete(Index); end; end;若需要從ListBox2拉回ListBox1的話對於ListBox1 的OnDragOver 和OnDragDrop 也輸入同樣的程式碼即可 ~ P.S. 如果你要用mdManual 的話 開始跟結束都需要由你自己控制也就是說你必須下BeginDrag 才會開始,結束時下EndDrag指令 ~ 發表人 - unisabilly 於 2005/07/22 13:31:03 |
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
如果你想做的是移動整個 Form 可以參考這篇
http://delphi.ktop.com.tw/topic.php?topic_id=37720 不然可以描述一下你想做的事.. 大家就不必猜來猜去的.
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
我剛剛找到了....哈哈哈,不知道可不可以加自己分呢?哈哈
interface ... type TForm1 = class(TForm) ... private { Private declarations } procedure FormMove(var Msg: TWMMove); message WM_MOVE; ... end; ... implementation ... procedure TForm1.FormMove(var Msg: TWMMove); begin inherited; Label1.Caption := Format('(%d,%d)', [Left, Top]); end; ... We call "inherited" to let the ancestors of TForm process the message. This will update the Left and Top properties. In the above example we simply displayed them, but we can use this kind of Move event for example to guarantee that the form is always placed within the limits of the screen's work area (the portion of the screen not used by the system taskbar or by application desktop toolbars). procedure TForm1.FormMove(var Msg: TWMMove); var WorkArea: TRect; begin inherited; if SystemParametersInfo(SPI_GETWORKAREA, 0, @WorkArea, 0) then begin if Left < WorkArea.Left then Left := WorkArea.Left else if Left Width > WorkArea.Right then Left := WorkArea.Right - Width; if Top < WorkArea.Top then Top := WorkArea.Top else if Top Height > WorkArea.Bottom then Top := WorkArea.Bottom - Height; end; end; |
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |