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>