WndProc Overloading的問題 |
答題得分者是:dllee
|
falldog7
一般會員 發表:12 回覆:16 積分:5 註冊:2007-08-30 發送簡訊給我 |
我想重載WndProc來處理一些訊息Message
以下是我的code <textarea class="cpp" rows="10" cols="60" name="code">class TForm1 : public TForm { .... protected: virtual LRESULT __fastcall WndProc(TMessage&); } </textarea> 結果卻出現這樣子的compile Error.... E2113 Virtual function '_fastcall TForm1::WndProc(TMessage &)' conflicts with base class 'TCustomForm' 為什麼會這樣咧@@" 還是一定要宣告成virtual void__fastcall WndProc(TMessage&);才行??? 因為我原本寫在 static LRESULT APIENTRY SkypeAPITest_Windows_WindowProc( HWND hWindow, UINT uiMessage, WPARAM uiParam, LPARAM ulParam) { ... } 有些地方一定要return 才能正常work. 請問有什麼方法可解嗎? |
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
正確的作法應該是寫一個函式用 WindowProc 去指定,請參考 TControl 之 WindowProc 屬性線上說明。
另外,不知道您指的要 Return 是什麼意思?是要給回傳值嗎?TMessage 內有 Result 可以設定 Message return value,請參考。 以下範例取自BCB5線上說明 This example shows how to use the WndProc method and the WindowProc property to subclass a custom control旧 window procedure. This example subclasses the window procedure of a TListBox descendant to respond to a user-defined message called WM_STYLEMESSAGE. The subclassed window procedure can be turned on or off by pressing a radio button. Style = (TListBoxStyle)Message.WParam; else WndProc(Message); } void __fastcall TMyListBoxDescendant::ToggleSubClass(bool On) { if (On) WindowProc = SubClassWndProc; else WindowProc = WndProc; } void __fastcall TForm1::SubClassRadioGroup1Click(TObject *Sender) { MyListBoxDescendant1->ToggleSubClass(SubClassRadioGroup1->ItemIndex == 0); }
------
http://www.ViewMove.com |
falldog7
一般會員 發表:12 回覆:16 積分:5 註冊:2007-08-30 發送簡訊給我 |
|
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |