Solved

Programatically adding edit controls to CTabCtrl

Posted on 1998-08-16
7
461 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now