![]() |
Desktop Development »
Static & Panel Controls »
Beginners
Intermediate
CPPHtmlStatic v1.2By Eugene PustovoytA control based on CStatic for displaying HTML-like text formatting elements. |
VC6, VC7, VC7.1Win2K, WinXP, MFC, STL, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
To integrate HTML drawer in your application you should add next files to your project:
Extend background effects by Davide Pizzolato and Davide Calabro become available
if defined USE_SHADE:
In PPDrawManager.h
#define USE_SHADE
Include PPHtmlDrawer.h in the header file where you want to use the CPPHtmlStatic and create a member variable:
CPPHtmlStatic m_html_static; or CPPHtmlStatic * m_pHtmlStatic;
Construction |
|
| CPPHtmlStatic | Constructs a CPPHtmlStatic object. |
|
Operation |
|
| SetWindowText | Specifies a text to be displayed in the static control. |
| SetHyperlink | Specifies a hyperlink to be displayed in the static control. |
| SetIcon | Specifies an icon to be displayed in the static control. |
| SetBitmap | Specifies a bitmap to be displayed in the static control. |
| SetAnimation | Specifies an animation image to be displayed in the static control. |
| SetImageList | Specifies an item from an image list to be displayed in the static control. |
|
Align |
|
| SetAlign | Sets the object-alignment flags |
| GetAlign | Gets the object-alignment flags. |
|
Drawing |
|
| SetImageZoom | Sets the zoom factor for an image |
| SetFrameRate | Sets the new frame rate for the animation. |
| ClearFrameRate | Sets the new frame rate for the animation. |
| SetCallbackHyperlink | Sets the callback messages from the control to the parent window by clicks a hyperlink. |
| SetFont | Sets the window's current font to the specified font. |
| GetFont | Gets the current font for this window. |
| SetTextColor | Sets the text color. |
| SetBkColor | Sets the current background color. |
| SetBkMode | Sets the background mode. |
| SetHyperlinkStyle | Sets the style of the hyperlink. |
|
Borders |
|
| SetRgn | Sets a region |
| SetRectRgn | Creates and sets a rectangle region |
| SetRoundRectRgn | Creates and sets a rounded rectangle region |
| SetBorder | Sets a static's border |
|
Version |
|
| GetVersionI | Get CPPHtmlStatic version |
| GetVersionC | Get CPPHtmlStatic version |
CPPHtmlStatic ();
Remarks
Constructs a CPPHtmlStatic object.
Example
// Create a static object on the stack. CHtmlStatic m_HtmlStatic; // Create a static object on the heap. CHtmlStatic* m_pHtmlStatic = new CHtmlStatic;
CPPHtmlStatic Overview | Class Members
void SetWindowText(LPCTSTR lpszText);
Parameters
lpszText -
Specifies the text to place in the control. If NULL , no text will be visible. This text may be a HTML string.Remarks
This method sets the static title to the specified text. This method causes a WM_SETTEXT message to be sent to this window. Text may be a HTML string like this:
<h2>CPPHtmlStatic</h2><br><hr color=blue><br>
CPPHtmlStatic Overview | Class Members
void SetHyperlink(LPCTSTR lpszText, LPCTSTR lpszUrl, BOOL bParentNotify /* = FALSE */);
Parameters
lpszText - Specifies the visible text for a hyperlink. Can't be NULL.lpszUrl - Specifies the target URL. Can't be NULL.bParentNotify - If TRUE will be create a hyperlink for send message to the parent.Remarks
Call this method to create an hyperlink control.
Example
// Create a hyperlink control for open WWW link. m_html.SetHyperlink("Goto the Codeproject", "http://www.codeproject.com"); // Create a hyperlink control to send a mail to me. m_html.SetHyperlink("Send mail to me", "mailto:pustovoyt@mail.ru"); // Create a hyperlink control to send a message to //the parent with label "click no.1". m_html.SetHyperlink("Notify a parent", "click no.1", TRUE);
CPPHtmlStatic Overview | Class Members
void SetIcon(DWORD dwIdIcon, LPSIZE lpSize /* = NULL */);void SetIcon(HICON hIcon);
Parameters
dwIdIcon - ID number of the icon resource to be drawn in the static control.lpSize - A size of the loading icon. hIcon - Handle of the icon to be drawn in the static control.Remarks
Call this member function to associate a new icon image with the static control. The icon will be automatically drawn in the static control.
CPPHtmlStatic Overview | Class Members
void SetBitmap(DWORD dwIdBitmap, COLORREF clrMask /*= RGB(255, 0, 255)*/);void SetBitmap(HBITMAP hBitmap, COLORREF clrMask /*= RGB(255, 0, 255)*/);
Parameters
dwIdBitmap -
ID number of the bitmap resource to be drawn in the static control.hBitmap -
Handle of the bitmap to be drawn in the static control.clrMask - A transparent color on the bitmap. -1 if not transparent color present Remarks
Call this member function to associate a new bitmap with the static control. The bitmap will be automatically drawn in the static control.
CPPHtmlStatic Overview | Class Members
void SetAnimation(DWORD dwIdBitmap, LPSIZE lpSizeItem, COLORREF clrMask /*= RGB(255, 0, 255)*/);void SetAnimation(HBITMAP hBitmap, LPSIZE lpSizeItem, COLORREF clrMask /*= RGB(255, 0, 255)*/);
Parameters
dwIdBitmap - ID number of the bitmap resource with image list.hBitmap - Handle of the bitmap with image list.clrMask - A transparent color on the bitmap. -1 if not transparent color present.lpSizeItem -
Dimensions of each image.Remarks
Call this method to draw an image list as animation.
CPPHtmlStatic Overview | Class Members
void SetImageList(DWORD dwIdBitmap, DWORD dwIndex, LPSIZE lpSizeItem, COLORREF clrMask /*= RGB(255, 0, 255)*/);void SetImageList(HBITMAP hBitmap, DWORD dwIndex, LPSIZE lpSizeItem, COLORREF clrMask /*= RGB(255, 0, 255)*/);
Parameters
dwIdBitmap - ID number of the bitmap resource with image list.hBitmap - Handle of the bitmap with image list.clrMask - A transparent color on the bitmap. -1 if not transparent color present.lpSizeItem - Dimensions of each image.dwIndex -
Zero-based index of the image
.Remarks
Call this member function to associate an image from an image list with the static control.
CPPHtmlStatic Overview | Class Members
void SetAlign(DWORD dwAlign /*= PPHTMLSTATIC_ALIGN_DEFAULT*/);
Parameters
dwAlign - Specifies object-alignment flags. The first category affects object alignment in the x-direction:Remarks
Sets the object-alignment flags.
CPPHtmlStatic Overview | Class Members
DWORD GetAlign();
Return value
The status of the object-alignment flags. See the SetAlign function for the list of the available flagsRemarks
Retrieves the status of the object-alignment flags.
CPPHtmlStatic Overview | Class Members
void SetImageZoom(int nWidthPercent /*= 100*/, int nHeightPercent /*= 100*/);void SetImageZoom(int nPercent /*= 100*/);
Remarks
Sets the zoom factor (in percents) for an image.
CPPHtmlStatic Overview | Class Members
void SetFrameRate(DWORD dwFrameRate /*=500*/);
Parameters
dwFrameRate -
Specified a time-out value between current and next displayed bitmap.Remarks
Sets the new frame rate for the animation. For the CPPHtmlStaticl class the frame rate means a time-out period in milliseconds between current and next bitmap instead of number of frames per second. The default value is 500 milliseconds.
CPPHtmlStatic Overview | Class Members
void ClearFrameRate();
Remarks
Kills an animation timer.
CPPHtmlStatic Overview | Class Members
void SetCallbackHyperlink(UINT nMessage, LPARAM lParam /* = 0 */);
Parameters
nMessage -
Specifies the message to be sent.lParam -
Specifies additional user-defined informationRemarks
This method sets the callback messages from the control to the parent window if user clicks a hyperlink with msg parameter.
Format a callback message:
Msg - Specified ID message
wParam - Pointer to the string specified as msg
parameter of the "#A_Tag"><a> tag.
lParam - Additional user-defined value
CPPHtmlStatic Overview | Class Members
void SetFont(CFont* pFont, BOOL bRedraw /*= TRUE*/);
Parameters
pFont - Specifies the new font.bRedraw - If TRUE, redraw the CPPHtmlStatic objectRemarks
Sets the window's current font to the specified font. If bRedraw is TRUE , the window will also be redrawn.
CPPHtmlStatic Overview | Class Members
CFont* GetFont();
Return value
A pointer to a CFont that contains the current font. The pointer may be temporary and should not be stored for later use.
Remarks
Gets the current font for this window.
CPPHtmlStatic Overview | Class Members
void SetTextColor(COLORREF clrText);
Parameters
clrText -
Specifies the color of the text as an RGB color value.Remarks
Sets the text color to the specified color.
CPPHtmlStatic Overview | Class Members
void SetBkColor(COLORREF clrBk);
Parameters
clrBk -
Specifies the new background color.Remarks
Sets the current background color to the specified color.
CPPHtmlStatic Overview | Class Members
void SetBkMode(int nBkMode /*= TRANSPARENT*/);
Parameters
nBkMode - Specifies the mode to be set. This parameter can be either of the following values:
Remarks
Sets the background mode. The background mode defines whether the system removes existing background colors on the drawing surface before drawing text.
CPPHtmlStatic Overview | Class Members
void SetHyperlinkStyle(COLORREF clrOrg, BOOL bOrgUnderline, COLORREF clrHover, BOOL bHoverUnderline);
Parameters
clrOrg - Specifies the color of the hyperlink text when mouse isn't over the link.bOrgUnderline - Specifies the underline style of the hyperlink text when mouse isn't over the link.clrHover - Specifies the color of the hyperlink text when mouse is over the link.bHoverUnderline - Specifies the underline style of the hyperlink text when mouse is over the link.Remarks
Specified the colors and underline styles for normal and hover mode of the hyperlink.
CPPHtmlStatic Overview | Class Members
void SetRgn(HRGN hRgn = NULL);
Parameters
hRgn -
Handle to the region to be selected. NULL if any region must be delete.Remarks
Specified a region as the current clipping region for the static control.
CPPHtmlStatic Overview | Class Members
void SetRectRgn();
Remarks
Creates a rectangular region by client area of the static control and select him as the current clipping region.
CPPHtmlStatic Overview | Class Members
void SetRoundRectRgn(int nWidth, int nHeight);
Parameters
nWidth -
Specifies the width of the ellipse used to create the rounded corners.nHeight - Specifies the height of the ellipse used to create the rounded corners.Remarks
Creates a rectangular region with rounded corners by client area of the static control and select him as the current clipping region.
CPPHtmlStatic Overview | Class Members
void SetBorder(COLORREF color, int nWidth = 1, int nHeight = 1);void SetBorder(HBRUSH hbr, int nWidth = 1, int nHeight = 1);
Parameters
color - Specifies the color to create a solid brush.hbr -
Handle to the brush to be used to draw the border.nWidth -
Specifies the width, in logical units, of vertical brush strokes.nHeight -
Specifies the height, in logical units, of horizontal brush strokes.Remarks
Draws a border around the specified region by using the specified brush.
CPPHtmlStatic Overview | Class Members
short GetVersionI()
Return Value
Number version of CPPHtmlStatic.
Remarks
Returns the CPPHtmlStatic version as a short number. Divide by 10 to get actual version.
CPPHtmlStatic Overview | Class Members
LPCTSTR GetVersionC()
Return Value
Number version of CPPHtmlStatic as string.
Remarks
Returns the CPPHtmlStatic version as a string.
CPPHtmlStatic Overview | Class Members
| 09 May 2004 | First release |
| 25 May 2004 |
Released version 1.1 |
| 25 September 2004 |
Released version 1.2 |
You are encouraged to use this class everywhere you want; there is no fee required for CPPHtmlStatic. Freely add modifications and/or fix bugs, but please, send any of these to me!
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 4 Mar 2005 Editor: Paul Watson |
Copyright 2004 by Eugene Pustovoyt Everything else Copyright © CodeProject, 1999-2009 Web11 | Advertise on the Code Project |