Following code adds a shield icon to a button:
SendMessage(btn1.Handle, BCM_SETSHIELD, 0, 1);
I've tried the same with checkboxes, radio button groups etc. Nothing works except a button.
Is there a way to add the shield icon to any other control?
Is there a way to add the shield icon to any other control?
If the control in question supports the display of a HICON
(e. g. a static control), you can load the standard shield icon by calling LoadIconWithScaleDown
with the IDI_SHIELD
constant and assign that to the control.
int cx = GetSystemMetrics( SM_CXSMICON );
int cy = GetSystemMetrics( SM_CYSMICON );
HICON hShieldIcon = NULL;
HRESULT hr = LoadIconWithScaleDown( NULL, MAKEINTRESOURCE( IDI_SHIELD ), cx, cy,
&hShieldIcon );
if( SUCCEEDED( hr ) )
{
// Consult the reference on how to assign the HICON to the control.
}
If the control in question does not support assigning a HICON
, you could use custom-draw, which is supported by many controls, to draw the icon yourself.