王咣生 发表于 2004-2-4 21:32:00

下面代码改变AutoCAD图标怎么不行?

下面代码改变AutoCAD图标怎么不行?


#include "windows.h"<BR>#include "stdio.h"


void test();


void test()<BR>{<BR>        HWND hWnd = adsw_acadMainWnd();<BR>        HICON hIcon=::LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON1)); <BR>        SendMessage(hWnd,WM_SETICON,ICON_SMALL,(LPARAM)hIcon);<BR>}

Student 发表于 2004-2-5 09:55:00

<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt">可先获得<FONT face="Times New Roman">AutoCAD</FONT>窗口指针<FONT face="Times New Roman">acedGetAcadFrame()</FONT>,再调用<FONT face="Times New Roman">SetIcon ()</FONT>函数,见下面的<FONT face="Times New Roman">swicon()</FONT>函数:


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">        <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">#include "StdAfx.h"</FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">#include "StdArx.h"</FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">#include "resource.h"<SPAN style="mso-tab-count: 1">                       //</FONT></SPAN>此处要添加本<FONT face="Times New Roman">h</FONT>文件,才能使用<FONT face="Times New Roman">IDI_ICON1</FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">        <o:p></o:p></FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">// This is command 'SWICON'</FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">// </FONT>更改<FONT face="Times New Roman">AutoCAD</FONT>窗口的图标


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">int swicon()</FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">{</FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               // TODO: Implement the command</FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               resbuf* pArg = acedGetArgs();</FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">        <o:p></o:p></FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               CMDIFrameWnd *pFrame; </FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               pFrame=acedGetAcadFrame(); </FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">        <o:p></o:p></FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               HICON m_icon;</FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               ASSERT(hIcon);</FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               m_icon=AfxGetApp()-&gt;LoadIcon(IDI_ICON1);</FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               pFrame-&gt;SetIcon(m_icon,FALSE);</FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               pFrame-&gt;UpdateWindow (); </FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">        <o:p></o:p></FONT>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"><SPAN style="mso-tab-count: 1">                                               return RTNORM;</FONT></SPAN>


<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">}</FONT>

victory 发表于 2004-2-6 16:57:00

HICON hIcon=::LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON1)); <BR>CWnd *pWnd=CWnd::FromHandle(adsw_acadMainWnd());<BR>pWnd-&gt;SetIcon(hIcon,FALSE);<BR>pWnd-&gt;EnableWindow(FALSE);//可以试一试,别乱来-:)<BR>

王咣生 发表于 2004-2-6 21:37:00

工程应该建立什么类型的?

工程应该建立什么类型的?


<FONT face="Times New Roman">acedGetAcadFrame()要MFC支持,CWnd类也要吧?</FONT>


<EM><FONT face="Times New Roman">最好给我一个源程序,谢谢!</FONT></EM>

中国虫 发表于 2004-2-7 10:35:00

王咣生发表于2004-2-4 21:32:00static/image/common/back.gif下面代码改变AutoCAD图标怎么不行?



#include \"windows.h\"#include \"stdio.h\"


void test();


void test(){        HWND hWnd = adsw_acadMainWnd();        HICON hIcon=::LoadIcon(NULL,MAKEIN


<BR>并不非要用acedGetAcadFrame


关键是:


=::LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON1));


第一个参数不对,应该是你的资源所在的动态库或ARX(也是动态库)的句柄。


如果在同一个ARX中用_hdllInstance,见Wizard生成的主文件,如果是其它的库句柄,参见MSDN:LoadLibarary
页: [1]
查看完整版本: 下面代码改变AutoCAD图标怎么不行?