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 ) ;
}
need help with adding to a vector
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
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)?
Uh... why not just call the function directly yourself first, 16 times (in a loop)?
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
this is what I did
for (int i = 0;i <15;)
{
AddNewPage( hwnd, hwndTab ) ;
}
but it did not work
for (int i = 0; i < 16; i++)
You forgot the part of the for loop where you increment the counter...
You forgot the part of the for loop where you increment the counter...
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
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.
Sorry don't really use WIN32, so is just a guess.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement