N
NickP
Hi there,
Im using the following code to obtain an IPicture reference from a 16x16
custom binary resource of a bitmap.
-----------
IPicture *LoadPicture(const unsigned char *data, size_t len)
{
HRESULT hr = NULL;
IPicture *pic = NULL;
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, len);
LPVOID pvData = GlobalLock(hGlobal);
memcpy(pvData,data,len);
GlobalUnlock(hGlobal);
LPSTREAM pStream = NULL;
hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pStream);
if(SUCCEEDED(hr))
{
hr = OleLoadPicture(pStream, len, FALSE, IID_IPicture, (void
**)&pic);
pStream->Release();
if(SUCCEEDED(hr))
return(pic);
else
return(NULL);
}
else
return(NULL);
}
IPicture *GetButtonIcon()
{
HRSRC res = FindResource(g_hModule, MAKEINTRESOURCE(IDB_MYICON),
"BINARY");
if (res)
{
HGLOBAL mem = LoadResource(g_hModule, res);
void *data = LockResource(mem);
size_t sz = SizeofResource(g_hModule, res);
IPicture *pIPeIcon = LoadPicture((u_char*)data, sz);
return(pIPeIcon);
}
else
return(NULL);
}
-----------
From what I know the picture seems to be loading okay but I have no idea
how to set it to the command bar button...
vtParam.vt = VT_I4;
vtParam.lVal = 3;
hr = PutProperty(vtButton.pdispVal, L"Style", &vtParam);
if (FAILED(hr)) goto cleanup;
vtParam.vt = VT_I4;
vtParam.punkVal = GetButtonIcon();
hr = PutProperty(vtButton.pdispVal, L"Picture", &vtParam);
if (FAILED(hr)) goto cleanup;
I dont believe I am passing the information correctly to the object, how
would I do this correctly? Thanks loads in advance.
Nick.
Im using the following code to obtain an IPicture reference from a 16x16
custom binary resource of a bitmap.
-----------
IPicture *LoadPicture(const unsigned char *data, size_t len)
{
HRESULT hr = NULL;
IPicture *pic = NULL;
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, len);
LPVOID pvData = GlobalLock(hGlobal);
memcpy(pvData,data,len);
GlobalUnlock(hGlobal);
LPSTREAM pStream = NULL;
hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pStream);
if(SUCCEEDED(hr))
{
hr = OleLoadPicture(pStream, len, FALSE, IID_IPicture, (void
**)&pic);
pStream->Release();
if(SUCCEEDED(hr))
return(pic);
else
return(NULL);
}
else
return(NULL);
}
IPicture *GetButtonIcon()
{
HRSRC res = FindResource(g_hModule, MAKEINTRESOURCE(IDB_MYICON),
"BINARY");
if (res)
{
HGLOBAL mem = LoadResource(g_hModule, res);
void *data = LockResource(mem);
size_t sz = SizeofResource(g_hModule, res);
IPicture *pIPeIcon = LoadPicture((u_char*)data, sz);
return(pIPeIcon);
}
else
return(NULL);
}
-----------
From what I know the picture seems to be loading okay but I have no idea
how to set it to the command bar button...
vtParam.vt = VT_I4;
vtParam.lVal = 3;
hr = PutProperty(vtButton.pdispVal, L"Style", &vtParam);
if (FAILED(hr)) goto cleanup;
vtParam.vt = VT_I4;
vtParam.punkVal = GetButtonIcon();
hr = PutProperty(vtButton.pdispVal, L"Picture", &vtParam);
if (FAILED(hr)) goto cleanup;
I dont believe I am passing the information correctly to the object, how
would I do this correctly? Thanks loads in advance.
Nick.