+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ return FALSE;
+ }
+ m_alPageId.Insert((long)ulApiPage, nPage);
+ }
+
+ //
+ // Associate a window handle with the page
+ //
+ if (pPage)
+ {
+ if (!::WinSendMsg( GetHWND()
+ ,BKM_SETPAGEWINDOWHWND
+ ,MPFROMLONG((ULONG)m_alPageId[nPage])
+ ,MPFROMHWND(pPage->GetHWND())
+ ))
+ return FALSE;
+ }
+ //
+ // If the inserted page is before the selected one, we must update the
+ // index of the selected page
+ //
+ if (nPage <= (size_t)m_nSelection)
+ {
+ //
+ // One extra page added
+ //
+ m_nSelection++;
+ }
+
+ if (pPage)
+ {
+ //
+ // Save the pointer to the page
+ //
+ m_pages.Insert( pPage
+ ,nPage
+ );
+ }
+
+ //
+ // Now set TAB dimenstions
+ //
+
+ wxWindowDC vDC(this);
+ wxCoord nTextX;
+ wxCoord nTextY;
+
+ vDC.GetTextExtent(rsStrText, &nTextX, &nTextY);
+ nTextY *= 2;
+ nTextX = (wxCoord)(nTextX * 1.3);
+ if (nTextX > m_nTabSize)
+ {
+ m_nTabSize = nTextX;
+ ::WinSendMsg( GetHWND()
+ ,BKM_SETDIMENSIONS
+ ,MPFROM2SHORT((USHORT)m_nTabSize, (USHORT)nTextY)
+ ,(MPARAM)BKA_MAJORTAB
+ );
+ }
+ //
+ // Now set any TAB text
+ //
+ if (!rsStrText.IsEmpty())
+ {
+ if (!SetPageText( nPage
+ ,rsStrText
+ ))
+ return FALSE;
+ }
+
+ //
+ // Now set any TAB bitmap image
+ //
+ if (nImageId != -1)
+ {
+ if (!SetPageImage( nPage
+ ,nImageId
+ ))
+ return FALSE;
+ }
+
+ if (pPage)
+ {
+ //
+ // Don't show pages by default (we'll need to adjust their size first)
+ //
+ HWND hWnd = GetWinHwnd(pPage);
+
+ WinSetWindowULong( hWnd
+ ,QWL_STYLE
+ ,WinQueryWindowULong( hWnd
+ ,QWL_STYLE
+ ) & ~WS_VISIBLE
+ );
+
+ //
+ // This updates internal flag too - otherwise it will get out of sync
+ //
+ pPage->Show(FALSE);
+ }
+
+ //
+ // Some page should be selected: either this one or the first one if there is