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

如何在dll上建立Timer或是Thread?!

尚未結案
kj68215
初階會員


發表:47
回覆:91
積分:27
註冊:2003-08-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-10-22 13:39:47 IP:221.169.xxx.xxx 未訂閱
小弟用 vc++ for .net 去實做一個dll. 這個dll是寫了一個編碼器的函式. 但是在編碼是否已經結束時,問題來了... 若要該dll裡,試著加上Timer或是Thread,該怎麼使用呢? 另外,小弟也試過在單一執行緒處理訊息↓
MSG msg;
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
   TranslateMessage(&msg);
   DispatchMessage(&msg); // ← 傳入到訊息幫浦(Message Pump)
}
紅色那一行,是DispatchMessage函式將控制項(經由是視窗類別)傳入MFC訊息幫浦,此幫浦會經由訊息來對映來呼叫你的函式,當你的處理程序完成時,它會回傳給MFC程式碼,最後造成DispatchMessage的回傳。 問題是,它似乎只能用在擁有視窗類別才攔截得到message...?! 在MFC程式(視窗) → 成功攔截到訊息. 在dll(無視窗) → 在while迴圈一直跑(一直都抓不到訊息),導致列舉(emun)的變數,取得不到索引值!! 簡單來講,就是有視窗類別成功,無視窗類別則失敗! 這....到底是啥原因呢?! 在 > ----------------------- 請多多指教啦!!^^ 發表人 -
------
-----------------------
請多多指教啦!!^^
kj68215
初階會員


發表:47
回覆:91
積分:27
註冊:2003-08-09

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-09 18:13:33 IP:221.169.xxx.xxx 未訂閱
< > 還是沒有人知道是為什麼嗎?嗚嗚~< > 或許是小弟詳細得不夠清楚吧?! 那...小弟補上一張圖好了! ※先看藍色線條的部分,在看紅色線條的部分! dll是用 vc .net 2003做的(用int main(int argc,char *argv[])去接) 然後給用bcb去下參數,"餵給"dll,之後開始進行編碼程序! ----------------------- 請多多指教啦!!^^ 發表人 - kj68215 於 2004/11/09 18:20:11
------
-----------------------
請多多指教啦!!^^
kj68215
初階會員


發表:47
回覆:91
積分:27
註冊:2003-08-09

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-11-15 10:04:17 IP:221.169.xxx.xxx 未訂閱
小弟這幾天有去找了一下enum的相關資料! 我想會發生這問題,應該是當初在用debug模式時,發生的"列舉變數 xxx 未初始化"的關係.    翻閱了一下Help,上面講到    enum The keyword enum to identifies an enumerated type. enum [tag ] { identifier [=integer-value ] [ , ... ] } Parameters tag Specifies an optional tag for the enumerated type. identifier Specifies the particular enumeration. integer-value Specifies a constant integer value. Return Values This control code's function has no return values. Remarks enum types can appear as type specifiers in typedef declarations, general declarations, and function declarators (either as the function-return-type or as a parameter-type specifier). For the context in which type specifiers appear, see Interface Definition (IDL) File. In the MIDL compiler's default mode, you can assign integer values to enumerators. (This feature is not available when you compile with the /osf switch.) As with C-language enumerators, enumerator names must be unique, but the enumerator values need not be. When assignment operators are not provided, identifiers are mapped to consecutive integers from left to right, starting with zero. When assignment operators are provided, assigned values start from the most recently assigned value. The maximum number of identifiers is 65,535. Objects of type enum are int types, and their size is system-dependent. By default, objects of enum types are treated as 16-bit objects of type unsigned short when transmitted over a network. Values outside the range 0 - 32,767 cause the run-time exception RPC_X_ENUM_VALUE_OUT_OF_RANGE. To transmit objects as 32-bit entities, apply the [v1_enum] attribute to the enum typedef. Example Code
typedef enum {Monday=2, Tuesday, Wednesday, Thursday, Friday} workdays; 
 
typedef enum {Clemens=21, Palmer=22, Ryan=34} pitchers;
然而WMEncoder所提供的CallBack方法,裡頭所用的列舉是的確沒有明確的指定出列舉項目. 於是我改用 Win32專案 / dll 去嘗試,並把警告層級設定為0(不顯示警告),接著把Debug模式設定為Release模式,如此也解決了我目前的這問題! ----------------------- 請多多指教啦!!^^ 發表人 -
------
-----------------------
請多多指教啦!!^^
系統時間:2024-07-02 15:16:22
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!