全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2009
推到 Plurk!
推到 Facebook!

想請問一下那一個form event 是mouse drag move?

尚未結案
SamSam1230
中階會員


發表:128
回覆:178
積分:65
註冊:2004-12-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-07-22 11:51:15 IP:218.103.xxx.xxx 未訂閱
我的問題是那一個event 是可以觸發 mouse drag form moving ? 因為我都試過 Dragdrop 那些等等都不行 謝謝大大
unisabilly
一般會員


發表:19
回覆:20
積分:17
註冊:2004-05-20

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-07-22 13:27:40 IP:211.76.xxx.xxx 未訂閱
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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-07-22 17:24:51 IP:203.69.xxx.xxx 未訂閱
如果你想做的是移動整個 Form 可以參考這篇 http://delphi.ktop.com.tw/topic.php?topic_id=37720 不然可以描述一下你想做的事.. 大家就不必猜來猜去的.
SamSam1230
中階會員


發表:128
回覆:178
積分:65
註冊:2004-12-23

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-07-22 17:46:20 IP:218.103.xxx.xxx 未訂閱
謝謝 malanlk 你知道我的心意謝謝 我再看看你提供的
malanlk
尊榮會員


發表:20
回覆:694
積分:577
註冊:2004-04-19

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-07-23 03:42:28 IP:61.219.xxx.xxx 未訂閱
如果符合你心意就不必吝於給分吧...
SamSam1230
中階會員


發表:128
回覆:178
積分:65
註冊:2004-12-23

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-07-25 09:29:18 IP:218.103.xxx.xxx 未訂閱
malanlk你好 一定不會不給分的 但我想問滑鼠移動form 的event 呀.... 知道嗎? 謝謝
SamSam1230
中階會員


發表:128
回覆:178
積分:65
註冊:2004-12-23

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-07-25 10:40:09 IP:218.103.xxx.xxx 未訂閱
我剛剛找到了....哈哈哈,不知道可不可以加自己分呢?哈哈     
 
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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-07-25 13:52:20 IP:203.69.xxx.xxx 未訂閱
所以下次發問前請先想好如何陳述你想做的事或問題.不要再用這種"mouse drag form moving"自己發明的句子來浪費大家時間... 發表人 - malanlk 於 2005/07/25 13:54:29
系統時間:2024-05-02 5:44:50
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!