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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Icons are displayed as black squares on remote desktops

Icons are displayed as black squares on remote desktops

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++databasegraphics
9 Posts 3 Posters 1 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.
  • A Offline
    A Offline
    APSAccounts
    wrote on last edited by
    #1

    Hey guys, I'm encountering the following problem. I wolud very much appreciate your help. Description of the problem MFC Desktop Application VisualStudio 2010 Icons are supposed to be displayed in a CListCtrl as a CImageList. It usually works fine except when using RemoteDesktop with the OS Windows 2008 / 2003. In these particular cases the icons are just displayed as a black square. Connecting with VMware vSphere (alternative to RemoteDesktop) -> Icons are shown appropriately Remotdesktop on Windows XP / 7 / 8 -> Icons are shown appropriately Code: OnInitDialog() { /* ~Standardcode */ // Setting the symbol for this dialog-field. This is done automatically // if the mainwindow of the application is no dialog-field. SetIcon(m_hIcon, TRUE); // using big symbol SetIcon(m_hIcon, FALSE); // using small symbol // TODO: appending additional initialization InitList(); // m_list.SetImageList(imageList, LVSIL_NORMAL); //captions CString buf = _T("testitem"); m_list.InsertItem(0, buf, 0); m_list.SetItemData(0, (DWORD) 0); m_list.SetItemText(0, 0, _T("0")); m_list.SetItemState(0, 2, LVIS_SELECTED); m_list.EnsureVisible(0, FALSE); } void CDispomarkierungTestDlg::InitList() { imageList = new CImageList(); int err = imageList->Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 1); //ILC_COLOR16 , ILC_COLOR8 , ... getested int id = 40; int requiredLength = 3154; LPCSTR picInCharsFromDB = GetBitmapAsText(); int width = 24; int heigth = 24; int pixel = 32; int planes = 1; BYTE *picInBytes = new BYTE[requiredLength]; int lengthVariable = requiredLength; int* lengthPointer; lengthPointer = &lengthVariable; Base64Decode(picInCharsFromDB, requiredLength, picInBytes, lengthPointer); HANDLE hBitMap = CreateBitmap(width, heigth, planes, pixel, picInBytes); BITMAP bitmap; GetObject(hBitMap,sizeof(BITMAP),&bitmap); CImage image; image.Attach((HBITMAP)hBitMap); CBitmap icon; icon.Attach((HBITMAP)hBitMap); CBitmap* bitmappointer; bitmappointer = &icon; BITMAP bmp; icon.GetBitmap(&bmp); CClientDC dcClient(this); CDC memDC; memDC.CreateCompatibleDC(&dcClient); HBITMAP hbmMask = ::CreateCompatibleBitmap(memDC.GetSafeHdc(), width, heigth); ICONINFO ii = {0}; ii.fIcon = TRUE; ii.hbmColor = icon; ii.hbmMask = hbmMask; HICON hIcon = ::CreateIconIndirect(&ii); ::DeleteObject(hbmMask); err = imageList->Add(hIcon); } In the real application, the source is a database which

    Richard Andrew x64R L 2 Replies Last reply
    0
    • A APSAccounts

      Hey guys, I'm encountering the following problem. I wolud very much appreciate your help. Description of the problem MFC Desktop Application VisualStudio 2010 Icons are supposed to be displayed in a CListCtrl as a CImageList. It usually works fine except when using RemoteDesktop with the OS Windows 2008 / 2003. In these particular cases the icons are just displayed as a black square. Connecting with VMware vSphere (alternative to RemoteDesktop) -> Icons are shown appropriately Remotdesktop on Windows XP / 7 / 8 -> Icons are shown appropriately Code: OnInitDialog() { /* ~Standardcode */ // Setting the symbol for this dialog-field. This is done automatically // if the mainwindow of the application is no dialog-field. SetIcon(m_hIcon, TRUE); // using big symbol SetIcon(m_hIcon, FALSE); // using small symbol // TODO: appending additional initialization InitList(); // m_list.SetImageList(imageList, LVSIL_NORMAL); //captions CString buf = _T("testitem"); m_list.InsertItem(0, buf, 0); m_list.SetItemData(0, (DWORD) 0); m_list.SetItemText(0, 0, _T("0")); m_list.SetItemState(0, 2, LVIS_SELECTED); m_list.EnsureVisible(0, FALSE); } void CDispomarkierungTestDlg::InitList() { imageList = new CImageList(); int err = imageList->Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 1); //ILC_COLOR16 , ILC_COLOR8 , ... getested int id = 40; int requiredLength = 3154; LPCSTR picInCharsFromDB = GetBitmapAsText(); int width = 24; int heigth = 24; int pixel = 32; int planes = 1; BYTE *picInBytes = new BYTE[requiredLength]; int lengthVariable = requiredLength; int* lengthPointer; lengthPointer = &lengthVariable; Base64Decode(picInCharsFromDB, requiredLength, picInBytes, lengthPointer); HANDLE hBitMap = CreateBitmap(width, heigth, planes, pixel, picInBytes); BITMAP bitmap; GetObject(hBitMap,sizeof(BITMAP),&bitmap); CImage image; image.Attach((HBITMAP)hBitMap); CBitmap icon; icon.Attach((HBITMAP)hBitMap); CBitmap* bitmappointer; bitmappointer = &icon; BITMAP bmp; icon.GetBitmap(&bmp); CClientDC dcClient(this); CDC memDC; memDC.CreateCompatibleDC(&dcClient); HBITMAP hbmMask = ::CreateCompatibleBitmap(memDC.GetSafeHdc(), width, heigth); ICONINFO ii = {0}; ii.fIcon = TRUE; ii.hbmColor = icon; ii.hbmMask = hbmMask; HICON hIcon = ::CreateIconIndirect(&ii); ::DeleteObject(hbmMask); err = imageList->Add(hIcon); } In the real application, the source is a database which

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      From your explanation it's not clear whether Windows 2008 and 2003 represent the remote desktop, or the desktop on which you are viewing the remote desktop.

      The difficult we do right away... ...the impossible takes slightly longer.

      A 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        From your explanation it's not clear whether Windows 2008 and 2003 represent the remote desktop, or the desktop on which you are viewing the remote desktop.

        The difficult we do right away... ...the impossible takes slightly longer.

        A Offline
        A Offline
        APSAccounts
        wrote on last edited by
        #3

        They represent the remote desktop on which the application runs, sorry for the unclarity.

        1 Reply Last reply
        0
        • A APSAccounts

          Hey guys, I'm encountering the following problem. I wolud very much appreciate your help. Description of the problem MFC Desktop Application VisualStudio 2010 Icons are supposed to be displayed in a CListCtrl as a CImageList. It usually works fine except when using RemoteDesktop with the OS Windows 2008 / 2003. In these particular cases the icons are just displayed as a black square. Connecting with VMware vSphere (alternative to RemoteDesktop) -> Icons are shown appropriately Remotdesktop on Windows XP / 7 / 8 -> Icons are shown appropriately Code: OnInitDialog() { /* ~Standardcode */ // Setting the symbol for this dialog-field. This is done automatically // if the mainwindow of the application is no dialog-field. SetIcon(m_hIcon, TRUE); // using big symbol SetIcon(m_hIcon, FALSE); // using small symbol // TODO: appending additional initialization InitList(); // m_list.SetImageList(imageList, LVSIL_NORMAL); //captions CString buf = _T("testitem"); m_list.InsertItem(0, buf, 0); m_list.SetItemData(0, (DWORD) 0); m_list.SetItemText(0, 0, _T("0")); m_list.SetItemState(0, 2, LVIS_SELECTED); m_list.EnsureVisible(0, FALSE); } void CDispomarkierungTestDlg::InitList() { imageList = new CImageList(); int err = imageList->Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 1); //ILC_COLOR16 , ILC_COLOR8 , ... getested int id = 40; int requiredLength = 3154; LPCSTR picInCharsFromDB = GetBitmapAsText(); int width = 24; int heigth = 24; int pixel = 32; int planes = 1; BYTE *picInBytes = new BYTE[requiredLength]; int lengthVariable = requiredLength; int* lengthPointer; lengthPointer = &lengthVariable; Base64Decode(picInCharsFromDB, requiredLength, picInBytes, lengthPointer); HANDLE hBitMap = CreateBitmap(width, heigth, planes, pixel, picInBytes); BITMAP bitmap; GetObject(hBitMap,sizeof(BITMAP),&bitmap); CImage image; image.Attach((HBITMAP)hBitMap); CBitmap icon; icon.Attach((HBITMAP)hBitMap); CBitmap* bitmappointer; bitmappointer = &icon; BITMAP bmp; icon.GetBitmap(&bmp); CClientDC dcClient(this); CDC memDC; memDC.CreateCompatibleDC(&dcClient); HBITMAP hbmMask = ::CreateCompatibleBitmap(memDC.GetSafeHdc(), width, heigth); ICONINFO ii = {0}; ii.fIcon = TRUE; ii.hbmColor = icon; ii.hbmMask = hbmMask; HICON hIcon = ::CreateIconIndirect(&ii); ::DeleteObject(hbmMask); err = imageList->Add(hIcon); } In the real application, the source is a database which

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          What does GetBitmapAsText(); do, are you sure it is returning the correct data?

          A 1 Reply Last reply
          0
          • L Lost User

            What does GetBitmapAsText(); do, are you sure it is returning the correct data?

            A Offline
            A Offline
            APSAccounts
            wrote on last edited by
            #5

            Please don't bother about GetBitmapAsText(); because it only exists in the demo project in order to replace the complex algorithm and database infrastructure in the real project and make the problem portable. The correct loading of picture data from DB can be assumed because the problem is not that the picture can't be seen at all but that it can only be seen in certain circumstances.

            L 1 Reply Last reply
            0
            • A APSAccounts

              Please don't bother about GetBitmapAsText(); because it only exists in the demo project in order to replace the complex algorithm and database infrastructure in the real project and make the problem portable. The correct loading of picture data from DB can be assumed because the problem is not that the picture can't be seen at all but that it can only be seen in certain circumstances.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              APSAccounts wrote:

              complex algorithm and database infrastructure

              To load an icon?

              APSAccounts wrote:

              is not that the picture can't be seen at all but that it can only be seen in certain circumstances.

              Well apart from the fact that it happens on some systems but not on some others, we have no real information to go on.

              A 1 Reply Last reply
              0
              • L Lost User

                APSAccounts wrote:

                complex algorithm and database infrastructure

                To load an icon?

                APSAccounts wrote:

                is not that the picture can't be seen at all but that it can only be seen in certain circumstances.

                Well apart from the fact that it happens on some systems but not on some others, we have no real information to go on.

                A Offline
                A Offline
                APSAccounts
                wrote on last edited by
                #7

                The demo project gives you the function GetBitmapAsText(); which constantly and reliably delivers the same picture because it always returns a hardcoded string of base64-encoded picture data. Despite of this fact and despite of the constant algorithm for the presentation the presentation of the picture differs depending on the system. Therefore, for me the reason for the problem is situated somewhere in the interaction of the presentation algorithm with the specific system. The only bridge I could build for you in order to make the picture data more transparent, would be to get rid of the base64 encoding and hardcode the picture data directly into picInBytes (BYTE*) as it is consumed by the API function CreateBitmap. But would it really help? The only reason for checking the picutre data once again would be for me the knowledge of a limitation saying that CreateBitmap needs the data on different systems in different forms...

                L 1 Reply Last reply
                0
                • A APSAccounts

                  The demo project gives you the function GetBitmapAsText(); which constantly and reliably delivers the same picture because it always returns a hardcoded string of base64-encoded picture data. Despite of this fact and despite of the constant algorithm for the presentation the presentation of the picture differs depending on the system. Therefore, for me the reason for the problem is situated somewhere in the interaction of the presentation algorithm with the specific system. The only bridge I could build for you in order to make the picture data more transparent, would be to get rid of the base64 encoding and hardcode the picture data directly into picInBytes (BYTE*) as it is consumed by the API function CreateBitmap. But would it really help? The only reason for checking the picutre data once again would be for me the knowledge of a limitation saying that CreateBitmap needs the data on different systems in different forms...

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  APSAccounts wrote:

                  the knowledge of a limitation saying that CreateBitmap needs the data on different systems in different forms...

                  That is most unlikely, as it would affect half the systems across the world. You could always check that by looking at the documentation.

                  A 1 Reply Last reply
                  0
                  • L Lost User

                    APSAccounts wrote:

                    the knowledge of a limitation saying that CreateBitmap needs the data on different systems in different forms...

                    That is most unlikely, as it would affect half the systems across the world. You could always check that by looking at the documentation.

                    A Offline
                    A Offline
                    APSAccounts
                    wrote on last edited by
                    #9

                    Well, we have to distinguish between published knowledge, unpublished/internal one and achieved by experience one. Writing here we primarly hope to find the third kind... but the first two kinds are welcome, too, of course.

                    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