Prob with tabctrl
Hello,
I am trying to create a dialog with tabbed control.
I have written this code in (OnInitDialog())
CTabCtrl tab;
RECT rect;
rect.left = 10;
rect.top = 10;
rect.right =20;
rect.bottom = 20;
tab.Create(TCS_FIXEDWIDTH|WS_CHILD|WS_VISIBLE|WS_TABSTOP,rect,this,100);
tab.ShowWindow(SW_SHOWNORMAL);
But the tabbed control is not displayed.
Can anyone help me.
thnx
swetha
# 1 Re: Prob with tabctrl
But the tabbed control is not displayed.You are creating your CTabCtrl instance locally, on the stack. When it goes out of scope (after OnInitDialog is left), it will be automatically deleted, destroying the wrapped tab control. So you shold declare it as a class member of your dialog class, and not as a local variable.
Besides that: Why are you trying to create the tab control dynamically? Wouldn't it be easier in the dialog resource editor?
Also, note that there's an MFC class CRect, that wraps the RECT structure: It is way easier to use and initialize than RECT.