开发者

How can I find my application's icon?

I am trying to load the icon associated with the application that called my function.

The way I am solving the problem for GUI applications is this:

AfxGetApp()->LoadIcon(128); // 128 is the IDR_MAINFRAME icon

However, the Afx functions, upon looking up the resource, fail for some non-gui applications, since afxCurrentResourceHandle is NULL.

What would be a better way to fi开发者_如何学编程nd the mainframe icon?

PS. currently I can work around it by testing afxCurrentResourceHandle != NULL... wish I could do better.


It sounds like you're assuming that only MFC applications will be calling your function. If so, how about:

HICON hIcon = AfxGetMainWnd()->GetIcon( TRUE );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜