Windows Client development -- duilib display html

Source: Internet
Author: User

Windows Client development -- duilib display html

Today we will share with you how to display html in the duilib library.

Some controls, such as Text, can use the showhtml function to set whether to display html rich Text.

Bold

{B} bold {/B}

Italics

{I} italic {/I}

Underline

{U} underline {/u}

Selected

{S} selected {/s}

Line feed

{n}

Link
This is the most important personal opinion.

{A http://www.baidu.com} Baidu {/a>}

For example:
Input
Www.baidu.com {n} {B} bold {/B} {n} {I} italic {/I} {n} {u} underline {/u} {n} {s} selected {/s}

Display:

Finally, post a piece of duilib code about how to handle the link: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxwcmUgY2xhc3M9 "brush: java;"> <code class = "hljs lasso"> case _ T ('A'): // Link {pstrText ++; while (* pstrText> _ T ('\ 0') & * pstrText <= _ T ('') pstrText =: CharNext (pstrText ); if (iLinkIndex <nLinkRects &&! BLineDraw) {CDuiString * pStr = (CDuiString *) (sLinks + iLinkIndex); pStr-> Empty (); while (* pstrText! = _ T ('\ 0') & * pstrText! = _ T ('>') & * pstrText! = _ T ('}') {LPCTSTR pstrTemp =: CharNext (pstrText); while (pstrText <pstrTemp) {* pStr + = * pstrText ++ ;}}} DWORD clrColor = pManager-> getdefalinklinkfontcolor (); if (bHoverLink & iLinkIndex <nLinkRects) {CDuiString * pStr = (CDuiString *) (sLinks + iLinkIndex ); if (sHoverLink = * pStr) clrColor = pManager-> getdefalinklinkhoverfontcolor () ;}// else if (prcLinks = NULL) {// if (: PtInRect (& rc, ptMouse) // clrColor = pManager-> getdefalinklinkhoverfontcolor (); //} aColorArray. add (LPVOID) clrColor);: SetTextColor (hDC, RGB (GetBValue (clrColor), GetGValue (clrColor), GetRValue (clrColor ))); TFontInfo * pFontInfo = pManager-> GetDefaultFontInfo (); if (aFontArray. getSize ()> 0) pFontInfo = (TFontInfo *) aFontArray. getAt (aFontArray. getSize ()-1); if (pFontInfo-> bUnderline = false) {HFONT hFont = pManager-> GetFont (pFontInfo-> sFontName, pFontInfo-> iSize, pFontInfo-> bBold, false, pFontInfo-> bItalic); if (hFont = NULL) {hFont = pManager-> AddFont (g_iFontID, pFontInfo-> sFontName, pFontInfo-> iSize, pFontInfo-> bBold, false, pFontInfo-> bItalic); g_iFontID + = 1;} pFontInfo = pManager-> GetFontInfo (hFont); aFontArray. add (pFontInfo); pTm = & pFontInfo-> tm;: SelectObject (hDC, pFontInfo-> hFont); cyLine = MAX (cyLine, pTm-> tmHeight + pTm-> tmExternalLeading + (int) aPIndentArray. getAt (aPIndentArray. getSize ()-1);} ptLinkStart = pt; bInLink = true;} break; </code>

Related Article

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.