<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How does AppendItem() work for ListBox? in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-does-AppendItem-work-for-ListBox/m-p/362744#M1232</link>
    <description>&lt;P&gt;I was confused how empty Items in a listbox can get their value. But now that i figured out how the update function for list boxes works, the append function makes sense.&lt;/P&gt;&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2022 16:18:44 GMT</pubDate>
    <dc:creator>Dayiz</dc:creator>
    <dc:date>2022-11-21T16:18:44Z</dc:date>
    <item>
      <title>How does AppendItem() work for ListBox?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-does-AppendItem-work-for-ListBox/m-p/361607#M1230</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been working my way through the "Dialog Manager" Doc and the example addons provided by Graphisoft.&lt;/P&gt;&lt;P&gt;In the DG_Test AddOn&amp;nbsp;is an example for a ListBox called "OwnerDrawnListBoxPalette.cpp". There is a function called "GetObjects()":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;void OwnerDrawnListBoxPalette::GetObjects()&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; listBox.DeleteItem (DG::ListBox::AllItems);&lt;BR /&gt;&amp;nbsp; // add items to the listbox&lt;BR /&gt;&amp;nbsp; data.elements.Clear (true /*keepCapacity*/);&lt;BR /&gt;&amp;nbsp; data.elementImages.Clear ();&lt;BR /&gt;&amp;nbsp; ACAPI_Element_GetElemList (API_ZombieElemID, &amp;amp;data.elements);&lt;BR /&gt;&amp;nbsp; for (UIndex i = 0; i &amp;lt; data.elements.GetSize (); ++i) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; listBox.AppendItem ();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (i % 2)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; listBox.SetItemBackgroundColor (DG_LIST_BOTTOM, Gfx::Color::LightGray);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/LI-SPOILER&gt;&lt;P&gt;As I understand, the function clears the Items in the ListBox and fills it again. But how exactly does listBox.AppendItem() work?&amp;nbsp;&lt;/P&gt;&lt;P&gt;ACAPI_Element_GetElemList (API_ZombieElemID, &amp;amp;data.elements) gets an elementlist, where data is a struct and data.elements is a GS::Array&amp;lt;API_Guid&amp;gt;.&lt;/P&gt;&lt;P&gt;So if we iterate in the for loop over the size of the GS::Array, how does "listBox.AppendItem ()" know which item to add? In the header file I saw it doesn't take any parameters (void), so I'm even more confused on how this function is supposed to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear Regards&lt;/P&gt;&lt;P&gt;Dayiz&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 15:44:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-does-AppendItem-work-for-ListBox/m-p/361607#M1230</guid>
      <dc:creator>Dayiz</dc:creator>
      <dc:date>2022-11-09T15:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: How does AppendItem() work for ListBox?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-does-AppendItem-work-for-ListBox/m-p/361725#M1231</link>
      <description>&lt;P&gt;Hi Dayiz,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"listBox.AppendItem ()" adds an item to the end of the list box. So in the example you posted, for each iteration of the loop there is a new item added to the list box and then you can reference this item immediately with "DG_LIST_BOTTOM" (there is also "listBox.BottomItem") which will always point to the currently last item.&lt;BR /&gt;&lt;BR /&gt;In the end the loop body was executed exactly so many times as the size of the GS::Array, so the listBox will have that amount of items.&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 14:51:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-does-AppendItem-work-for-ListBox/m-p/361725#M1231</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2022-11-10T14:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: How does AppendItem() work for ListBox?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-does-AppendItem-work-for-ListBox/m-p/362744#M1232</link>
      <description>&lt;P&gt;I was confused how empty Items in a listbox can get their value. But now that i figured out how the update function for list boxes works, the append function makes sense.&lt;/P&gt;&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 16:18:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-does-AppendItem-work-for-ListBox/m-p/362744#M1232</guid>
      <dc:creator>Dayiz</dc:creator>
      <dc:date>2022-11-21T16:18:44Z</dc:date>
    </item>
  </channel>
</rss>

