SetIcon与SetClassWindow的区别 为什么在调用SetClassWindow(在CFrame中的一个命令响应中)来改变图标,运行后却显示的图标是个白色的框.而是用SetIcon就可以成功加载? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不好意思,一时手误,是SetClassLong。 SetClassLong函数可以改变程序的图标。在CMainFrame类的OnCreate函数里面添加SetClassLong(m_hWnd,GCL_HICON,(LONG)LoadIcon(NULL,IDI_ERROR));(IDI_ERROR可以改成你需要的图标去,自己设置)或者添加自定义的图标都可以的。或者在CMainFrame的PreCreateWindow函数中添加cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,0,0,LoadIcon(NULL,IDI_WARNING));一样的可以更改图标 我想问的是 为什么在一个命令响应中用SetClassLong改变的图标竟然变成无效的图标,而CWnd::SetIcon函数却可以?这两个函数的实现到底有什么样的区别呢? MSDN上有一个说法,你可以参考下:Use the SetClassLong function with care. For example, it is possible to change the background color for a class by using SetClassLong, but this change does not immediately repaint all windows belonging to the class. 我好想记得有个教程里有说到过用SetClassLong改图标的,记得好想是很成功...图标是封装在窗口类中的,感觉SetIcon内部应该也是用SetClassLong实现的吧...子类化都是使用的SetClassLong与SetWindowLong实现的,没见过用其他函数实现的,也许我孤陋寡闻了 调用完SetClassLong之后用UpdateWindow更新一下应该就行了。 我不知道你的代码是如何写的,刚才我试了一下,能成功啊!代码:void CMainFrame::On32771(){::SetClassLong(GetSafeHwnd(),GCL_HICON,(LONG)LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON1)));} 请问如何做一个视频播放器? 父类已经有ON_WM_LBUTTONDBLCLK()了,那其子类也要拦截WM_LBUTTONDBLCLK,咋办? 文件对话框类 数据库重启之后,ADO是否可以自动检测到并重连? Debug Assertion Failed!请指教 ??如何在对话框中显示位图文件 资源共享 CListCtrl如何禁止用鼠标拖动改变列的宽度? 有用win95的朋友吗?帮忙测试一个软件。 操作注册表时为什么有时能读出来有时又读不出来? AcceptEx客户端连接上了,为什么GetQueuedCompletionStatus没有返回呢? 参数传递的问题 于操作副
SetClassLong(m_hWnd,GCL_HICON,(LONG)LoadIcon(NULL,IDI_ERROR));
(IDI_ERROR可以改成你需要的图标去,自己设置)
或者添加自定义的图标都可以的。或者在CMainFrame的PreCreateWindow函数中添加
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,0,0,LoadIcon(NULL,IDI_WARNING));
一样的可以更改图标
Use the SetClassLong function with care. For example, it is possible to change the background color for a class by using SetClassLong, but this change does not immediately repaint all windows belonging to the class.
代码:void CMainFrame::On32771()
{
::SetClassLong(GetSafeHwnd(),GCL_HICON,(LONG)LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON1)));}