Earlier in the Windows 7 compatibility webcast I made a shield icon of the demo, this icon is to say click on the button to perform a request to enhance the rights of the operation, to write its main implementation process and the webcast in the demo released.
In fact, the main implementation is to invoke the method in User32.dll to paste the existing button control a small icon, you can use the following methods to implement:
[DllImport ("user32.dll")]
private static extern IntPtr SendMessage (handleref hWnd, uint MSG, IntPtr WParam, IntPtr lParam);
/**////////////////////////////////////////////////////////////////////////
///<summary& Gt
///enables the elevated shield icon on the given button control
///</summary>
<param name= "Thisbutton"
///button control to enable the elevated icon on.
</param>
///////////////////////////////////////////////////////////////////////
P rivate void Enableelevateicon_bcm_setshield (Button Thisbutton)
{
//Input validation, validate That's not NULL
if (Thisbutton = null)
{
return;
ThisControl
//Define Bcm_setshield locally, declared originally in Commctrl.h
UINT Bcm_setshield = 0x0000160c;
//Set button style to the system style
Thisbutton.flatstyle = FlatStyle.System;
//Send the Bcm_setshield message to the button control
SendMessage (new HandleRef THISBU Tton, Thisbutton.handle), Bcm_setshield, new IntPtr (0), new IntPtr (1));
}
You can then implement the effect by passing the button directly into the method:
EnableElevateIcon_BCM_SETSHIELD(button2);
The implementation effect is as follows: