Sollyu

  • 捐赠
  • 关于
  1. 首页
  2. 原创文章
  3. 正文

C# 给按钮添加小盾牌图标

2014年12月16日 6736点热度 2人点赞 0条评论

代码

        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     Enables the elevated shield icon on the given button control
        /// </summary>
        /// <param name="ThisButton">
        ///     Button control to enable the elevated shield icon on.
        /// </param>
        ///////////////////////////////////////////////////////////////////////
        private void EnableElevateIcon_BCM_SETSHIELD(Button ThisButton)
        {
            // Input validation, validate that ThisControl is not null
            if (ThisButton == null)
            {
                return;
            }

            // 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 System.Runtime.InteropServices.HandleRef(ThisButton, ThisButton.Handle), BCM_SETSHIELD, new IntPtr(0), new IntPtr(1));
        }

        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern IntPtr SendMessage(System.Runtime.InteropServices.HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

截图

C# 给按钮添加小盾牌图标

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: C++ 小盾牌 按钮
最后更新:2014年12月16日

sollyu

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

COPYRIGHT © 2021 sollyu.com. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS

苏ICP备15007531号