mfc - Intercept pasting to a (rich) edit control -


i want override default behavior when text pasted rich edit control. specifically, want paste plain-text, not formatted rich-text. guess boils down getting data different clipboard format, don't know how intercept default behavior first.

for reference, have:

class mydialog : public cdialog {  cricheditctrl m_edit; }; 

and relevant ddx_control(pdx, idc_edit1, m_edit) set in cpp file. since don't think cricheditctrl has facility built-in control paste-formatting, how can set elegantly? when google, find lots of people manually capturing ctrl+v, etc... not horrible won't work in languages paste key isn't v!

you intercept en_update instruction , re-format text when receive that? problem don't know new data has been added.

you may, though, find easier override cricheditctrl own , intercept whichevere messages want processing on incoming data , call parent class's implementation of function. way everytime added performing necessary re-formats ...

edit: derive class cricheditctrl pretty easy

class cmyricheditctrl : public cricheditctrl {     declare_dynamic( cmyricheditctrl )  protected:     declare_message_map()  public:     cmyricheditctrl();     virtual ~cmyricheditctrl();     // ... rest of implementation here }; 

you can intercept messages in message map follows...

on_message( em_pastespecial, &cmyricheditctrl::onpastespecial ) 

and handler this:

lresult cmyricheditctrl::onpastespecial( wparam wparam, lparam lparam ) 

wparam clipboard format , lparam contains either null or repastespecial structure.

all need make sure class 1 receives messages , can, done, using dodataexchange function.

define member variable as:

cmyricheditctrl m_myricheditctrl; 

and add following dodataexchange:

ddx_control( pdx, idc_myrichedit, m_myricheditctrl ); 

all messages route through implementation of richeditctrl

you can intercept message, including wm_paste, way ...


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -