cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad C++ API
About Archicad add-on development using the C++ API.

SingleSelListView with custom icons appearing as gray boxes

NatHen
Participant

I'm having an issue putting custom icons into SingleSelListView rows. No matter how I assign the icon to the row, it always appears as a gray box.

 

I define a listview in the GRC file like this:

/* [ 2] */ SingleSelListView 40 60 370 350 LargePlain 40 40 150 50 singleColumn

then am trying to add the icons via code. I have tried this multiple ways.

 

Here is the code I'm using to setup the list view. The list view appears perfectly in the UI, except the icon's appear as grey boxes.

 

DGListViewSetItemSize(dialogID, listID, 150, 50);
DGListViewSetImageSize(dialogID, listID, 24, 24);
DGListViewDeleteItem(dialogID, listID, DG_ALL_ITEMS);

//this code is inside a loop 
DGListViewInsertItem(dialogID, listID, DG_LIST_BOTTOM);
DGListViewSetItemText(dialogID, listID, DG_LIST_BOTTOM, text);

//icon set here
DG::Icon aicon = DG::Icon(ACAPI_GetOwnResModule(), DG::Icon::GetIdFromString("35011"))
DGListViewSetItemImage(dialogID, listID, DG_LIST_BOTTOM, DG_LVIT_ICON, aicon);

//set status and userdata
DGListViewSetItemStatus(dialogID, listID, DG_LIST_BOTTOM, DG_IS_ENABLE);
DGListViewSetItemUserData(dialogID, listID, DG_LIST_BOTTOM, userData);

//endloop

 

 

 

I have also tried this way of initializing icons and assigning them:

 

NewDisplay::NativeImage archimg(ACAPI_GetOwnResModule(), 35011, NewDisplay::NativeImage::Encoding::PNG);
const void* dgPicture = GX::Image(archimg).ToDGPicture();
DGListViewSetItemImage(dialogID, listID, DG_LIST_BOTTOM, DG_LVIT_ICON, DG::Icon(dgPicture));

 

 

My final attempt, I added the icons as a DG::IconItems to my ModalDialog, displayed them somewhere so I knew they were working correctly, then did a .SetVisibility(false) and a .Hide() on the icons to not show them. I then did:

 

aIcon.SetIcon(DG::Icon(ACAPI_GetOwnResModule(), 35011)); //aIcon is an IconItem
...
...
DGListViewSetItemImage(dialogID, listID, DG_LIST_BOTTOM, DG_LVIT_ICON, aIcon.GetIcon());

DG::Icon ai = aIcon.GetIcon();
bool empty = ai.IsEmpty(); //this is false
bool valid = ai.IsValid(); //this is true

 

 

Despite all 3 of these methods, the icon in each row always displays as a grey box. I have tried using DG_LVIT_PICTURE and that didn't work either.

 

Does anyone have any suggestions, or has anyone encountered this before? Can I only use the default icons specified by Archicad?

1 REPLY 1
Viktor Kovacs
Graphisoft
Graphisoft

The icon identifier variable must have "short" type. Your are passing 35011 that is outside of the short range in C++. Try using a number that is lower than 32767.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!