我遇到以下问题。我非常感谢你的帮助。
问题描述 MFC桌面应用程序 VisualStudio 2010 图标应该在CListCtrl中显示为CImageList。 它通常可以正常工作,除非将RemoteDesktop与OS Windows 2008/2003一起使用。 在这些特定情况下,图标仅显示为黑色方块。 与VMware vSphere连接(RemoteDesktop的替代方案) - >图标显示得恰当 Windows XP / 7/8上的Remotdesktop - >图标显示正确
代码:
OnInitDialog()
{
// 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);
}
在实际应用程序中,源是一个将Bitmap保存为字符串的数据库。这就是加载过程中代码复杂的原因。可以将图像作为资源加载,但在这种情况下没有选项。 服务器和客户端的驱动程序更新到最新版本。 我在这里添加了项目https://www.hidrive.strato.com/lnk/gRuMg38R。谢谢你帮忙