【问题标题】:How to change program Icon programmatically?如何以编程方式更改程序图标?
【发布时间】:2014-09-13 22:48:41
【问题描述】:

如何在 Visual C++ 中以编程方式更改程序图标?我的 IDE 是 Visual Studio 2013。

我想将图标更改为嵌入式资源图标。你知道该怎么做吗?

【问题讨论】:

  • 我对VS2013一无所知,但程序图标不是静态资源吗? IE。你不能。

标签: c++ visual-studio icons clr


【解决方案1】:
using System.Runtime.InteropServices;

..

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam);

struct IconHandler
{
    internal const uint WmSeticon = 0x80u;
    internal const int IconSmall = 0x0;
    internal const int IconBig = 0x1;
}

 private void Form1_Load(object sender, EventArgs e)
 {
    InitializeComponent();

    //Properties.Resources.Icon.Handle is just an .*ico file in your resources. Icons can have different sizes.
    SendMessage(Handle, IconHandler.WmSeticon, IconHandler.IconSmall, Properties.Resources.Icon.Handle);
    SendMessage(Handle, IconHandler.WmSeticon, IconHandler.IconBig, Properties.Resources.Icon.Handle);
}

【讨论】:

    【解决方案2】:

    如果您想更改 Microsoft Visual Studio C++ 的程序图标,您可以:

    Right Click Visual Studio 2013
    
    1.Click "Properties"
    
    2.Click the sub-tab "Shortcut"
    
    3.Click "Change Icon"
    
    4.Browse or select from the list below
    

    完成!

    【讨论】:

    • 不,我想在加载表单时更改程序的图标
    猜你喜欢
    • 2012-08-17
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-29
    • 1970-01-01
    相关资源
    最近更新 更多