有關RichEdit設定問題 |
尚未結案
|
g6101
高階會員 發表:22 回覆:129 積分:110 註冊:2002-06-15 發送簡訊給我 |
|
流
中階會員 發表:36 回覆:142 積分:70 註冊:2003-07-24 發送簡訊給我 |
|
ENIX007
高階會員 發表:28 回覆:274 積分:185 註冊:2003-11-27 發送簡訊給我 |
|
g6101
高階會員 發表:22 回覆:129 積分:110 註冊:2002-06-15 發送簡訊給我 |
|
流
中階會員 發表:36 回覆:142 積分:70 註冊:2003-07-24 發送簡訊給我 |
|
ENIX007
高階會員 發表:28 回覆:274 積分:185 註冊:2003-11-27 發送簡訊給我 |
找到一個很棒的FAQ,裡頭有您第一個問題的解答喔
http://home.att.net/~robertdunn/FAQs/Faqs.html
解答部分在此:(網路法規小弟不是很懂耶,如有犯法請版主大大多多指教喔)
How do determine the current insert/overwrite mode for a TRichEdit? The native Rich Edit control will not tell you whether the next character keyed will be inserted or overwritten. You will have to trap keystrokes and track the insert/overwrite mode yourself. One way to do this is to write your own class, presumably derived from TRichEdit, to track the control's current insert/overwrite state. Note that Rich Edit controls are in insert mode when created. Here is what I use: class TMyRichEdit : public TRichEdit { protected: bool FInsertMode; TNotifyEvent FOnInsertChange; void __fastcall SetInsertMode(bool insertMode); void ToggleInsertMode(void); public: TMyRichEdit(…)… set state variable DYNAMIC void __fastcall KeyDown(Word &Key, Classes::TShiftState Shift); __property bool InsertMode = { read = FInsertMode, write = SetInsertMode, nodefault }; __published: __property TNotifyEvent OnInsertChange = { read = FOnInsertChange, write = FOnInsertChange, default = 0 }; }; //--------------------------------------------------------------------------- void __fastcall TMyRichEdit::KeyDown(Word &Key, Classes::TShiftState Shift) { TRichEdit::KeyDown(Key, Shift); TShiftState noShiftKeys; if (Key == VK_INSERT && Shift == noShiftKeys) { FInsertMode = !FInsertMode; if (FOnInsertChange) FOnInsertChange(this); } } //--------------------------------------------------------------------------- // note: SetInsertMode() does not trigger an OnInsertChange event // void __fastcall TMyRichEdit::SetInsertMode(bool insertMode) { if (insertMode == FInsertMode) return; ToggleInsertMode(); } //--------------------------------------------------------------------------- // note: ToggleInsertMode() does not trigger an OnInsertChange event -- // the FInsertMode member shadow variable gets flipped in the KeyDown() // handler // void TMyRichEdit::ToggleInsertMode(void) { // synthesize an insert keystroke (cannot use keybd_event() because // there is no window associated with the API function) if (!Handle) return; // save and clear the event handler TNotifyEvent event = FOnInsertChange; FOnInsertChange = 0; // the following scarfed from a Micro$oft VB(?) example ::SendMessage(Handle, WM_KEYDOWN, VK_INSERT, 0x00510001); ::SendMessage(Handle, WM_KEYUP, VK_INSERT, 0xC0510001); // restore the event handler FOnInsertChange = event; } //---------------------------------------------------------------------------也就是要自己寫一個class來繼承RichEdit才有辦法辦到... 至於第二個問題,也不知道這裡面有沒有(我也還沒看完,先放上來分享)< > 如果找到再放上來囉< > 程式迷人之處,在於邏輯思考,然而卻也是惱人之處~~
------
程式迷人之處,在於邏輯思考,然而卻也是惱人之處~~ |
g6101
高階會員 發表:22 回覆:129 積分:110 註冊:2002-06-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |