Use Windows command bar icon (FaceID) on dialog?
-
Hi all, I am wondering if there is a way to use FaceID icon to a dialog box? I tried to do the following in my dialog's
OnInitDialog()
:HICON hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(540));
this->SetIcon(hIcon, FALSE);"540" is FaceID number of a commandbar button icon. Apparently it did not work as the ID did not point to the wanted resource in the dialog project. Any help would be really great. Thanks!
-
Hi all, I am wondering if there is a way to use FaceID icon to a dialog box? I tried to do the following in my dialog's
OnInitDialog()
:HICON hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(540));
this->SetIcon(hIcon, FALSE);"540" is FaceID number of a commandbar button icon. Apparently it did not work as the ID did not point to the wanted resource in the dialog project. Any help would be really great. Thanks!
J.B. wrote:
Apparently it did not work...
What does
LoadIcon()
return? Have you tried makinghIcon
a member variable instead? What happens if you use:hIcon = AfxGetApp()->LoadIcon(540);
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
J.B. wrote:
Apparently it did not work...
What does
LoadIcon()
return? Have you tried makinghIcon
a member variable instead? What happens if you use:hIcon = AfxGetApp()->LoadIcon(540);
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Dear DavidCrow, Thanks for the reply.
LoadIcon()
returnsNULL
. I should give more details about my project. The dialog is ATL-based class which is to be brought up viaDoModal()
. A window-based parent may decide to bring up the dialog at any time. Since the dialog is ATL based (derived fromCAxDialogImpl
class). The way I use to callLoadIcon
in the dialog'sOnInitDialog()
is in fact:HICON hIcon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINRESOURCE(540));
if (NULL != hIcon)
this->SetIcon(hIcon);I get
hIcon
isNULL
in return. Am I doing something incorrectly here? Thanks! -
Dear DavidCrow, Thanks for the reply.
LoadIcon()
returnsNULL
. I should give more details about my project. The dialog is ATL-based class which is to be brought up viaDoModal()
. A window-based parent may decide to bring up the dialog at any time. Since the dialog is ATL based (derived fromCAxDialogImpl
class). The way I use to callLoadIcon
in the dialog'sOnInitDialog()
is in fact:HICON hIcon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINRESOURCE(540));
if (NULL != hIcon)
this->SetIcon(hIcon);I get
hIcon
isNULL
in return. Am I doing something incorrectly here? Thanks!J.B. wrote:
Am I doing something incorrectly here?
Are you calling
GetLastError()
to find out why?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
J.B. wrote:
Am I doing something incorrectly here?
Are you calling
GetLastError()
to find out why?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Yes, the return code is
1813
(The specified resource type cannot be found in the image file
). Perhaps the resource just isn't available for access without explicitly loading from the actual resource DLL? Thanks for the help anyway :)J.B. wrote:
Perhaps the resource just isn't available for access without explicitly loading from the actual resource DLL?
Where else would it come from? :rolleyes:
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
J.B. wrote:
Perhaps the resource just isn't available for access without explicitly loading from the actual resource DLL?
Where else would it come from? :rolleyes:
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
That's exactly right. I naively thought it is as that's what I was able to do with Visual Studio Automation and Extensibility methods. I simply looked up the face ID and specified it in a method, say
AddCommandBar2()
(Commands ojbect, EnvDTE namespace). And the icon I picked would appear accordingly. I initially hoped the FaceID resource is somehow accessible globally. This is embarassing :^) Thanks for the help to clearing this out :-D Reference: FaceID Browser[^]