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

有關RichEdit設定問題

尚未結案
g6101
高階會員


發表:22
回覆:129
積分:110
註冊:2002-06-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-12-17 20:34:48 IP:163.29.xxx.xxx 未訂閱
小弟有二個困擾很久問題,請各位先進幫幫忙:    1.我如何取得/設定RichEdit元件,目前輸入模式是覆寫狀態還是插入狀態?    2.我如何取消標點符號(不允許出現在行頭)避頭點的設定?    新手上路請多包涵!
     
        

中階會員


發表:36
回覆:142
積分:70
註冊:2003-07-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-12-17 23:00:54 IP:163.23.xxx.xxx 未訂閱
g6101 您好:
一、 
(1)
  (a)
    判斷 RichEdit 每一行是不是沒有字
    沒有字時就是覆寫狀態,若有字,就僅是插入狀態
  (b)
    若您的目的與存檔有關,則不必考慮是何種狀態
    直接整個存檔就是,也許這可能不是您的目的吧...    二、
    一樣是判斷是否行頭有標點符號,有的話就不要出現    以上的判斷式都可以寫在 RichEdit1Change     小弟的淺見啦,版上應該會有更好的回答 
         發表人 - 流 於 
        
ENIX007
高階會員


發表:28
回覆:274
積分:185
註冊:2003-11-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-12-18 10:35:31 IP:210.243.xxx.xxx 未訂閱
插個花~~ 針對您的第一個問題,直接按鍵盤上的"Insert"鍵就可以囉
------
程式迷人之處,在於邏輯思考,然而卻也是惱人之處~~
g6101
高階會員


發表:22
回覆:129
積分:110
註冊:2002-06-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-12-18 23:39:33 IP:163.29.xxx.xxx 未訂閱
非常感謝二位先進的回應:    一.或許是小弟問題需求描述的不夠清楚,關於問題(1.)小弟我也知道按"Insert"鍵用於切換插入/覆寫,我要是用何種方法取得目前的輸入狀態?    二.問題(2.)當WordWrap屬性為真(true)時,自動轉行的第一個字元是不允許出現標點符號,如",、。‧!:;?...等等"(系統內定),這時會將上一行最後一個字會移到本行的第一字,我要是將這個設定取消,也就是允許行頭排上標點符號?    還請各位先進幫幫忙,看看我所提的問題有解嗎?
     
        

中階會員


發表:36
回覆:142
積分:70
註冊:2003-07-24

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-12-18 23:56:48 IP:163.23.xxx.xxx 未訂閱
g6101 您好:    (1) 不知道能不能考慮放一個 Button 來切換編輯與否?
   按 Button 來切換 RichEdit 的 Enabled    (2) 記得 word 對這個也沒辦法處理說...最近在打報告也都碰上這種問題
   小弟解決的方式是...自己加一個 Enter ! 在 word 中行頭第一個字
   就可以是標點符號,試試能不能這樣處理?    祝順心了           
        
ENIX007
高階會員


發表:28
回覆:274
積分:185
註冊:2003-11-27

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-12-19 10:32:23 IP:210.243.xxx.xxx 未訂閱
找到一個很棒的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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-12-21 00:12:40 IP:163.29.xxx.xxx 未訂閱
各位好:
既然問題(2)目前沒有更好的方法解決,小弟先把這個主題結案,再另闢新主題
討論,非常感謝所提供另類的思考方向,至於分數就給ENIX007好
了,因為他的解答比較合乎主題哦!最後非常感謝先進們的幫忙
     
        
系統時間:2024-05-15 21:32:00
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!