SetIcon bug [英] SetIcon bug

查看:61
本文介绍了SetIcon bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现设置图标可能有错误。

我不确定,但我不认为这应该是这样的。


程序使用大而不是小图标。

请告诉我它是已知错误还是我错过了什么。


如果这是我犯的错误记录如何实现它。所以我会把它发送到

可以验证它的人。


谢谢,Rajko。

解决方案

>我发现设置图标可能存在错误。

我不确定,但我不认为这应该像这个。

程序使用大而不是小图标。
请告诉我它是已知错误还是我错过了什么。

如果这是我犯的错误记录如何实现它。所以我会将它发送给可以验证它的人。




为什么不在这里发布一个最小的代码片段来说明如何

重现这个问题?


Dave

-

MVP VC ++ FAQ: http://www.mvps.org/vcfaq


确定。这个很简单。

由于我测试了行为,我创建了以下测试结果:

我希望你能读懂html(红色可能是错误的)。 />
BTW我没有所有的Windows更新,因为我遇到了Windows(包括震荡波)的问题。

SetIcon(); - >我避免了这个功能,因为:

_AFXWIN_INLINE HICON CWnd :: SetIcon(HICON hIcon,BOOL bBigIcon)

{ASSERT(:: IsWindow(m_hWnd)); return(HICON):: SendMessage(m_hWnd,WM_SETICON,bBigIcon,(LPARAM)hIcon); }




我使用过:" SendMessage(WM_SETICON,...);" = SM


资源:3个带有资源ID的独立文件:IDI_ICONS(用于小 - 列表和详细信息),IDI_ICONL(用于大图标),IDI_ICONX(用于xlarge - tile和thumbinals)


S =小,L =大,X = xlarge


应用程序图标Windows资源管理器(列表视图ctrl)

函数调用左上角(=小)Alt + Tab(=大)小(16x16)大(32x32)XLarge(48x48)

SM + ICON_SMALL + IDI_ICONS

S NULL SSS

SM + ICON_SMALL + IDI_ICONL L NULL SSS

SM + ICON_SMALL + IDI_ICONX X NULL SSS

SM + ICON_BIG + IDI_ICONS

SSSSS

SM + ICON_BIG + IDI_ICONL LLSSS

SM + ICON_BIG + IDI_ICONX XXSSS

SM + ICON_SMALL + IDI_ICONS

SM + ICON_SMALL + IDI_ICONL

SM + ICON_SMALL + IDI_ICONX

XXSSS

SM + ICON_BIG + IDI_ICONS

SM + ICON_BIG + IDI_ICONL

SM + ICON_BIG + IDI_ICONX

XXSSS


资源:1个ico文件,图标大小为32x32,16x16,48x48,Id = IDI_ICONALL


应用程序图标Windows资源管理器(列表视图)

函数调用左上角(=小)Alt + Tab(=大)小(16x16)大(32x32)XLarge(48x48)

SM + ICON_SMALL + IDI_ICONALL L NULL SLX

SM + ICON_BIG + IDI_ICONALL SLSLX

SM + ICON_SMALL + IDI_ICONALL

SM + ICON_BIG + IDI_ICONALL

LLSLX

SM + ICON_BIG + IDI_ICONALL

SM + ICON_SMALL + IDI_ICONALL

LLSLX


这是它的样子喜欢在这里:


BOOL CTestDlgIconDlg :: OnInitDialog(){

CDialog :: OnInitDialog();

... 。

SendMessage(WM_SETICON,ICON_BIG,(LPARAM)AfxGetApp() - > LoadIcon(IDI_ICONALL));

SendMessage(WM_SETICON,ICON_SMALL,(LPARAM)AfxGetApp() - > LoadIcon(IDI_ICONALL));

....

--------------------- ---------------------------------------- -------------------


MFC库参考


CWnd :: SetIcon

调用此成员函数将句柄设置为特定图标,由hIcon标识。


HICON SetIcon(

HICON hIcon,

BOOL bBigIcon

);参数

hIcon

前一个图标的句柄。

bBigIcon

指定32像素乘32像素图标,如果为TRUE;如果为FALSE,则指定16像素乘16像素的图标。

返回值

图标句柄。


备注

当窗口类是注册后,它会选择一个图标。


例子

参见CWnd :: GetSystemMenu的例子。


参见

CWnd概述|班级成员|层次结构图| GetIcon


------------------------------------- -------------------------------------------

发送有关此主题的反馈给微软


?微软公司。保留所有权利。

-------------------------------------- ------------------------------------------


---------------------------------------------- ----------------------------------


---- -------------------------------------------------- --------------------------


WM_SETICON消息


------------------------------------------------ --------------------------------


应用程序发送WM_SETICON消息将新的大图标或小图标与窗口相关联。系统在ALT + TAB对话框中显示大图标,在窗口标题中显示小图标。


语法

要发送此消息,请按如下方式调用SendMessage函数。

lResult = SendMessage(//在lResult(HWND)中返回LRESULT hWndControl,//目标控件句柄(UINT)WM_SETICON,//消息ID(WPARAM)wParam,// =(WPARAM)( )wParam;(LPARAM)lParam // =(LPARAM)()lParam;);参数


wParam

指定要设置的图标类型。此参数可以是以下值之一。

ICON_BIG

设置窗口的大图标。

ICON_SMALL

设置窗口的小图标。

lParam

处理新的大图标或小图标。如果此参数为NULL,则删除wParam指示的图标。

返回值


返回值是前一个大图标或小图标的句柄,具体取决于wParam的值。如果窗口之前没有wParam指示的类型的图标,则为NULL。

备注


DefWindowProc函数返回前一个大小的句柄与窗口关联的图标,具体取决于wParam的值。


消息信息


在Winuser.h中声明的头文件,包括Windows.h

最低操作系统Windows 95,Windows NT 4.0



Windows概述,DefWindowProc,WM_GETICON


--------------------------------------- -----------------------------------------


? 2003年微软公司。版权所有。



" David Lowndes" <哒**** @ example.invalid>在消息新闻中写道:h7 ******************************** @ 4ax.com ...

我发现设置图标可能有错误。
我不确定,但我不认为这应该是这样的。
请告诉我它是已知错误还是我错过了什么。

如果是一个错误,我制作文档如何实现它。所以我会将它发送给可以验证它的人。



为什么不在这里发布一个最小的代码片段来说明如何
重现这个问题?

戴夫
-
MVP VC ++ FAQ: http://www.mvps.org/vcfaq



>由于我测试了行为,我创建了以下结果我的测试:

我希望你能读懂html(红色可能是错误的)。


这里没有HTML谢谢。

资源:3个带资源ID的独立文件:IDI_ICONS(小 - 列表和详细信息),IDI_ICONL(适用于大图标) ),IDI_ICONX(用于xlarge - tile和thumbinals)
S = small,L = large,X = xlarge
App图标Windows资源管理器(列表视图ctrl)
函数调用左上角(=小)Alt + Tab(=大)小(16x16)大(32x32)XLarge(48x48)
SM + ICON_SMALL + IDI_ICONS
剪辑


我''我害怕我没想到你想要告诉我们这个地段我们是什么。

SendMessage(WM_SETICON,ICON_BIG,(LPARAM)AfxGetApp () - > LoadIcon(IDI_ICONALL));
SendMessage(WM_SETICON,ICON_SMALL,(LPARAM)AfxGetApp() - > LoadIcon(IDI_ICONALL));




使用LoadImage而不是LoadIcon。 LoadIcon只加载大小的图标

SM_CXICON,SM_CYICON。


Dave

-

MVP VC ++ FAQ: http://www.mvps.org/vcfaq


I found possible bug with set icon.
I''m not sure but I don''t think this is supposed to work like this.

Program uses large instead of small icons.
Please tell me is it known bug or maybe I missed something.

If it is a bug I made document how to make it happen. So I''ll send it to
someone who can verify it.

Thanks, Rajko.

解决方案

>I found possible bug with set icon.

I''m not sure but I don''t think this is supposed to work like this.

Program uses large instead of small icons.
Please tell me is it known bug or maybe I missed something.

If it is a bug I made document how to make it happen. So I''ll send it to
someone who can verify it.



Why don''t you post a minimal code snippet here that illustrates how to
reproduce this issue?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq


OK. This one is quite simple.
Since I tested behaviour, I created following results of my test:
I hope you can read html (red is possible error).
BTW I don''t have all Windows updates because I had problem with Windows(including sasser).
SetIcon(); --> I avoided this function because :
_AFXWIN_INLINE HICON CWnd::SetIcon(HICON hIcon, BOOL bBigIcon)
{ ASSERT(::IsWindow(m_hWnd)); return (HICON)::SendMessage(m_hWnd, WM_SETICON, bBigIcon, (LPARAM)hIcon); }
)

I used: "SendMessage(WM_SETICON, ...);" = SM

Resources: 3 separate files with resource ids: IDI_ICONS(for small - list and details), IDI_ICONL(for large - icons), IDI_ICONX(for xlarge - tiles and thumbinals)

S=small, L=large, X=xlarge

App icon Windows Explorer (list view ctrl)
Function calls top-left(=small) Alt+Tab(=large) Small(16x16) Large(32x32) XLarge(48x48)
SM + ICON_SMALL + IDI_ICONS
S NULL S S S
SM + ICON_SMALL + IDI_ICONL L NULL S S S
SM + ICON_SMALL + IDI_ICONX X NULL S S S
SM + ICON_BIG + IDI_ICONS
S S S S S
SM + ICON_BIG + IDI_ICONL L L S S S
SM + ICON_BIG + IDI_ICONX X X S S S
SM + ICON_SMALL + IDI_ICONS
SM + ICON_SMALL + IDI_ICONL
SM + ICON_SMALL + IDI_ICONX

X X S S S
SM + ICON_BIG + IDI_ICONS
SM + ICON_BIG + IDI_ICONL
SM + ICON_BIG + IDI_ICONX
X X S S S

Resources: 1 ico file with icon sizes 32x32, 16x16, 48x48, Id = IDI_ICONALL

App icon Windows Explorer (list view)
Function calls top-left(=small) Alt+Tab(=large) Small(16x16) Large(32x32) XLarge(48x48)
SM + ICON_SMALL + IDI_ICONALL L NULL S L X
SM + ICON_BIG + IDI_ICONALL S L S L X
SM + ICON_SMALL + IDI_ICONALL
SM + ICON_BIG + IDI_ICONALL
L L S L X
SM + ICON_BIG + IDI_ICONALL
SM + ICON_SMALL + IDI_ICONALL
L L S L X

This is how it looked like over here:

BOOL CTestDlgIconDlg::OnInitDialog() {
CDialog::OnInitDialog();
....
SendMessage(WM_SETICON, ICON_BIG, (LPARAM)AfxGetApp()->LoadIcon(IDI_ICONALL));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM)AfxGetApp()->LoadIcon(IDI_ICONALL));
....
--------------------------------------------------------------------------------

MFC Library Reference

CWnd::SetIcon
Call this member function to set the handle to a specific icon, as identified by hIcon.

HICON SetIcon(
HICON hIcon,
BOOL bBigIcon
);Parameters
hIcon
A handle to a previous icon.
bBigIcon
Specifies a 32 pixel by 32 pixel icon if TRUE; specifies a 16 pixel by 16 pixel icon if FALSE.
Return Value
A handle to an icon.

Remarks
When the window class is registered, it selects an icon.

Example
See the example for CWnd::GetSystemMenu.

See Also
CWnd Overview | Class Members | Hierarchy Chart | GetIcon

--------------------------------------------------------------------------------

Send feedback on this topic to Microsoft

? Microsoft Corporation. All rights reserved.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

WM_SETICON Message

--------------------------------------------------------------------------------

An application sends the WM_SETICON message to associate a new large or small icon with a window. The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption.

Syntax
To send this message, call the SendMessage function as follows.
lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) WM_SETICON, // message ID (WPARAM) wParam, // = (WPARAM) () wParam; (LPARAM) lParam // = (LPARAM) () lParam; ); Parameters

wParam
Specifies the type of icon to be set. This parameter can be one of the following values.
ICON_BIG
Set the large icon for the window.
ICON_SMALL
Set the small icon for the window.
lParam
Handle to the new large or small icon. If this parameter is NULL, the icon indicated by wParamis removed.
Return Value

The return value is a handle to the previous large or small icon, depending on the value of wParam. It is NULL if the window previously had no icon of the type indicated by wParam.
Remarks

The DefWindowProc function returns a handle to the previous large or small icon associated with the window, depending on the value of wParam.

Message Information

Header Declared in Winuser.h, include Windows.h
Minimum operating systems Windows 95, Windows NT 4.0

See Also

Windows Overview, DefWindowProc, WM_GETICON

--------------------------------------------------------------------------------

? 2003 Microsoft Corporation. All rights reserved.



"David Lowndes" <da****@example.invalid> wrote in message news:h7********************************@4ax.com...

I found possible bug with set icon.
I''m not sure but I don''t think this is supposed to work like this.

Program uses large instead of small icons.
Please tell me is it known bug or maybe I missed something.

If it is a bug I made document how to make it happen. So I''ll send it to
someone who can verify it.



Why don''t you post a minimal code snippet here that illustrates how to
reproduce this issue?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



>Since I tested behaviour, I created following results of my test:

I hope you can read html (red is possible error).
No HTML here thanks.
Resources: 3 separate files with resource ids: IDI_ICONS(for small - list and details), IDI_ICONL(for large - icons), IDI_ICONX(for xlarge - tiles and thumbinals)
S=small, L=large, X=xlarge
App icon Windows Explorer (list view ctrl)
Function calls top-left(=small) Alt+Tab(=large) Small(16x16) Large(32x32) XLarge(48x48)
SM + ICON_SMALL + IDI_ICONS
snip
I''m afraid I''ve not got the faintest idea what you''re trying to tell
us in that lot.
SendMessage(WM_SETICON, ICON_BIG, (LPARAM)AfxGetApp()->LoadIcon(IDI_ICONALL));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM)AfxGetApp()->LoadIcon(IDI_ICONALL));



Use LoadImage rather than LoadIcon. LoadIcon only loads icons of size
SM_CXICON, SM_CYICON.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq


这篇关于SetIcon bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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