如何使用c#.net windows应用程序从数据库中更改Windows窗体图标? [英] How to change windows form icon from database using c# .net windows application?

查看:88
本文介绍了如何使用c#.net windows应用程序从数据库中更改Windows窗体图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



如何使用c#.net windows应用程序从数据库更改Windows窗体图标?



我们如何使用c#.net windows应用程序动态或运行时更改图标?



请帮助我。



Ankit Agarwal

软件工程师

Hello,

How to change windows form icon from database using c# .net windows application?

How can we change icon dynamically or runtime using c# .net windows application?

Please help me.

Ankit Agarwal
Software Engineer

推荐答案

参见 Bitmap.GetHicon Method [ ^ ]。



1。将图标图像作为.jpg图像保存在数据库中。

2.将图标图像检索到位图变量,比如位图。

See Bitmap.GetHicon Method[^].

1. Save your icon image in the DB as a .jpg image.
2. Retrieve your icon image into a Bitmap variable, say bitmap.
Bitmap  bitmap;



3.将位图转换为图标句柄。


3. Convert the Bitmap into an Icon handle.

IntPtr  icon_handle = bitmap.GetHicon ( );



4.从Icon手柄创建新图标。


4. Create new Icon from the Icon handle.

Icon    icon = Icon.FromHandle ( icon_handle );



5.将表格图标设置为新图标。


5. Set Form Icon to the new icon.

this.Icon = icon;



6.销毁图标,因为表单会创建自己的图标副本。


6. Destroy the icon, since the form creates its own copy of the icon.

[ System.Runtime.InteropServices.DllImport ( "user32.dll",
                                             CharSet = CharSet.Auto ) ]
extern static bool DestroyIcon(IntPtr handle);

DestroyIcon ( icon.Handle );


这篇关于如何使用c#.net windows应用程序从数据库中更改Windows窗体图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆