線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1142
推到 Plurk!
推到 Facebook!

兩個project間的物件如何互用?

尚未結案
nlj859
資深會員


發表:139
回覆:375
積分:322
註冊:2004-03-20

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-22 20:42:50 IP:163.28.xxx.xxx 未訂閱
我有兩個project,如果我要在projectA中要讓projectB中的Label1.Caption改變,那該怎麼做?可以這樣做嗎?
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-03-22 21:17:46 IP:61.221.xxx.xxx 未訂閱
引言: 我有兩個project,如果我要在projectA中要讓projectB中的Label1.Caption改變,那該怎麼做?可以這樣做嗎?
nlj859 你好: 可以,請參考以下的連結文章 (Application 之間交換訊息) src="http://delphi.ktop.com.tw/loadfile.php?TOPICID=10003806&CC=223734"> -- Enjoy Researching & Developing --
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-03-22 23:49:13 IP:140.135.xxx.xxx 未訂閱
nlj859您好:
引言: 我有兩個project,如果我要在projectA中要讓projectB中的Label1.Caption改變
包子哥的方式相當讚,這裡提供另外一種選擇(無意見看到的一篇文章) http://delphi.ktop.com.tw/topic.php?topic_id=39734 pental 前輩的方式,下面是修改後的code
AP1
.h
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:        // IDE-managed Components
        TLabel *Label1;
private:        // User declarations
  unsigned int WM_CaptionChange;
  void __fastcall WndProc(Messages::TMessage &Message);
public:                // User declarations
        __fastcall TForm1(TComponent* Owner);
};    .cpp
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
  WM_CaptionChange = RegisterWindowMessage("WM_CaptionChange");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WndProc(Messages::TMessage &Message)
{
  if(Message.Msg == WM_CaptionChange) //判斷是否收到自訂的訊息
    Label1->Caption="已改變";
  else
    TWinControl::WndProc(Message);
}    AP2
.h
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:        // IDE-managed Components
        TButton *Button1;
        TButton *Button2;
        void __fastcall Button1Click(TObject *Sender);
private:        // User declarations
   unsigned int WM_CaptionChange;
public:                // User declarations
        __fastcall TForm1(TComponent* Owner);
};    .cpp
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
  WM_CaptionChange = RegisterWindowMessage("WM_CaptionChange");
}
//---------------------------------------------------------------------------    void __fastcall TForm1::Button1Click(TObject *Sender)
{
  SendMessage(HWND_BROADCAST,WM_CaptionChange,0,0); //訊息廣播
}
//---------------------------------------------------------------------------
順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~
系統時間:2024-05-08 12:01:21
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!