Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Programatically adding edit controls to CTabCtrl

Posted on 1998-08-16
7
Medium Priority
?
529 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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: 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: 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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 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