- int nCount = ::WinQueryClassName((HWND)hWnd, nLen, vStr.GetWriteBuf(nLen));
-
- vStr.UngetWriteBuf();
- if (nCount == nLen )
- {
- // the class name might have been truncated, retry with larger
- // buffer
- nLen *= 2;
- }
- else
- {
- break;
+ int nLen = 256; // some starting value
+
+ for ( ;; )
+ {
+ int nCount = ::WinQueryClassName((HWND)hWnd, nLen, wxStringBuffer(vStr, nLen));
+
+ if (nCount == nLen )
+ {
+ // the class name might have been truncated, retry with larger
+ // buffer
+ nLen *= 2;
+ }
+ else
+ {
+ break;
+ }