?
Solved

Programatically adding edit controls to CTabCtrl

Posted on 1998-08-16
7
Medium Priority
?
534 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
  • 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
Technology Partners: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

862 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