Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Listview icons?


6 replies to this topic

gstock

gstock
  • Members
  • 8 posts

Posted 22 August 2005 - 21:15

I'm populating a listview at runtime. Here is a snippet:

CODE

hRecord = MsiCreateRecord(5);

MsiRecordSetString(hRecord, 1, L"PREREQS_CHECK");

MsiRecordSetInteger(hRecord, 2, ivRecordCount);

svRecordText = L"Info: ";
svRecordText.append(svSubString);
svRecordValueText.append(svSubString+lpRecordCount);
MsiRecordSetString(hRecord, 3, svRecordValueText);
MsiRecordSetString(hRecord, 4, svRecordText);
MsiRecordSetString(hRecord, 5, L"QuestionIcon");


I open and close all DB handles before and after as needed.

The "QuestionIcon" is an icon stored in the binary table. All the text is put into the listview the correct way, and it is displayed correctly, but I there is no icon displayed.

The odd part is, if I change the listview attribute to be sorted, I get the icon. I don't change any code, only the sorted attribute. I don't want to sort it, but its the only way I can see the icon.

Anyone ever seen this?

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 23 August 2005 - 19:44

Can't say I've seen this, but... do you raise ivRecordCount every time?

Otherwise, rewrite the code to change an existing MSI (so, not a Custom Action modifying the active install at runtime, but a program/VBS opening, changing and saving a MSI), and check the result with Orca.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 24 August 2005 - 18:41

Not sure why it doesn't work when you don't specify "sorted" but are you really sure yu want these entries listed in alphabetical order?
Note that "sorted" means that they will be listed in the order you specify in the order column. "Unsorted" means this number is ignored and the entries are sorted alphabetically.

gstock

gstock
  • Members
  • 8 posts

Posted 25 August 2005 - 14:30

Yup, I raise the record count every time. I don't want it sorted alphabetically because I'm creating a multiline listview. So a sentance covers 2 lines, if I sort it, those lines won't appear in the right order. Here is the full funtion:

CODE

OutputDebugString(L"Entering AddToListView");
PMSIHANDLE  hDB;
PMSIHANDLE  hView;
UINT uRet;
LPWSTR  lpRecordCount;
int   ivRecordCount;
PMSIHANDLE hRecord;
int   izMaxLineLength = 80;
int   izLineLength;
CStdString svRecordText;
CStdString svRecordValueText;
CStdString svSubString;
CStdString svSecondHalf;
CStdString szLogMsg;


//get teh current open MSI database handle
hDB = MsiGetActiveDatabase(hInstall);
if(hDB == 0){
 LogMessage(hInstall,L"AddToListView: Failed to get active database");
 OutputDebugString(L"AddToListView: Failed to get active database");
 ModalMessageBox(hInstall,L"Failed to get active database",L"Error",MB_OK | MB_ICONEXCLAMATION);
 return hDB;
}
//select the listview table, with the properties for our listview
uRet = MsiDatabaseOpenView(hDB,L"SELECT * FROM `ListView` WHERE `Property`='LV_PREREQS_CHECK'",&hView);
if(uRet != ERROR_SUCCESS){
 LogMessage(hInstall,L"AddToListView: Failed to open database");
 OutputDebugString(L"AddToListView: Failed to open database");
 ModalMessageBox(hInstall,L"Failed to open database",L"Error",MB_OK | MB_ICONEXCLAMATION);
 return uRet;

}
//execute the query
uRet = MsiViewExecute(hView, 0);
if(uRet != ERROR_SUCCESS){
 LogMessage(hInstall,L"AddToListView: Failed to ViewExecute on the database");
 OutputDebugString(L"AddToListView: Failed to ViewExecute on the database");
 ModalMessageBox(hInstall,L"Failed to ViewExecute on the database",L"Error",MB_OK | MB_ICONEXCLAMATION);
 return uRet;
}

//find the record count so we don't overwrite a record in the DB already
lpRecordCount = GetStringProperty(hInstall,L"PREREQ_CHECK_COUNT");
ivRecordCount = _wtoi(lpRecordCount);
ivRecordCount++;
swprintf(lpRecordCount,L"%i",ivRecordCount);
SetStringProperty(hInstall,L"PREREQ_CHECK_COUNT",lpRecordCount);


izLineLength = izMaxLineLength;
if(izLineLength > wcslen(szErrorTitle)){
 izLineLength = wcslen(szErrorTitle);
}
 svSubString = szErrorTitle;
 svSubString = svSubString.substr(0,izLineLength);

if(wcscmp(szIconType,L"ERROR_ICON") == 0){
 //create new records, and write to the listview table
 hRecord = MsiCreateRecord(5);

 MsiRecordSetString(hRecord, 1, L"LV_PREREQS_CHECK");
 MsiRecordSetInteger(hRecord, 2, ivRecordCount);
 svRecordText = L"Error: ";
 svRecordText.append(svSubString);
 svRecordValueText.append(svSubString+lpRecordCount);
 
 //MsiRecordSetString(hRecord, 4, szText);
 MsiRecordSetString(hRecord, 3, svRecordValueText);
 MsiRecordSetString(hRecord, 4, svRecordText);
 
 MsiRecordSetString(hRecord, 5, L"ErrorIcon");
 
}

else if (wcscmp(szIconType,L"WARNING_ICON") == 0){
 //create new records, and write to the listview table
 hRecord = MsiCreateRecord(5);

 MsiRecordSetString(hRecord, 1, L"LV_PREREQS_CHECK");
 MsiRecordSetInteger(hRecord, 2, ivRecordCount);
 svRecordText = L"Warning: ";
 svRecordText.append(svSubString);
 svRecordValueText.append(svSubString+lpRecordCount);
 MsiRecordSetString(hRecord, 3, svRecordValueText);
 MsiRecordSetString(hRecord, 4, svRecordText);
 //use the warning icon from installshield
 MsiRecordSetString(hRecord, 5, L"NewBinary4");
}
else if (wcscmp(szIconType,L"QUESTION_ICON") == 0){
 //create new records, and write to the listview table
 hRecord = MsiCreateRecord(5);

 MsiRecordSetString(hRecord, 1, L"LV_PREREQS_CHECK");
 MsiRecordSetInteger(hRecord, 2, ivRecordCount);
 svRecordText = L"Info: ";
 svRecordText.append(svSubString);
 svRecordValueText.append(svSubString+lpRecordCount);
 MsiRecordSetString(hRecord, 3, svRecordValueText);
 MsiRecordSetString(hRecord, 4, svRecordText);
 //for undefined, use the question icon, this should VERY RARELY be used
 MsiRecordSetString(hRecord, 5, L"Ex_QuestionIcon");

}
else{
 //create new records, and write to the listview table
 hRecord = MsiCreateRecord(4);

 MsiRecordSetString(hRecord, 1, L"LV_PREREQS_CHECK");
 MsiRecordSetInteger(hRecord, 2, ivRecordCount);
 svRecordText = L"         ";
 svRecordText.append(svSubString);
 svRecordValueText.append(svSubString+lpRecordCount);
 
 MsiRecordSetString(hRecord, 3, svRecordValueText);
 MsiRecordSetString(hRecord, 4, svRecordText);

}


uRet = MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRecord);
if(uRet != ERROR_SUCCESS){
 LogMessage(hInstall,L"AddToListView: Failed to MsiModifyView, temporary");
 OutputDebugString(L"AddToListView: Failed to MsiModifyView, temporary");
 ModalMessageBox(hInstall,L"Failed to MsiModifyView, temporary",L"Error",MB_OK | MB_ICONEXCLAMATION);
 return uRet;
}
//MsiViewModify(hView, MSIMODIFY_REFRESH, hRecord);


//MsiViewModify(hView, MSIMODIFY_SEEK, hRecord);

MsiViewClose(hView);
MsiCloseHandle(hRecord);
MsiCloseHandle(hView);
MsiCloseHandle(hDB);
svSecondHalf = szErrorTitle;
svSecondHalf = svSecondHalf.substr(izLineLength, wcslen(szErrorTitle));

if(izLineLength < svSecondHalf.GetLength()){
 OutputDebugString(L"__________________________________________________");
 AddToListView(hInstall,svSecondHalf,L"Extra_info");

}



return ERROR_SUCCESS;




It is a recursive function where you call it and give it an arbitrary length string. It chops it up to visible lengths, then calls itself to append more lines to the listview. The icon is only set on the first call to the function, the recursive calls only add padding spaces. If I sort the listview, the icons show up on the correct lines, and the padding shows up correctly, but since it is sorted, none of the lines match up anymore.


As far as saving an MSI, all appears to be ok, which I'm not surprised at, since everything is fine, once I select sorted from the IS gui.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 26 August 2005 - 22:04

QUOTE
I don't want it sorted alphabetically

That's what I'm saying. If you want it sorted in the way you number the entries you need to make the list "sorted". This sounds weired, but the opposite of "sorted" in this case is "ignore the sort sequence and sort alphbetically instead". At least that's my understanding of the docs.
QUOTE
Sorted
0x00000000 Items displayed in alphabetical order.
0x00010000 Items displayed in order specified in the ListView table.


gstock

gstock
  • Members
  • 8 posts

Posted 29 August 2005 - 14:45

I understand that, but the only way to get the icons to show up is to make it sorted, which I don't want to do. If I don't make it sorted, which is what I want, the icons don't show up. The only thing I change, is to make it sorted, and the icons show up. So I don't think its a database table issue.

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 09 September 2005 - 14:48

Guess what, I'm creating a ListView in a dialog now, and this appears to be a bug in Windows Installer.

When the Sorting bit is set (meaning: "use order of ListView table"), you get empty -totally transparent- icons.
When the Sorted bit is cleared ("use alphabetic order of items") you get the requested icons.

Using Orca, I tried modifying the attributes of the control, setting FixedSize and IconSize (which you can't control using InstallShield X), but that won't help.

I use Win2003sp1, Windows Installer 3.01.4000.1830.