![]() |
Desktop Development »
Button Controls »
Owner-draw buttons
Intermediate
CButtonSSLBy Derek LakinAn owner-drawn, flat, menu button that correctly handles the default state |
VC6, Windows, MFC, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

CButtonSSL has now been used extensively in a real product and has such has
been through the mill a fair bit on the testing side. Thankfully this has given
me time to find and fix these problems, too.
This latest version includes fixes for a GDI resource leak (which I must thank Dieter Hammer for finding), several changes to fix button state drawing problems (which I must thank Eugene Pustovyt for pointing out some of the more obscure ones) and also fixes a major bug with release builds.
The problem was that in a release build that included a CButtonSSL checkbox
whose state was altered using SetCheck the application would crash.
After enormous amounts of mostly fruitless debugging I eventually found a
way of reproducing the problem consistently, with the help of Alvaro Mendez.
Once I'd got to this stage I beginning to despait , but thankfully Joe Newcomer
came to my rescue and pointed out the error of my ways. The OnSetCheck handler
didn't define both of the required parameters for an ON_COMMAND handler. So, two
parameters pushed on the stack, only one popped off!
I'd like to thank everybody that has helped me out with this round of bug fixes, hopefully there won't be (m)any more.
It seems that no matter how hard you try, you just can't get enough done in one day! Trying to juggle work, play and family isn't easy! However, at last I have got round to updating this article. So, what's new?
CButtonSSL now inherits from "http://www.codeproject.com/buttonctrl/oddbutton.asp">COddButton, though there are one or two
changes I've made to it (see below).
Because there's so much been added I haven't had chance to test it all extensively, especially with respect to the menu functions. If there any problems, please let me know (prefereably with a fix ;)).
The change to inherit from COddButton has changed the handling of the standard
button styles. The use of COddButton::PreSubclassWindow means that the control
type is determined from the initial styles set in the dialog editor. So now
you cannot set the Owner Draw style, otherwise it won't work properly.
The handling of the default style is also provided entirely by COddButton now, though as mentioned above, I have made one or two changes to handle radio buttons as well.
The first change was to the constructor to make m_bCanBeDefault TRUE
initially. The second change was to the WM_GETDLGCODE handler, COddButton::OnGetDlgCode
(). The function now handles the code for radio buttons as follows:
UINT COddButton::OnGetDlgCode()
{
UINT nCode = CButton::OnGetDlgCode();
// tell the system if we want default state handling
// (losing default state always allowed)
UINT nType = GetControlType ();
if (BS_RADIOBUTTON == (BS_RADIOBUTTON & nType) ||
BS_AUTORADIOBUTTON == (BS_AUTORADIOBUTTON & nType)) {
nCode |= DLGC_RADIOBUTTON;
}
else {
if (m_bCanBeDefault || m_bDefault)
nCode |= (m_bDefault ? DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON);
}
return nCode;
}
It seems that Buttons are the flavour of the month at the moment and here's another. This button class is born out the need for a bitmap button with a menu drop-down on it, but as usual ended up being so much more!
I found Norm Almond's "Cool Push Menu
Button" and Davide Calabro's CButtonST and
wanted to combine the two. Along the way I came across the
BS_OWNERDRAW problem and tried to find my own way around it.
Fortunately Paolo Messina and Jerzy Kaczorowski solved it for me with their COddButton.
The class I have come up with draws mainly from these sources, but also some others and my thanks must go out to all those people who have helped me out in the Visual C++ forum. It has taken me so long to complete this and I have been a bit too relaxed with the documentation so if there is some code that you lay claim to and want it recognised then please let me know and I'll update it.
The full documentation for the class follows. I hope this is sufficient because it took me ages to write ;)
Overview | Class Members | Styles | Known Problems

The CButtonSSL is a feature rich extension to the normal
CButton. It adds flat appearance, a menu drop-down, bitmap or icon
images, text and image alignment, control over the button colour, multiline
tooltip, correct default button handling, control over the cursor and the
ability to specifiy a URL to link to.
CButtonSSL provides owner-drawn functionality for check boxes,
radio buttons and push buttons. A CButtonSSL object can be created
for any of these.
A CButtonSSL object can have separate images for the button's
up, over, down and disabled states. If an image is not specified for the
disabled state a disabled images is created from the up image, which must always
be specified. Additionally, the button colour and text colour can be different
for the button's up, over and down states.
Creation of CButtonSSL object is the same as for a CButton
object. They may be created from a dialog template or directly in your code.
If they are created from a dialog template it is not necessary to call SubclassDlgItem
if the DDX_Control entry exists for the variable in the DoDataExchange
function of your dialog. However the button is created it must not have
the BS_OWNERDRAW style set.
Following construction the button object's appearance should be initialised. The button's image(s) and the image alignment can be set using the Image Functions. The button text font and alignment can be altered using the Text Functions. The button's colours can be set using one of the Colour Functions and the button cursor, tooltip or URL can be set using one of the Miscellaneous Functions. If the button object is a checkbox then the button's check state can be set or retrieved using the Check Box Functions.
Windows notification messages are sent by the button control to the parent
for CButtonSSL objects in the same manner as for
CButton objects.
If you create a CButtonSSL object from a dialog resource, the
CButtonSSL object is automatically destroyed when the user closes
the dialog box.
#include "ButtonSSL.h"
Overview | Class Members | Styles | Known Problems
"#CButtonSSL">CButtonSSL |
Constructs a CButtonSSL
object. |
"#ButtonStyles">SetSSLButtonStyle |
Changes the style of a buton. |
"#GetSSLButtonStyle">GetSSLButtonStyle |
Retrieves information about the button control style. |
"#SetSSLButtonBitmap">SetSSLButtonBitmap |
Specifies a single bitmap as the image for all button states. |
"#SetSSLButtonBitmaps">SetSSLButtonBitmaps |
Specifies different bitmaps for different button states. |
"#SetSSLButtonIcon">SetSSLButtonIcon |
Specifies a single icon as the image for all button states. |
"#SetSSLButtonIcons">SetSSLButtonIcons |
Specifies different icons for different button states. |
"#SetSSLImageAlign">SetSSLImageAlign |
Sets the alignment of the button image. |
"#SetSSLImageAlign">GetSSLImageAlign |
Retrieves the image alignment for the button image. |
"#SetSSLTextAlign">SetSSLTextAlign |
Sets the alignment for the button text. |
"#GetSSLTextAlign">GetSSLTextAlign |
Retrieves the alignment of the button text. |
"#SetSSLButtonFont">SetSSLButtonFont |
Specifies font characteristics for the button text |
"#SetSSLDefaultColors">SetSSLDefaultColors |
Sets the button and text colours to the default system defined colours. |
"#SetSSLDefaultColors">SetSSLColor |
Specifies the colour to use for the button face or text for a particular button state. |
"#SetSSLColor">GetSSLColor |
Retrieves the colour for the button face or text for a particular button state previously set with SetSSLColor. |
"#SetSSLCheck">SetSSLCheck |
Sets the check state of a check box style button. |
"#SetSSLCheck">GetSSLCheck |
Retrieves the check state of a check box style button. |
"#SetSSLButtonMenu">SetSSLButtonMenu |
Specifies the menu resource to use for a menu button. |
"#CheckSSLMenuItem">CheckSSLMenuItem |
Places a check mark next to or removes a check mark from a menu item in the pop-up menu. |
"#CheckSSLMenuRadioItem">CheckSSLMenuRadioItem |
Places a radio button next to a menu item and removes the radio button from all of the other menu items in the group. |
"#EnableSSLMenuItem">EnableSSLMenuItem |
Enables, disables, or dims (grays) a menu item. |
"#GetSSLMenuItemCount">GetSSLMenuItemCount |
Determines the number of items in a pop-up or top-level menu. |
"#GetSSLMenuItemID">GetSSLMenuItemID |
Obtains the menu-item identifier for a menu item located at the specified position. |
"#GetSSLMenuState">GetSSLMenuState |
Returns the status of the specified menu item or the number of items in a pop-up menu. |
"#GetSSLMenuString">GetSSLMenuString |
Retrieves the label of the specified menu item. |
"#GetSSLMenuItemInfo">GetSSLMenuItemInfo |
Retrieves information about a menu item. |
"#ModifySSLMenu">ModifySSLMenu |
Changes an existing menu item at the specified position. |
"#RemoveSSLMenu">RemoveSSLMenu |
Deletes a menu item with an associated pop-up menu from the specified menu. |
"#SetSSLMenuItemBitmaps">SetSSLMenuItemBitmaps |
Associates the specified check-mark bitmaps with a menu item. |
"#SetSSLButtonCursor">SetSSLButtonCursor |
Specifies the cursor to display when the mouse is over the button. |
"#SetSSLButtonTooltip">SetSSLButtonToolTip |
Specifies the tooltip to display when the mouse is hovered over the button. |
"#SetSSLButtonURL">SetSSLButtonURL |
Specifies the URL to be launched when the button is clicked. |
Overview | Class Members | Styles | Known Problems
CButtonSSL ();
Constructs a CButtonSSL object. The button style is initially
set to SSL_BS_FLAT, the image is initially aligned using
SSL_IMAGE_TOP and SSL_IMAGE_LEFT and the text is
initially aligned using SSL_TEXT_CENTER and
SSL_TEXT_VCENTER.
Overview | Class Members | Styles | Known Problems
void SetSSLButtonStyle (UINT nStyle);
nStyle
Specifies the button
style.
Changes the style of a button.
Use the GetSSLButtonStyle member function to retrieve the button
style.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::GetSSLButtonStyle
UINT GetSSLButtonStyle ();
Returns the button styles for this button object.
Returns only the SSL_BS_ style values, not any of the window styles.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLButtonStyle
BOOL SetSSLButtonBitmap (UINT nResourceID, COLORREF crMask =
SSL_MASK);
Nonzero if successful; otherwise 0.
nResourceID
The resource ID for the bitmap to be added.
crMask
The colour to be used in the bitmap as a transparency
mask. This is "#SSL_MASK">SSL_MASK
by default.
This function specifies a single bitmap to use for all states. The bitmap is copied into an image list and then treated as an icon thereafter. When the button is in the disabled state a disabled image is created from the specified bitmap.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLButtonBitmaps, CButtonSSL::SetSSLButtonIcon, CButtonSSL::SetSSLButtonIcons
BOOL SetSSLButtonBitmaps (UINT nUpID, COLORREF crUpMask, UINT nOverID =
0, COLORREF crOverMask = SSL_MASK, UINT nDownID = 0, COLORREF crDownMask =
SSL_MASK, UINT nDisabledID = 0, COLORREF crDisabledMask = SSL_MASK);
Nonzero if successful; otherwise 0.
nUpID
The resource ID for the bitmap to be used for the up
state.
crUpMask
The colour to be used in the up bitmap as a
transparency mask. This is "#SSL_MASK">SSL_MASK
by default.
nOverID
The resource ID for the bitmap to be used for the
over state. This is zero by default.
crOverMask
The colour to be used in the over bitmap as a
transparency mask. This is "#SSL_MASK">SSL_MASK
by default.
nDownID
The resource ID for the bitmap to be used for the
down state. This is zero by default.
crDownMask
The colour to be used in the down bitmap as a
transparency mask. This is "#SSL_MASK">SSL_MASK
by default.
nDisabledID
The resource ID for the bitmap to be used for the
disabled state. This is zero by default.
crDisabledMask
The colour to be used in the disabled bitmap
as a transparency mask. This is "#SSL_MASK">SSL_MASK
by default.
The up bitmap must be defined, however, a resource ID of zero may be defined for any state image that is not required. If no bitmap is specified for the over state then the up image is used instead. If no bitmap is specified for the down state then the over image is used instead (if this was not specified then the up image will be used).
If a bitmap is specified for the disabled state then this will be used in full colour. If it is not then the up image will be used to create a normal disabled image.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLButtonBitmap, CButtonSSL::SetSSLButtonIcon, CButtonSSL::SetSSLButtonIcons
BOOL SetSSLButtonIcon (UINT nResourceID);
Nonzero if successful; otherwise 0.
nResourceID
The resource ID for the icon to be added.
This function specifies a single icon to use for all states. The icon is copied into an image list. When the button is in the disabled state a disabled image is created from the specified icon.
The transparency defined in the source icon is preserved.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLButtonBitmap, CButtonSSL::SetSSLButtonBitmaps, CButtonSSL::SetSSLButtonIcons
BOOL SetSSLButtonIcons (UINT nUpID, UINT nOverID = 0, UINT nDownID = 0,
UINT nDisabledID = 0);
Nonzero if successful; otherwise 0.
nUpID
The resource ID for the icon to be used for the up
state.
nOverID
The resource ID for the icon to be used for the over
state. This is zero by default.
nDownID
The resource ID for the icon to be used for the down
state. This is zero by default.
nDisabledID
The resource ID for the icon to be used for the
disabled state. This is zero by default.
The up icon must be defined, however, a resource ID of zero may be defined for any state image that is not required. If no icon is specified for the over state then the up image is used instead. If no icon is specified for the down state then the over image is used instead (if this was not specified then the up image will be used).
If an icon is specified for the disabled state then this will be used in full colour. If it is not then the up image will be used to create a normal disabled image.
The transparency of the source icon is preserved.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLButtonBitmap, CButtonSSL::SetSSLButtonBitmaps, CButtonSSL::SetSSLButtonIcon
void SetSSLImageAlign (UINT nImageAlign);
nImageAlign
Specifies the image alignment
style.
A single horizontal and vertical alignment style may be specified, though there are no checks within the function to ensure that this is the case.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::GetSSLImageAlign
UINT GetSSLImageAlign ();
The button image alignment style.
This function returns only the "#AlignmentSTyles">SSL_IMAGE_
style values.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLImageAlign
void SetSSLTexteAlign (UINT nTextAlign);
nTextAlign
Specifies the text alignment
style.
A single horizontal and vertical alignment style may be specified, though there are no checks within the function to ensure that this is the case.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::GetSSLTextAlign
UINT GetSSLTextAlign ();
The button text alignment style.
This function returns only the "#AlignmentSTyles">SSL_TEXT_
style values.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLTextAlign
BOOL SetSSLButtonFont (LPCTSTR lpszFaceName, int nSizePoints = 8, BOOL
bUnderline = FALSE, BOOL bBold = FALSE, BOOL bStrikeOut = FALSE, BOOL bItalic =
FALSE);
BOOL SetSSLButtonFont (CFont& font);
Nonzero if successful; otherwise 0.
lpszFaceName
The font face name.
nSizePoints
The font size in points.
The default value is 8.
bUnderline
Specifies whether the font is to be underlined. A
nonzero value sets the font to be underlined. A 0 value sets the font not to be
underlined. The font is not underlined by default.
bBold
Specifies whether the font weight is to be bold or not.
A nonzero value sets the font to be bold. A 0 value sets the font weight to be
normal. The font weight is normal by default.
bStrikeOut
Specifies whether the font is to be struck out or
not. A nonzero value sets the font to be struck out. A 0 value sets the font not
to be struck out. The font is not struck out by default.
bItalic
Specifies whether the font style is to be italic or
not. A nonzero value sets the font style to be italic. A 0 value sets the font
style to be normal. The font style is normal by default.
font
A CFont object allowing full control over
the appearance of the font.
RemarksThe first version of this function provides simple control over the main aspects of the button text font. If required the second version can be used to provide full control over the appearance of the button text font.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLTextAlign, CButtonSSL::GetSSLTextAlign
void SetSSLDefaultColors (BOOL bRedraw = TRUE);
bRedraw
Specifies whether the button is to be redrawn. A
nonzero value redraws the button. A 0 value does not redraw the button. The
button is redrawn by default.
Use this function to reset the button colours to their default values. The
default values are the system colours COLOR_BTNFACE and
COLOR_BTNTEXT.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLColor, CButtonSSL::GetSSLColor
BOOL SetSSLColor (BYTE byColorIndex, COLORREF crColor, BOOL bRedraw =
TRUE);
Nonzero if successful; otherwise 0.
byColorIndex
Specifies the colour to be set. This is one of
the colour values defined in the colour
enumeration, except SSL_MAX_COLORS.
crColor
A COLORREF value specifying
the colour to set.
bRedraw
Specifies whether the button is to be redrawn. A
nonzero value redraws the button. A 0 value does not redraw the button. The
button is redrawn by default.
Use this function to set the button face or text colour for a particular button state.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::GetSSLColor, CButtonSSL::SetSSLDefaultColors
BOOL GetSSLColor (BYTE byColorIndex, COLORREF* pcrColor);
Nonzero if byColorIndex is less than "#ColourEnumeration">SSL_MAX_COLORS;
otherwise 0.
byColorIndex
Specifies the colour to be retrieved. This is
one of the colour values defined in the colour
enumeration, except SSL_MAX_COLORS.
pcrColor
A pointer to a COLORREF
value to be receive the requested colour value.
Use this function to retrieve the current button face or text colour for a particular button state.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLColor, CButtonSSL::SetSSLDefaultColors
void SetSSLCheck (int nCheck, BOOL bRedraw = TRUE);
nCheck
Specifies the check state. This parameter
can be either 0 (unchecked) or 1 (checked).
bRedraw
Specifies whether the button is to be redrawn. A
nonzero value redraws the button. A 0 value does not redraw the button. The
button is redrawn by default.
Sets or resets the check state of a check box. This member function has no effect on a push button.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::GetSSLCheck
int GetSSLCheck ();
The return value is either 0 (unchecked) or 1 (checked).
Retrieves the check state of a radio button or check box.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLCheck
BOOL SetSSLButtonMenu (UINT nResourceID);
BOOL SetSSLButtonMenu (LPCTSTR lpszResourceName);
Nonzero if successful; otherwise 0.
nResourceID
Specifies the menu ID of the menu resource to
load.
lpszResourceName
Points to a null-terminated string that
contains the name of the menu resource to load.
Both of these functions use the first submenu in the supplied menu, assuming that it is a popup menu. For example, create a menu resource in the resource editor. Set the first menu item to be pop-up. Add subitems below this to be shown on the menu button.
The Windows message handling for the menu item selections must be handled by
the parent, there is no mechanism for CButtonSSL to handle
them.
Overview | Class Members | Styles | Known Problems
UINT CheckSSLMenuItem (UINT nIDCheckItem, UINT nCheck = MF_CHECKED);
The previous state of the item: MF_CHECKED or MF_UNCHECKED, or 0xFFFFFFFF (MF_DOES_NOT_EXIST) if the menu item did not exist.
nIDCheckItem
Specifies the menu item to be checked, as determined by nCheck.
nCheck
Specifies how to check the menu item and how to determine the item�s position
in the menu. The nCheck parameter can be a combination of MF_CHECKED
or MF_UNCHECKED with MF_BYPOSITION or MF_BYCOMMAND flags.
These flags can be combined by using the bitwise OR operator. They have the
following meanings:
Adds check marks to or removes check marks from menu items in the pop-up menu. The nIDCheckItem parameter specifies the item to be modified.
The nIDCheckItem parameter may identify a pop-up menu item as well as a menu item. No special steps are required to check a pop-up menu item. Top-level menu items cannot be checked. A pop-up menu item must be checked by position since it does not have a menu-item identifier associated with it.
Overview | Class Members | Styles | Known Problems
BOOL CheckSSLMenuRadioItem (UINT nIDFirst, UINT nIDLast, UINT nIDItem,
UINT nFlags);
Return Value
Nonzero if successful; otherwise 0.
Parameters
nIDFirst
Specifies (as an ID or offset, depending on the value of nFlags) the first menu
item in the radio button group.
nIDLast
Specifies (as an ID or offset, depending on the value of nFlags) the last menu
item in the radio button group.
nIDItem
Specifies (as an ID or offset, depending on the value of nFlags) the item in
the group which will be checked with a radio button.
nFlags
Specifies interpretation of nIDFirst, nIDLast, and nIDItem in the following
way:
Adds check marks to or removes check marks from menu items in the pop-up menu. The nIDCheckItem parameter specifies the item to be modified.
The nIDCheckItem parameter may identify a pop-up menu item as well as a menu item. No special steps are required to check a pop-up menu item. Top-level menu items cannot be checked. A pop-up menu item must be checked by position since it does not have a menu-item identifier associated with it.
Overview | Class Members | Styles | Known Problems
UINT EnableSSLMenuItem (UINT nIDEnableItem, UINT nEnable);
Previous state (MF_DISABLED, MF_ENABLED, or MF_GRAYED), �1 if not valid or MF_DOES_NOT_EXIST if menu not initialised.
nIDEnableItem
Specifies the menu item to be enabled, as determined by nEnable. This parameter
can specify pop-up menu items as well as standard menu items.
nEnable
Specifies the action to take. It can be a combination of MF_DISABLED,
MF_ENABLED, or MF_GRAYED, with MF_BYCOMMAND or MF_BYPOSITION.
These values can be combined by using the bitwise OR operator. These values
have the following meanings:
Enables, disables, or dims a menu item.
Using the MF_BYPOSITION value requires an application to use the correct CMenu. If the CMenu of the menu bar is used, a top-level menu item (an item in the menu bar) is affected. To set the state of an item in a pop-up or nested pop-up menu by position, an application must specify the CMenu of the pop-up menu.
When an application specifies the MF_BYCOMMAND flag, Windows checks all pop-up menu items that are subordinate to the CMenu; therefore, unless duplicate menu items are present, using the CMenu of the menu bar is sufficient.
Overview | Class Members | Styles | Known Problems
UINT GetSSLMenuItemCount () const;
The number of items in the menu if the function is successful; otherwise �1. MF_DOES_NOT_EXIST will be returned if the menu is not initialised.
Determines the number of items in a pop-up or top-level menu.
Overview | Class Members | Styles | Known Problems
UINT GetSSLMenuItemID (int nPos) const;
The item ID for the specified item in a pop-up menu if the function is successful. If the specified item is a pop-up menu (as opposed to an item within the pop-up menu), the return value is �1. If nPos corresponds to a SEPARATOR menu item, the return value is 0. If the menu is not yet initialised the value MF_DOES_NOT_EXIST will be returned.
nPos
Specifies the position (zero-based) of the menu item whose ID is being retrieved.
Obtains the menu-item identifier for a menu item located at the position defined
by nPos.
Overview | Class Members | Styles | Known Problems
UINT GetSSLMenuState (UINT nID, UINT nFlags);
The value MF_DOES_NOT_EXIST if the specified item does not exist or
the menu is uninitialised. If nId identifies a pop-up menu, the high-order byte
contains the number of items in the pop-up menu and the low-order byte contains
the menu flags associated with the pop-up menu. Otherwise the return value is
a mask (Boolean OR) of the values from the following list (this mask describes
the status of the menu item that nId identifies):
nID
Specifies the menu item ID, as determined by nFlags.
nID
Specifies the nature of nID. It can be one of the following values:
Returns the status of the specified menu item or the number of items in a pop-up menu.
Overview | Class Members | Styles | Known Problems
int GetSSLMenuString (UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags);
int GetSSLMenuString (UINT nIDItem, CString& rString, UINT nFlags);
Specifies the actual number of bytes copied to the buffer, not including the null terminator.
nIDItem
Specifies the integer identifier of the menu item or the offset of the menu
item in the menu, depending on the value of nFlags.
lpString
Points to the buffer that is to receive the label.
rString
A reference to a CString object that is to receive the copied menu string.
nMaxCount
Specifies the maximum length (in bytes) of the label to be copied. If the label
is longer than the maximum specified in nMaxCount, the extra characters are
truncated.
nFlags
Specifies the interpretation of the nIDItem parameter. It can be one of the
following values:
Copies the label of the specified menu item to the specified buffer.
The nMaxCount parameter should be one larger than the number of characters
in the label to accommodate the null character that terminates a string.
Overview | Class Members | Styles | Known Problems
BOOL GetSSLMenuItemInfo (UINT nIDItem, LPMENUITEMINFO lpMenuItemInfo, BOOL ByPos = FALSE);
If the function succeeds, the return value is nonzero. If the function fails,
the return value is zero. To get extended error information, use the Win32 function
GetLastError, as described in the Platform SDK.
nIDItem
Identifier or position of the menu item to get information about. The meaning
of this parameter depends on the value of ByPos.
lpMenuItemInfo
A pointer to a MENUITEMINFO, as described in the Platform SDK, that contains
information about the menu.
rString
A reference to a CString object that is to receive the copied menu
string.
ByPos
Value specifying the meaning of nIDItem. By default, ByPos is FALSE, which indicates
that nIDItem is a menu item identifier. If ByPos is not set to FALSE, it indicates
a menu item position.
This member function implements the behavior of the of the Win32 function GetMenuItemInfo,
as described in the Platform SDK.
Note that in the MFC implementation of GetMenuItemInfo, you do not use a handle
to a menu.
Overview | Class Members | Styles | Known Problems
BOOL ModifySSLMenu (UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL);
BOOL ModifySSLMenu (UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp);
Nonzero if the function is successful; otherwise 0.
nPosition
Specifies the menu item to be changed. The nFlags parameter can be used to
interpret nPosition in the following ways:
nFlags
Specifies how nPosition is interpreted and gives information about
the changes to be made to the menu item.
nIDNewItem
Specifies either the command ID of the modified menu item or, if nFlags
is set to MF_POPUP, the menu handle (HMENU) of a pop-up
menu. The nIDNewItem parameter is ignored (not needed) if nFlags
is set to MF_SEPARATOR.
lpszNewItem
Specifies the content of the new menu item. The nFlags parameter can be used
to interpret lpszNewItem in the following ways:
CString.
lpszNewItem parameter is ignored (not needed). pBmp
Points to a CBitmap object that will be used as the menu item.
Changes an existing menu item at the position specified by nPosition. The application
specifies the new state of the menu item by setting values in nFlags. If this
function replaces a pop-up menu associated with the menu item, it destroys the
old pop-up menu and frees the memory used by the pop-up menu.
When nIDNewItem specifies a pop-up menu, it becomes part of the menu in which
it is inserted. If that menu is destroyed, the inserted menu will also be destroyed.
An inserted menu should be detached from a CMenu object to avoid conflict.
Overview | Class Members | Styles | Known Problems
BOOL RemoveSSLMenu (UINT nPosition, UINT nFlags);
Nonzero if the function is successful; otherwise 0.
nPosition
Specifies the menu item to be changed. The nFlags parameter can
be used to interpret nPosition in the following ways:
nFlags
Specifies how nPosition is interpreted.
Deletes a menu item with an associated pop-up menu from the menu. It does not destroy the handle for a pop-up menu, so the menu can be reused.
Overview | Class Members | Styles | Known Problems
BOOL SetSSLMenuItemBitmaps (UINT nPosition, UINT nFlags, const CBitmap* pBmpUnchecked,
const CBitmap* pBmpChecked);
Nonzero if the function is successful; otherwise 0.
nPosition
Specifies the menu item to be changed. The nFlags parameter can
be used to interpret nPosition in the following ways:
nFlags
Specifies how nPosition is interpreted.
pBmpUnchecked
Specifies the bitmap to use for menu items that are not checked.
pBmpChecked
Specifies the bitmap to use for menu items that are checked.
Associates the specified bitmaps with a menu item. Whether the menu item is checked or unchecked, Windows displays the appropriate bitmap next to the menu item.
If either pBmpUnchecked or pBmpChecked is NULL, then Windows displays nothing
next to the menu item for the corresponding attribute. If both parameters are
NULL, Windows uses the default check mark when the item is checked and removes
the check mark when the item is unchecked.
When the menu is destroyed, these bitmaps are not destroyed; the application must destroy them.
The Windows GetMenuCheckMarkDimensions function retrieves the dimensions of
the default check mark used for menu items. The application uses these values
to determine the appropriate size for the bitmaps supplied with this function.
Get the size, create your bitmaps, then set them.
Overview | Class Members | Styles | Known Problems
BOOL SetSSLButtonCursor (UINT nResourceID);
Nonzero if successful; otherwise 0.
nResourceID
Specifies the cursor ID of the cursor resource to
load.
The cursor specified will be shown when the mouse is over any part of the button, including the drop-down arrow. The cursor will revert to it's previous state when the drop-arrow is clicked for navigation of the menu.
Overview | Class Members | Styles | Known Problems
void SetSSLButtonToolTip (LPCTSTR lpszTipText, BOOL bActivate =
TRUE);
void SetSSLButtonToolTip (UINT nResourceID, BOOL bActivate =
TRUE);
lpszTipText
Points to a null-terminated string containing the
text to be displayed on the tooltip.
nResourceID
Specifies the resource ID of a string in the
string table to be dispalyed on the tooltip.
bActivate
Specifies whether the tool tip is to be activated
or deactivated. The tool tip is activated by default.
When the tool tip is active (bActivate = TRUE), the
tool tip information appears when the cursor hovered over the button; when it is
inactive (bActivate = FALSE), the tool tip information
does not appear, even when the cursor is hovered over the button.
Overview | Class Members | Styles | Known Problems
void SetSSLButtonURL (LPCTSTR lpszURL);
lpszURL
Points to a null-terminated string containing the URL
to be opened when the button is clicked.
Call this function to define a URL to be opened when the button is clicked. If a cursor has not already been defined for the button using SetSSLButtonCursor then this function attempts to load the hand cursor from WinHlp32.exe. This approach was detailed in Paul DiLascia's Jan 1998 MSJ article. If the runtime environment does not have WinHlp32.exe in the Windows directory then one can be defined and set using SetSSLButtonCursor.
Overview | Class Members | Styles | Known Problems
See Also CButtonSSL::SetSSLButtonCursor
SSL_BS_FLAT Creates
a button with a flat appearance. When the mouse is over the button it will be
raised, but not to the extent of a normal 3D control. The default style.
SSL_BS_MENU_BTN
Creates a button with a drop-arrow at the right side of the button. A menu may
be assigned to the object to be displayed when the drop part is clicked.
SSL_BS_AUTOSIZE
Creates a button that automatically sizes to fit it's contents. This style
will not prevent the button image and the button text from overlapping.
SSL_TEXT_TOP Aligns
the text vertically to the top of the button.
SSL_TEXT_LEFT
Aligns the text horizontally to the left of the button.
SSL_TEXT_CENTER
Aligns the text horizontally to the centre of the button. The default style.
SSL_TEXT_RIGHT
Aligns the text horizontally to the right of the button.
SSL_TEXT_VCENTER
Aligns the text vertically to the centre of the button. The default style.
SSL_TEXT_BOTTOM
Aligns the text vertically to the bottom of the button. Only one horizontal and one vertical style should be set for the text alignment.
SSL_IMAGE_TOP
Aligns the button image vertically to the top of the button. The default
style.
SSL_IMAGE_LEFT
Aligns the button image horizontally to the left of the button. The default
style.
SSL_IMAGE_CENTER
Aligns the button image horizontally to the centre of the button.
SSL_IMAGE_RIGHT
Aligns the button image horizontally to the right of the button.
SSL_IMAGE_VCENTER
Aligns the button image vertically to the centre of the button.
SSL_IMAGE_BOTTOM
Aligns the button image vertically to the bottom of the button. Only one horizontal and one vertical style should be set for the button image alignment.
SSL_UP_BK_COLOR The
button colour to use when the button is in the up state.
SSL_UP_TEXT_COLOR
The text colour to use when the button is in the up state.
SSL_OVER_BK_COLOR
The button colour to use when the button is in the over state.
SSL_OVER_TEXT_COLOR
The text colour to use when the button is in the overstate.
SSL_DOWN_BK_COLOR
The button colour to use when the button is in the down state.
SSL_DOWN_TEXT_COLOR
The text colour to use when the button is in the down state.
SSL_MAX_COLORS
Defines the maximum number of colours that can be defined. SSL_MASK Defined as RGB (<span class=cpp-literal
>255, <span class=cpp-literal
>0, <span class=cpp-literal
>255) As far as I know there aren't any. If you find any let me know.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 4 Dec 2001 Editor: Chris Maunder |
Copyright 2001 by Derek Lakin Everything else Copyright © CodeProject, 1999-2009 Web22 | Advertise on the Code Project |