?
Solved

Programatically adding edit controls to CTabCtrl

Posted on 1998-08-16
7
Medium Priority
?
521 Views
Last Modified: 2013-11-20
I am trying to add CEdits to a CTabCtrl at run time.  

I have put this code in the OnInitDialog() function.

TC_ITEM local;
local.mask = TCIF_TEXT;          
local.pszText = "Untitled";        
m_TabCtrl.InsertItem(1,&local);

RECT wookie;
RECT* pwookie = &wookie;
m_TabCtrl.GetItemRect(1, pwookie);

    CWnd *myWnd = new CWnd();
      CEdit *ETerm = new CEdit;

myWnd->Create(NULL, "AviWindow", WS_VISIBLE | WS_CHILD,wookie,
    AfxGetMainWnd(),NULL,NULL);
 

    myWnd->ShowWindow(SW_SHOWNORMAL);

ETerm->Create(WS_VISIBLE | ES_LEFT | ES_MULTILINE | ES_WANTRETURN, WindowRect, myWnd,1234);

The code is supposed to add a tab to an exisiting tab control and add an edit control to the tab area.  It adds the tab fine, but the edit control does not show up.

Thanks.
0
Comment
Question by:Jothanin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 3

Expert Comment

by:Norbert
ID: 1320895
Only a shot in the dark:
Is the Setup for WindowRect right?
did you try to swap the ShowWindow line and the create line?
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1320896
Not tried the code, but one obvious error is you missed out WS_CHILD from the edit control styles (line beginning ETerm->Create)
0
 

Author Comment

by:Jothanin
ID: 1320897
Answer 2000 - Good point, I did miss the WS_CHILD, thanks for pointing it out.  But it                       doesn't help me make the edit control show up.

Norbert - I tried swapping them and it didn't change anything.   WindowRect should really be wookie as well.  I was just trying some stuff out and I forgot to change it back.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:rlarner
ID: 1320898
If you only have that tab control and it's associated windows in the dialog, you may want to try using a property sheet (CPropertySheet) instead -- it has a much nicer interface than CTabCtrl.
0
 
LVL 1

Expert Comment

by:rlarner
ID: 1320899
If you only have that tab control and it's associated windows in the dialog, you may want to try using a property sheet (CPropertySheet) instead -- it has a much nicer interface than CTabCtrl.
0
 

Author Comment

by:Jothanin
ID: 1320900
Also, does anyone know how I can hide/show an edit box after it has been created.
0
 
LVL 3

Accepted Solution

by:
Norbert earned 40 total points
ID: 1320901
The CTabCtrl is Zerobased therefore maybe the index for the first element you add should be 0.
did you check the rectangle ? if m_TabCtrl.GetItemRect(1, pwookie) fails the rect is not ok. and the Box will probably be outside

>>Also, does anyone know how I can hide/show an edit box after it has been created.
A CEditBox is derived from CWnd so you can use a edit box like a CWnd to make it Visible/Invisible you can call
pYourEditBox->ShowWindow(SW_SHOW) and  
pYourEditBox->ShowWindow(SW_HIDE)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question