請問如何在DLL中使用主程式中的元件 |
尚未結案
|
agogo
一般會員 發表:2 回覆:4 積分:1 註冊:2004-01-08 發送簡訊給我 |
舉例:
今天有一個主程式(Uuit1)跟一個dll(test)
主程式中包含一個button跟progressbar bar的範圍是0~10000 按下button->呼叫dll->然後在dll中要使用主程式中form的bar,讓bar可以跑
不過就錯了,不知道那出問題 以下有程式碼,可否幫我看一下 unit1.cpp
-------------------
#includetest.cpp ------------------------------ #includetest.bpf ---------------------------- USEFORM("Unit1.cpp", Form1); This file is used by the project manager only and should be treated like the project file DllEntryPoint大致上是將,可以build,但run出來會錯。 發表人 - agogo 於 2004/01/12 23:35:21 |
agogo
一般會員 發表:2 回覆:4 積分:1 註冊:2004-01-08 發送簡訊給我 |
沒人回應,我自己回應好了 經過一翻找尋,找到答案了 原文網址http://delphi.ktop.com.tw/topic.php?TOPIC_ID=35852
可以直接將物件傳入 dll 內,在 dll 內直接改變它的內容
//DLL __declspec(dllexport) int __stdcall FPoint(TLabel *label,int x); int __stdcall FPoint(int x) { int iValueX=x; for(int i=0;i<100000;i ) { Application->ProcessMessages(); // 讓主表單可以更新 Label iValueX =i; label->Caption=iValueX; } return iValueX; } // 主表單程式 __declspec(dllimport) int __stdcall FPoint(TLabel *label,int x); // 作一個按鈕啟動, Timer 定時更新顯示數值 void __fastcall TForm1::Button1Click(TObject *Sender) { int y=20; FPoint(Label1,y); } |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |