Use hyperlinks in Richedit 2.0. Send a message. Nice article.

xiaoxiao2021-03-06  83

Creating the Outlookrichedit Control

Rating:

None

Madhu B Nair (View Profile) Decemcer 30, 2002

(Continued)

ENVIRONMENT: VC6 SP4, 2000.

FOLLOW THESE 10 Easy Steps to Build The Outlookrichedit Control:

Insert a rich edit control into the dialog. Call AfxInitRichEdit () in the InitInstance of the App class or in InitDialog. If it does not exist, copy OutLookRichEdit.cpp and OutLookRichEdit.h to the project directory. Click the menu choice Project-Add to Project-Files and select the above-copied files to add the wrapper class to your project. Import the hand cursor into the resource and rename it "IDC_LINK". Use Classwizard to add a member variable of the rich edit control (CRichEditCtrl). Include the Outlookrichedit.h File in The Dialog's Header File and Change The Dialog's Header File Variable, AS in cricheditctrl m_ctrltext1

To coutlookrichedit m_ctrlText1;

INITDIALOG (), add the folowing code. M_ctrltext1.setrawhypertext (_T ("Click <% $ here # 100 #%>

To See the About Box. ");

At this level, if you build the project and run it, you can see the rich edit control with linked text, but nothing would happen if you clicked on the link. To Show a dialog while the link is clicked, you have to add some more code in the dialog class. Before that, have a closer look at the preceding code and hypertext syntax. The link text is enclosed between the "$" symbols and the corresponding dialog's resource value 100 (About Box), enclosed in "#" . symbols You can find the #define values ​​of dialogs in the resource.h file Use ClassWizard to map OnNotify of the dialog and write the corresponding implementation code in .cpp file, like:. BOOL CDEMODlg :: OnNotify (wPARAM wParam,

LPARAM LPARAM, LRESULT * PRESULT)

{

NmHDR * pnmhdr = (nmHDR *) LPARAM;

IF (idc_richedit1 == pnmhdr-> idfrom) {

Switch (pnmhdr-> code)

{

Case IDD_Aboutbox:

Caboutdlg Odlg;

Odlg.domodal ();

Break;

}

}

Return CDialog :: ONNOTIFY (WPARAM, LPARAM, PRESULT);

}

Now, Build and Run The Project. It is recommented That You set the read-only attribute to the rich edit control.

Downloads

Download Demo Project - 23 KB

Download Source - 6 KB

转载请注明原文地址:https://www.9cbs.com/read-105110.html

New Post(0)