Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First off, change your call to <code>EnumWindows()</code> to this:</p> <pre><code>int _tmain(int argc, _TCHAR* argv[]) { MYHANDLES lumpi[10]; EnumWindows(&amp;EnumVisiWindowTitles, reinterpret_cast&lt;LPARAM&gt;(lumpi)); // ... } </code></pre> <p>Standard C++ requires that you use the <code>&amp;</code> symbol to pass a pointer to a function. The <code>reinterpret_cast&lt;&gt;()</code> tells the compiler to pass the pointer to your <code>MYHANDLES</code> array as-is to the <code>LPARAM</code> parameter of <code>EnumWindows()</code>.</p> <p>Then, in your callback:</p> <pre><code>BOOL CALLBACK EnumVisiWindowTitles(HWND hWnd, LPARAM ptr) { MYHANDLES* lumpi = reinterpret_cast&lt;MYHANDLES*&gt;(ptr); // ... } </code></pre> <p>We then retrieve the original pointer back using <code>reinterpret_cast&lt;&gt;()</code> again. Then, you can act upon <code>lumpi</code> as though it was an array because it actually is an array.</p> <p>That issue asside, I see other problems. You apparently use the first element to store the count, which is weird. Just put that in another <code>struct</code>.</p> <pre><code>struct MyHandles { public: MyHandles(); HWND haendchen; char title[200]; }; struct ListOfMyHandles { public: int count; MyHandles handles[10]; }; int _tmain(int argc, _TCHAR* argv[]) { ListOfMyHandles lumpi; ::EnumWindows(&amp;EnumVisiWindowTitles, reinterpret_cast&lt;LPARAM&gt;(&amp;lumpi)); // ... } BOOL CALLBACK EnumVisiWindowTitles(HWND hWnd, LPARAM ptr) { ListOfMyHandles* lumpi = reinterpret_cast&lt;ListOfMyHandles*&gt;(ptr); if(lumpi != 0 &amp;&amp; lumpi-&gt;count &lt; 10) // Avoid going past the array { lumpi-&gt;handles[lumpi.count] = //... // ... ++lumpi-&gt;count; return TRUE; } return FALSE; } </code></pre> <p>Note that this will only hold up to 10 windows. Why not use <code>std::vector</code> instead, which will grow dynamically as you add elements to it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload