Solved

Programatically adding edit controls to CTabCtrl

Posted on 1998-08-16
7
485 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 20 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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