Wince Edit Control copy/paste

Source: Internet
Author: User

Wince Edit Control copy/paste

 

Author: Lai yuping (aulyp@163.com)

 

In Windows CE, when you write an MFC program, the Edit Control is frequently used. However, by default, the content you input on the control does not support copying and pasting, there is no right-click menu, which is very inconvenient. I found no detailed information on Google. I can only read the help documentation of E. In fact, it is not difficult to implement it. The following is the step, share it with you.

1) Respond to the wm_rbuttondown message in pretranslatemessage. (For more information about how to reload pretranslatemessage in MFC, see my other blog .)

Bool newsmsdlg: pretranslatemessage (MSG * PMSG) <br/>{< br/> DWORD regvalue; <br/> bool bproces; <br/> // static bool com7state; <br/> switch (PMSG-> message) <br/>{< br/> case wm_rbuttonup: /* Right click message */<br/> {<br/> If (getfocus () = getdlgitem (idc_edit_newwrite )) // The Judgment focus is not in the box <br/>{< br/> retailmsg (1, (text ("Right button/R/N "))); <br/> point Pt = {0}; <br/> getcursorpos (& pt ); // obtain the mouse clicking position <br/> // ------ generate the corresponding menu ------------------------- <br/> cmenu menu; <br/> menu. createpopupmenu (); // generate a menu object <br/> menu. appendmenu (mf_string, contenteditcopy, l "copy"); <br/> menu. appendmenu (mf_string, contenteditpaste, l "Paste"); <br/> menu. trackpopupmenu (0, PT. x, PT. y, this); // plistctrl <br/> menu. destroymenu (); <br/>}< br/> break; <br/> default: break; <br/>}< br/> return cdialog:: pretranslatemessage (PMSG); <br/>}< br/> 

 

 

 

2) Respond to menu events

All menu messages in MFC are processed in oncommand and the oncommand function is reloaded. The specific method is to open the header file of the dialog window where your editcontrol is located, and then focus the mouse on the class, view the "properties" window,

 

 

 

 

 

 

Then process menu operations in oncommand, such as copying/pasting

 

 

 

 Bool newsmsdlg: oncommand (wparam, lparam) </P> <p >{</P> <p> int menuid = loword (wparam ); </P> <p> switch (menuid) </P> <p >{</P> <p> case contenteditcopy: // copy </P> <p >{</P> <p>: sendmessage (getdlgitem (idc_edit_newwrite)-> getsafehwnd (), wm_copy, 0, 0 ); </P> <p> break; </P> <p >}</P> <p> case contenteditpaste: // paste </P> <p >{</P> <p>: sendmessage (getdlgitem (idc_edit_newwrite)-> getsafehwnd (), wm_paste, 0, 0 ); </P> <p> break; </P> <p >}</P> <p> default: break; </P> <p >}</P> <p> return cdialog: oncommand (wparam, lparam ); </P> <p >}</P> <p>

 

 

Here, the editcontrol control in your program can be used to copy and paste data.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.