Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Use Windows command bar icon (FaceID) on dialog?

Use Windows command bar icon (FaceID) on dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlearning
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    J B 0
    wrote on last edited by
    #1

    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!

    D 1 Reply Last reply
    0
    • J J B 0

      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!

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      J.B. wrote:

      Apparently it did not work...

      What does LoadIcon() return? Have you tried making hIcon 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 1 Reply Last reply
      0
      • D David Crow

        J.B. wrote:

        Apparently it did not work...

        What does LoadIcon() return? Have you tried making hIcon 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 Offline
        J Offline
        J B 0
        wrote on last edited by
        #3

        Dear DavidCrow, Thanks for the reply. LoadIcon() returns NULL. I should give more details about my project. The dialog is ATL-based class which is to be brought up via DoModal(). A window-based parent may decide to bring up the dialog at any time. Since the dialog is ATL based (derived from CAxDialogImpl class). The way I use to call LoadIcon in the dialog's OnInitDialog() is in fact:

        HICON hIcon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINRESOURCE(540));
        if (NULL != hIcon)
        this->SetIcon(hIcon);

        I get hIcon is NULL in return. Am I doing something incorrectly here? Thanks!

        D 1 Reply Last reply
        0
        • J J B 0

          Dear DavidCrow, Thanks for the reply. LoadIcon() returns NULL. I should give more details about my project. The dialog is ATL-based class which is to be brought up via DoModal(). A window-based parent may decide to bring up the dialog at any time. Since the dialog is ATL based (derived from CAxDialogImpl class). The way I use to call LoadIcon in the dialog's OnInitDialog() is in fact:

          HICON hIcon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINRESOURCE(540));
          if (NULL != hIcon)
          this->SetIcon(hIcon);

          I get hIcon is NULL in return. Am I doing something incorrectly here? Thanks!

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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 1 Reply Last reply
          0
          • D David Crow

            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 Offline
            J Offline
            J B 0
            wrote on last edited by
            #5

            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 :)

            D 1 Reply Last reply
            0
            • J J B 0

              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 :)

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              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 1 Reply Last reply
              0
              • D David Crow

                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 Offline
                J Offline
                J B 0
                wrote on last edited by
                #7

                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[^]

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups