Dynamically add tabs?

Hi, I'm developing a gui using the win32 API in c++ with visual studios. I was wondering if anybody can help me.

On my window i have a button which when pressed, the typical open file dialog is displayed for a user to select a text file to open. When the user has selected a file to open, I want a new tab to be added my tab control and to display the text file which was selected by the user.

I'm struggling with how I can do this and would greatly appreciate any help with this.
It's all out there in MSDN. See http://msdn.microsoft.com/en-us/library/bb760550(VS.85).aspx for an overview and links to the full reference. What you need to do is prepare a TCITEM structure and then call the TabCtrl_InsertItem() macro (http://msdn.microsoft.com/en-us/library/bb760678(VS.85).aspx ).
Yeah but once I add the tab items, how do I switch between the views for each window?

I don't know if it's something obvious staring me in the face, but i have no idea how to do it when i don't know how many tabs there are going to be at any given time. I can do it when i know how many tabs are going to be open, then i can just code which window to show depending on which tab clicked, but I'm unsure of how to do this when there isn't a definitive number of tabs.
The TabCtrl_SetCurSel() macro selects a specific tab by index. If you want to know how many tabs are there, use the TabCtrl_GetItemCount() macro.
That's what the lParam member of the TCITEM struct is for; to associate data with a tab. It could be set to a pointer to the filename of a text document, for example.
Topic archived. No new replies allowed.