|
HI!
The code is below.
i had tried both the way.by using LVBKIMAGE and also used ImageList_AddIcon,but not getting fruitful result. can any guide me,please?
<br />
<br />
LVBKIMAGE IBBkImg;<br />
ZeroMemory(&IBBkImg,sizeof(LVBKIMAGE));<br />
IBBkImg.ulFlags=LVBKIF_STYLE_TILE;<br />
IBBkImg.pszImage=(LPWSTR)"C:\\ok.bmp";<br />
LvItem.iItem=0;
LvItem.iSubItem=0;
<br />
LvItem.pszText=w_UploadedFile;
SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem);
Amit
|
|
|
|
|
|
i did it. i got reference from that but in WM_PAINT gives error,AND i also took reference from 2 more places then i put here.
amit
|
|
|
|
|
|
Three errors
1)
Error 2 error LNK2019: unresolved external symbol __imp__ImageList_Create@20 referenced in function "long __stdcall GlobaListProc(struct HWND__ *,unsigned int,unsigned int,long)" (?GlobaListProc@@YGJPAUHWND__@@IIJ@Z) DRMClient.obj
2)same as bove
3)Error 5 fatal error LNK1120: 2 unresolved externals D:\Projects\Debug\DRMClient.exe
|
|
|
|
|
Did you include Commctrl.lib/ Imgctl.lib
|
|
|
|
|
I have added it. Inspite of it gives the linking error is any there other matter?
Amit
|
|
|
|
|
Requires comctl32.lib library to be linked.
|
|
|
|
|
I have already used include.
#include <commctrl.h>
is it ok? if not then guide me for explicit linking with lib.
|
|
|
|
|
|
|
how can i resolve the bugs , for linking.
I need simple first, then i will try to add the file icon . but i need base first how can any images display icon/image from resource in the listview.
|
|
|
|
|
which view are you using in list view? Report, icon etc..?
nave
|
|
|
|
|
|
1.Create a image list with width and height 20, 20 or less
2.Add icons to the image list.
3. Send LVM_SETIMAGELIST to the image list with the wparam LVSIL_SMALL and LPARAM as handle of image list.
4. Then while inserting item with the LVM_INSERTITEM message, set the appropriate values in the LVITEM structure( mask and iImage )
nave
|
|
|
|
|
the code as per your guidline is below
<br />
<br />
memset(&LvCol,0,sizeof(LvCol));
HIMAGELIST hSmall;<br />
HICON hIcon;<br />
<br />
hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1);<br />
<br />
hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_QUESTION));<br />
ImageList_AddIcon(hSmall, hIcon);<br />
DestroyIcon(hIcon);<br />
<br />
ListView_SetImageList(hList, hSmall, LVSIL_SMALL);<br />
<br />
LvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;<br />
LvCol.iSubItem = 0;<br />
LvCol.pszText = _T("Flag");<br />
LvCol.cx = 50;<br />
LvCol.fmt = LVCFMT_RIGHT;<br />
LvCol.iImage =0;<br />
<br />
ListView_InsertColumn(hList, 0, &LvCol); <br />
LvCol.pszText=_T("File"); <br />
SendMessage(hList,LVM_INSERTCOLUMN,1,(LPARAM)&LvCol);<br />
LvCol.pszText=_T("Extension");
SendMessage(hList,LVM_INSERTCOLUMN,2,(LPARAM)&LvCol);
LvCol.pszText=_T("Location");
<br />
SendMessage(hList,LVM_INSERTCOLUMN,3,(LPARAM)&LvCol);
LvCol.pszText=_T("Size");
<br />
SendMessage(hList,LVM_INSERTCOLUMN,4,(LPARAM)&LvCol);
LvCol.pszText=_T("Duration");
<br />
SendMessage(hList,LVM_INSERTCOLUMN,5,(LPARAM)&LvCol);
LvCol.pszText=_T("Bit Rate");
<br />
SendMessage(hList,LVM_INSERTCOLUMN,6,(LPARAM)&LvCol);
LvCol.pszText=_T("Type"); <br />
SendMessage(hList,LVM_INSERTCOLUMN,7,(LPARAM)&LvCol);
LvCol.pszText=_T("Modified Date"); <br />
SendMessage(hList,LVM_INSERTCOLUMN,8,(LPARAM)&LvCol);
LvCol.pszText=_T("Progress"); <br />
SendMessage(hList,LVM_INSERTCOLUMN,9,(LPARAM)&LvCol);
LvCol.pszText=_T("Protected");<br />
SendMessage(hList,LVM_INSERTCOLUMN,10,(LPARAM)&LvCol);
memset(&LvItem,0,sizeof(LvItem));<br />
SendMessage(hList,LVM_INSERTCOLUMN,11,(LPARAM)&LvCol);
LvItem.mask=LVIF_TEXT;
LvItem.cchTextMax = 256;
ListView_SetItemState(hList,0,LVIS_SELECTED ,LVIF_STATE); <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Amit
|
|
|
|
|
your code have some problem..
amitmistry_petlad wrote: hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1);
use ILC_COLOR32 along with ILC_MASK
hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), ILC_COLOR32|ILC_MASK, 1, 1);
amitmistry_petlad wrote: DestroyIcon(hIcon);
Should not call DestroyIcon for a resource icon.
Also show me how you called the ListView_InsertItem().
nave
|
|
|
|
|
I am using listview two times.
1) first when i read all the xml content and display it in the listview.(on WM_INITDIALOG)
for that all columns draw first time in this call back(i will manage it if first time image add
by the (2)). (this is when application open firstime)
(after opened application- new dialog contain combo and new call back - and listview HANDLE is global )
2) when I add any new item in the list view through open dialog.(when COMBO event selchange)
then the new values(files) add diretly in this when i used open dialog.(want to add image/icon here ). when dialog close.the listview saved and display by (1).(this is when running application).
//same for all sub items
<br />
LvItem.iItem=i; <br />
LvItem.iSubItem=0;
LvItem.pszText=(LPWSTR)w_UploadedFile;<br />
SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem);
|
|
|
|
|
why didnt you set the mask member of the LVITEM? Also you havent set the iImage member of the structure LVITEM. If you didnt set this values, image will not appear.
LvItem.iItem=i;
LvItem.iImage = 0;// 0th image in the image list
LvItem.mask = LVIF_TEXT|LVIF_IMAGE
LvItem.iSubItem=0; //using loop for sub item
LvItem.pszText=(LPWSTR)w_UploadedFile;
SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&LvItem);//please refer LVM_SETITEM for sub item
nave
|
|
|
|
|
it is ok but. still i faced the following linking error.
Error 63 error LNK2019: unresolved external symbol __imp__ImageList_Create@20 referenced in function "long __stdcall GlobaListProc(struct HWND__ *,unsigned int,unsigned int,long)" (?GlobaListProc@@YGJPAUHWND__@@IIJ@Z) DRMClient.obj
Error 62 error LNK2019: unresolved external symbol __imp__ImageList_ReplaceIcon@12 referenced in function "long __stdcall GlobaListProc(struct HWND__ *,unsigned int,unsigned int,long)" (?GlobaListProc@@YGJPAUHWND__@@IIJ@Z) DRMClient.obj
Error 66 fatal error LNK1120: 2 unresolved externals D:\Projects\Debug\DRMClient.exe
GlobaListProc is my callback where under this dialog my listview control present
i am finding solution for this in msdn.
|
|
|
|
|
Hi all,
I need to know the status of the physical memory.
Total physical memory of my machine is 512 MB.
But when i use GlobalMemoryStatusEx API, it shows the size as 503 MB.
Why it happens so?
MSDN says that the values retrieved by this function is volatile.
How can know the exact physical memory size?
Any help would be appreciated.
Thanks.
Selva
|
|
|
|
|
See if this helps.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks David.
But it shows 518MB now..But the actual memory is only 512 MB.
What could be the problem..
Thanks
Selva
|
|
|
|
|
Hi,
I am writing a code to execute a method of a WMI class. Please find a piece of my code below :
CString wmi_method = WMI_METHOD_GETINSTID;
BSTR wmi_method_bstr = _bstr_t(wmi_method);
IWbemClassObject* l_pClass = NULL;
HRESULT (l_hRes);
l_hRes = m_wmiService->GetObject(L"Win32_WindowsProductActivation", 0, NULL,&l_pClass, NULL); //WMI Call
if (FAILED (l_hRes))
return 0;
IWbemClassObject* l_pInParamsDefinition = NULL; //input parameter definition
IWbemClassObject* l_pOutParams= NULL;
l_hRes = l_pClass->GetMethod(L"GetInstallationID", 0, &l_pInParamsDefinition, &l_pOutParams);
if (FAILED (l_hRes))
{
return 0;
}
IWbemClassObject* l_pClassInstance = NULL;
l_hRes = l_pInParamsDefinition->SpawnInstance(0, &l_pClassInstance);
if (FAILED (l_hRes))
{
l_pClass->Release();
l_pInParamsDefinition->Release();
l_pClassInstance->Release();
return 0;
}
This code is failing because l_pInParamsDefinition value after GetMethod is called is null.
hence it cannot do 'spawnInstalnce' .
Can anyone please let me know what could be wrong.
Thanks,
Manasi
|
|
|
|
|
i got the same problem, i found l_pInParamsDefinition is null but l_pOutParams is not null, you can use l_pOutParams to spawnInstance
|
|
|
|
|