• Advertisement
Sign in to follow this  

need help with adding to a vector

This topic is 4612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

void AddNewPage( HWND hwndParent, HWND hwndTab )
{
  //+-----------------------------------------+
  //| Get the client rect of the main window. |
  //+-----------------------------------------+
  RECT rcClient ; GetClientRect( hwndParent, &rcClient ) ;

  //+------------------------------------------------------------+
  //| Now get the appropriate display area for the edit control. |
  //+------------------------------------------------------------+
  RECT rcDisplay ; rcDisplay = rcClient ;
  TabCtrl_AdjustRect( hwndTab, FALSE, &rcDisplay ) ;

  //+---------------------------------+
  //| Hide all current edit controls. |
  //+---------------------------------+
  for ( int i=0; i < (int)vEditControls.size(); i++ )
    ShowWindow( vEditControls, SW_HIDE ) ;

  //+--------------------------------------+
  //| Determine the text of the new tab.   |
  //+--------------------------------------+
  TCHAR szTabName[30] ;
  wsprintf( szTabName, TEXT("Tab %d"), vEditControls.size() ) ;

  //+------------------------------------------------------------+
  //| Insert a new tab by filling in a TCITEM object and sending |
  //| the TCM_INSERTITEM message or using the TabCtrl_InsertItem |
  //| macro.                                                     |
  //+------------------------------------------------------------+
  TCITEM tcitem ;
  tcitem.pszText = szTabName ;
  tcitem.mask    = TCIF_TEXT ;       // The pszText member is valid.
  TabCtrl_InsertItem( hwndTab, vEditControls.size(), &tcitem ) ;

  //+--------------------------+
  //| Select the new tab page. |
  //+--------------------------+
  TabCtrl_SetCurSel( hwndTab, vEditControls.size() ) ;

  //+------------------------------------------------------------------+
  //| Create a new edit control, set its font, and add it to the list. |
  //+------------------------------------------------------------------+
  HWND hwndEditNew = CreateEditControl( hwndParent, rcDisplay.left,
                                        rcDisplay.top,
                                        rcDisplay.right - rcDisplay.left,
                                        rcDisplay.bottom - rcDisplay.top ) ;
  SetDefaultGuiFont( hwndEditNew, FALSE ) ;
  vEditControls.push_back( hwndEditNew ) ;
  
 }

how would I make 16 of these?

Share this post


Link to post
Share on other sites
Advertisement
the code makes tabs and ataches a edit window to each tab. the way it stands now I have to click a button to make a tab. I just want 16 tabs to start so in the above code some hoe I need to have it just creat 16 tabs instead of having it only creaet when a button is hit

Share this post


Link to post
Share on other sites
Um, you have code that adds something to a vector, and it gets called when a button is clicked, and you want to start out with 16?

Uh... why not just call the function directly yourself first, 16 times (in a loop)?

Share this post


Link to post
Share on other sites
whats funny is I tryed that but for some reason it did not achive the affect I wanted it just made a tab named 16 not 16 tabs unless I made my loop wrong

this is what I did
for (int i = 0;i <15;)
{
AddNewPage( hwnd, hwndTab ) ;
}

but it did not work

Share this post


Link to post
Share on other sites
ya I just forgot to post it. It is in the code. Thanks for pointing that out.

Share this post


Link to post
Share on other sites
well I found that link to. But I was not smart enogh to figure it all out. I got it to make tabs but I can add anything to the tabs. Not sure. If you could help me figure it out I would be most apertitive

Share this post


Link to post
Share on other sites
In the loop are you passing the same HWND for each tab...do you need a new window handle for each tab?

Sorry don't really use WIN32, so is just a guess.

Share this post


Link to post
Share on other sites
no it is just one HWND for all the tabs.

does any one have any examples using tabs?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement