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

如何呼叫小幫手給自己的程式使用

尚未結案
willis
一般會員


發表:9
回覆:11
積分:4
註冊:2002-09-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-15 16:20:06 IP:61.218.xxx.xxx 未訂閱
之前有看過網頁將OFFICE 小幫手直接呼叫出來當網頁的介紹動畫, 那在BCB中有無方法來將OFFICE中的小幫手呼叫來自己的程式中使用的API。
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-10-15 18:07:36 IP:61.218.xxx.xxx 未訂閱
willis您好: 參考看看 Microsoft Agent http://www.microsoft.com/msagent/default.asp    http://www.msagentring.org/   MS Agent Ring    C++ Builder & MS Agent http://www.pcconcrete.ro/phtml/09/p09041.html    AgentEX for C++ Builder 4 http://www.programfiles.com/Default.asp?LinkId=8429      
/*生活是一種藝術,用心生活才能享受生活*/
發表人 - axsoft 於 2003/10/15 18:14:00
willis
一般會員


發表:9
回覆:11
積分:4
註冊:2002-09-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-10-16 12:56:24 IP:61.218.xxx.xxx 未訂閱
已經參考過了,不過我還有找到delphi 範例,不過不太會轉成BCB,當我轉到SHOW時程式就出現BUG. delphi CODE 如下 { The purpose of this app is to demonstrate usage of the Microsoft Agent (in this case, Robby the Robot). The gradient effect is used only if the machine is displaying > 256 colors. Coded by B. Clay Shannon } unit AgentDemoMain; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ComCtrls; type TfAgentDemoMain = class(TForm) procedure FormCreate(Sender: TObject); procedure FormPaint(Sender: TObject); private AgentInstalled: Boolean; function AgentIsInstalled: Boolean; procedure CreateAndLoadAgentIfInstalled; function GetColorDepth: Word; function GetWinDir: String; procedure SetFormColor; public {} end; var fAgentDemoMain: TfAgentDemoMain; implementation uses AgentDemoConsts, Registry, OLECtrls, AgentObjects_TLB; var RobotAgent: TAgent; {$R *.DFM} {------------------------------------------------------------------------------} procedure TfAgentDemoMain.FormCreate(Sender: TObject); begin SetFormColor; { Changed AgentInstalled from a property to a boolean field with a corresponding function so that it only needs to be evaluated once. Robby} AgentInstalled := AgentIsInstalled; CreateAndLoadAgentIfInstalled; end; {------------------------------------------------------------------------------} function TfAgentDemoMain.AgentIsInstalled: Boolean; begin Result := (FileSearch('Merlin.acs', Format('%s\MSAGENT\CHARS', [GetWinDir]))<>''); end; {------------------------------------------------------------------------------} procedure TfAgentDemoMain.CreateAndLoadAgentIfInstalled; const RightBias = 80; TopBias = 70; var tp: TPoint; begin if (AgentInstalled) and not (Assigned(RobotAgent)) then begin RobotAgent := TAgent.Create(Application); RobotAgent.Characters.Load('Merlin','Merlin.acs'); { Move the Agent to the center of the screen } tp.x := (Screen.Width div 2)-(Width div 2); tp.y := (Screen.Height div 2)-(Height div 2); with RobotAgent.Characters.Item['Merlin'] do begin MoveTo(tp.x RightBias, tp.y TopBias, 0); Show(0); Play('Greet'); Play('Explain'); Speak(SDemoIntro, ''); Play('Pleased'); Play('Wave'); Play('RestPose'); end; end; end; {------------------------------------------------------------------------------} { If the app runs on a machine running 256 colors or less, the GetColorDepth function returns 8 or less (8 if 256). } procedure TfAgentDemoMain.SetFormColor; begin if GetColorDepth <= 8 then begin OnPaint := nil; Color := clSilver; end; end; {------------------------------------------------------------------------------} function TfAgentDemoMain.GetColorDepth: Word; //code adapted from a newsgroup post var DeskDC: HDC; begin DeskDC := 0; try DeskDC := GetDC(0); Result := GetDeviceCaps(DeskDC,BITSPIXEL)*GetDeviceCaps(DeskDC,PLANES); finally ReleaseDC(0,DeskDC); end; end; {------------------------------------------------------------------------------} procedure TfAgentDemoMain.FormPaint(Sender: TObject); var Row, Ht: Word; begin Ht := (ClientHeight 255) div 256; for Row := 0 to 255 do with Canvas do begin { To change the color of the form, alter these three arguments. For example, (Row, Row, Row) produces gray, (Row, 0, 0) produces red, etc. } Brush.Color := RGB(Row, 0, Row); FillRect(Rect(0, Row * Ht, ClientWidth, (Row 1) * Ht)); end; end; {------------------------------------------------------------------------------} function TfAgentDemoMain.GetWinDir : String; var WinDirZ : array[0..256] of Char; begin GetWindowsDirectory(WinDirZ, SizeOf(WinDirZ)); Result := StrPas(WinDirZ); end; end. 當我轉procedure TfAgentDemoMain.CreateAndLoadAgentIfInstalled 內容時 在 Show時發生錯誤 請問大大能幫個忙嗎。謝謝
bruce0211
版主


發表:157
回覆:668
積分:279
註冊:2002-06-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-11-04 09:01:56 IP:211.21.xxx.xxx 未訂閱
如果長官將未完成 bcb source code 也貼上來 相信會有人更有機會回答 因為雖然您說在轉 procedure TfAgentDemoMain.CreateAndLoadAgentIfInstalled 內容時 錯誤 不過為了測試這個錯誤 回答的人還得先把其他程序轉好才能測試這個錯誤....
willis
一般會員


發表:9
回覆:11
積分:4
註冊:2002-09-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-12-24 10:16:45 IP:61.218.xxx.xxx 未訂閱
void __fastcall TMainForm::ShowAgent(int x,int y,int MsgNum,int act,bool English) { HRESULT hRes; IAgentEx *pAgentEx; VARIANT vPath; long lCharID; long lRequestID; BSTR bszSpeak; IAgentCharacterEx *pCharacterEx; //************************************************************************// WideString pop=MainDir "chat\\Genie.acs"; //WideString pop=MainDir "chat\\Peedy.acs"; static LPWSTR kpwzCharacterOld =pop.c_bstr(); pCharacterEx=NULL ; // Initialize COM if (FAILED(CoInitialize(NULL))) { MessageBox(NULL, _T("There was an error initializing COM."), kpszAppTitle, MB_OK | MB_IC CoCreateInstance(CLSID_AgentServer, NULL, CLSCTX_SERVER, IID_IAgentEx, (LPVOID *)&pAgentEx); VariantInit(&vPath); //vPath.vt = VT_EMPTY; vPath.vt = 1; if (FAILED(pAgentEx->Load(vPath, &lCharID, &lRequestID))) { vPath.vt = VT_BSTR; vPath.bstrVal = SysAllocString(kpwzCharacterOld); if (vPath.bstrVal == NULL) { hRes = E_OUTOFMEMORY; return; } hRes = pAgentEx->Load(vPath, &lCharID, &lRequestID); if (FAILED(hRes)) return; } hRes = pAgentEx->GetCharacterEx(lCharID, &pCharacterEx); hRes = pCharacterEx->SetLanguageID(MAKELANGID(LANG_ENGLISH,SUBLANG_CHINESE_TRADITIONAL)); //**********************************************************************// hRes = pCharacterEx->Show(0, &lRequestID); hRes= pCharacterEx->MoveTo(x,y,3,&lRequestID); //*******************動作***********************// switch(act) { case 0: bszSpeak = SysAllocString(L"Explain"); //說明 break; case 1: bszSpeak = SysAllocString(L"Greet"); //歡迎 break; case 2: bszSpeak = SysAllocString(L"Announce"); //播報 break; case 3: bszSpeak = SysAllocString(L"Congratulate"); //祝賀 break; case 4: bszSpeak = SysAllocString(L"DoMagic1"); hRes= pCharacterEx->Play(bszSpeak,&lRequestID); bszSpeak = SysAllocString(L"DoMagic2"); break; case 5: bszSpeak = SysAllocString(L"GestureRight"); break; case 6: bszSpeak = SysAllocString(L"GestureLeft"); break; case 7: bszSpeak = SysAllocString(L"Process");//進程 break; case 8: bszSpeak=SysAllocString(L"Suggest"); //建議 break; case 9: bszSpeak=SysAllocString(L"Read"); //讀 hRes= pCharacterEx->Play(bszSpeak,&lRequestID); bszSpeak=SysAllocString(L"ReadContinued"); //讀 hRes= pCharacterEx->Play(bszSpeak,&lRequestID); bszSpeak=SysAllocString(L"ReadReturn"); //讀 break; case 10: bszSpeak=SysAllocString(L"Confused"); //混亂的 break; } hRes= pCharacterEx->Play(bszSpeak,&lRequestID); //*********************說話***************// TIniFile* pif; WideString msg; BSTR WavFile; if(English) { pif = new TIniFile(MainDir "ini\\English.ini"); } else { pif = new TIniFile(MainDir "ini\\Local.ini"); WideString wav; wav=MainDir "wav\\" pif->ReadString("wav",IntToStr(MsgNum),""); WavFile=SysAllocString(wav.c_bstr()); } msg=pif->ReadString("speak",IntToStr(MsgNum),""); bszSpeak = SysAllocString(msg.c_bstr()); if(English) hRes=pCharacterEx->Speak(bszSpeak,NULL,&lRequestID); else hRes=pCharacterEx->Speak(bszSpeak,WavFile,&lRequestID); SysFreeString(bszSpeak); delete pif; } 上面是我完成秀出Agent 的副程式,也可以將英文透過音效卡讀出,但是我要如何得到AGENT 的ONCLICK EVENT 。 我有試著用BCB所提供的ACTIVEX TAGENT 控制件,裡面雖有寫好的ONCLICK EVENT 但是使用後卻無法發出唸英文的聲音,需要用錄製成.WAV 才可發出聲音,而上述完成的CODE 可發出英文但卻不知如何得到ONCLICK EVENT ,請問大大我到底要如何克服這問題,希望你能解答。
anpino
版主


發表:31
回覆:477
積分:231
註冊:2003-01-02

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-05-06 16:00:10 IP:211.23.xxx.xxx 未訂閱
不同或延伸出與主題不同的問題, 請用別的主題發問, 並請記得結案。 ------------------------------- 數學系是內功很強(邏輯/分析) 資工系是招式很多(程式技巧) 就像令狐沖VS東方不敗:D -------------------------------
系統時間:2017-11-22 20:43:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!