📄 05o025.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="../../vckbase.css">
</head>
<body>
<div align="justify">
<table border="0" width="100%" class="font" height="57">
<tr>
<td width="27%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
<font color="#800080">VC知识库(五)</font>
</td>
<td width="73%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
<font color="#800080">www.vckbase.com</font>
</td>
</tr>
<tr>
<td width="100%" height="4" class="header" valign="top" align="center" colspan="2">
<hr>
</td>
</tr>
<tr>
<td width="100%" height="17" class="header" valign="top" align="center" colspan="2">
如何在VC++程序中获得其他程序的图标?
</td>
</tr>
<tr>
<td width="100%" height="17" class="info" align="center" colspan="2">
</td>
</tr>
<tr>
<td width="100%" height="22" class="font" colspan="2">
<hr>
</td>
</tr>
<tr>
<td width="100%" height="5" class="font" colspan="2">
可采取两种方法: <BR>(1)
SDK函数 SHGetFileInfo 或使用 ExtractIcon获得图标资源的 handle, <BR>(2) SDK函数
SHGetFileInfo获得有关文件的 很多信息,如大小图标,属性, <BR>类型等. <BR>Example(1):
在程序窗口左上角显示 NotePad图标. <BR><BR>void CSampleView: OnDraw(CDC * pDC)
<BR>{ <BR>if( :: SHGetFileInfo(_T("c:\\pwin95\\notepad.exe"),0,
<BR>&stFileInfo,sizeof(stFileInfo),SHGFI_ICON)) <BR>{ <BR>pDC
->DrawIcon(10,10,stFileInfo.hIcon); <BR>} <BR>}
<BR>Example(2):同样功能,Use ExtractIcon Function <BR><BR>void
CSampleView:: OnDraw(CDC *pDC) <BR>{ <BR>HICON hIcon=::
ExtractIcon(AfxGetInstanceHandle(),_T <BR>("NotePad.exe"),0);
<BR><BR>if (hIcon &&hIcon!=(HICON)-1)
<BR>pDC->DrawIcon(10,10,hIcon); <BR>} <BR>说明:
获得notepad.exe的路径正规上来说用GetWindowsDirectory 函数得到, <BR>如果是调用
win95下的画笔,应该用访问注册表的方法获得其路径,要作成一个 <BR>比较考究的程序,考虑应该全面点.
</td>
</tr>
<tr>
<td width="100%" height="12" class="font" colspan="2">
</td>
</tr>
<tr>
<td width="100%" height="6" class="font" colspan="2">
</td>
</tr>
<tr>
<td width="100%" height="8" class="font" colspan="2">
</td>
</tr>
<tr>
<td width="100%" height="17" class="font" colspan="2"></td>
</tr>
</table>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -