Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Creating and using Tab controls in the windows api

This topic is 5730 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

Hi Ive been trying to create a working tab control using the winapi all day, and ive got pretty much nowhere. The only website i can find on them is the msdn one. But ive had alot of trouble trying to get the example they give to work correctly. I think the problem lies with creating resource templates, in that im not 100% sure how to do it. So if any1 has experience with the example on the msdn website ( in particular the one relating to tab controls on a dialog box), then id be greatful of some advice on how to create dialog templates. Or if anyone has some sample code which they have written, which uses tab controls on a dialog box (however messy) using the windows api (not mfc please) then id also be greatful if the can post a link to it or email it to me Also if anyone has a good tutorial about tab controls in the winapi it would be good if you could post some links Thx

Share this post

Link to post
Share on other sites
I don't know the msdn sample, however, to create a tab control:

#include <commctrl.h>

link with comctl32.lib

call InitCommonControls() somewhere before creating the dialog

in the WM_INITDIALOG message case:


// execute this code to add a tab page
Item.mask = TCIF_TEXT;
Item.pszText = "Tab";

you receive a WM_NOTIFY message with notify code TCN_SELCHANGE, when another page is selected, and than you should redraw the content of the tab page, or just show and hide other child windows, with the right controls in it.

hope this helps

My Site

[edited by - Quasar3D on April 4, 2003 5:20:21 AM]

Share this post

Link to post
Share on other sites
Thx for the reply .

The drawing and redrawing of the child dialog box is the main bit ive been having trouble with

Could you please explain how to do that in a bit more detail


Share this post

Link to post
Share on other sites
You have the dialog with the tab control in it, and for every page, you create another dialog, without a border (select none in the border list, and in the style list you should select child. Now you create such a dialog for every page.

now in the message proc for the dialog:

HWND hTabPages[5]; // this should be a global, or static

hTabPages[0] = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_PAGE1),hWnd,(DLGPROC)Tab1Proc);
hTabPages[1] = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_PAGE2),hWnd,(DLGPROC)Tab2Proc);



and when another page is selected, you hide and show other pages:

// in the message proc of the dialog
pNotify = (NMHDR*)lParam;
if(wParam == IDC_OBJTAB && pNotify->code == TCN_SELCHANGE)
for(int i = 0;i<5;i++)
ShowWindow(hTabPages[ i ],SW_HIDE); // hide all pages

int CurTab = SendMessage(pNotify->hwndFrom,TCM_GETCURSEL,0,0);
ShowWindow(hTabPages[CurTab],SW_SHOWNORMAL); // show the right page


My Site

[edited by - Quasar3D on April 5, 2003 3:42:14 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!