Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to create a runtime edit boxes erasing previously created edit boxes at client area?

Posted on 2002-07-04
5
Medium Priority
?
181 Views
Last Modified: 2013-11-20
In a dialog based application, onclick button1 i should generate dynamically three edit boxes, and onclick button2  previous edit boxes should vanish and new set of four edit boxes should appear.(i.e. client area should be erased on onclick button2 and new sizes of edit boxes should appear dynamically). if any one knows please send me sample program.
thanks
0
Comment
Question by:ravi_pvkumar
[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
5 Comments
 
LVL 8

Accepted Solution

by:
VinExpert earned 75 total points
ID: 7131462
Hi,

Solution is simple.

1. Have the CEdit pointers in the .h file of ur dialog class in the public section

//I am taking 2 pointers here for easy understanding
CEdit *pEdit1;
CEdit *pEdit2;

2. Have rectangles of each edit control u want to display also

CRect m_cRect1;
CRect m_cRect2;

3. In the constructor U intialize them to NULL and set the rect sizes

pEdit1 = NULL;
pEdit2 = NULL;

//Fill in m_cRect1 and m_cRect2 here
//...

4. Now, on click on button 1, u execute the follwing code

void Cddddlg::OnButton1()
{
//Delete the old set if any
if(pEdit2)
{
delete pEdit2;
pEdit2 = NULL;
}

pEdit1 = new CEdit;
pEdit1->Create(WS_CHILD|WS_BORDER|WS_TABSTOP|ES_LEFT, m_cRect1, this, 100);
pEdit1->ShowWindow(SW_SHOW);
}

void Cddddlg::OnButton1()
{
//Delete the old set if any
if(pEdit1)
{
delete pEdit1;
pEdit1 = NULL;
}

pEdit2 = new CEdit;
pEdit2->Create(WS_CHILD|WS_BORDER|WS_TABSTOP|ES_LEFT, m_cRect2, this, 101);
pEdit2->ShowWindow(SW_SHOW);
}

That should give u the idea on how to go abt it.

Try it out.
VinExpert
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 7131465
Ooops, second function name should be void Cddddlg::OnButton2()

VinExpert
0
 
LVL 4

Assisted Solution

by:mblat
mblat earned 75 total points
ID: 7133052
Or one can hide/show edit boxes after appropriate clicks.

Like this

CMyDlg:OnButton1()
{
    ShowFirstTreeEditBoxes(TRUE);
}

CMyDlg:OnButton1()
{
        ShowFirstTreeEditBoxes(FALSE);
}

CMyDlg::ShowFirstTreeEditBoxes(BOOl bFlag)
{
// first 3 boxes
GetDlgItem(IDC_EDIT1)->ShowWindow(bFlag ? SW_SHOW : SW_HIDE);
GetDlgItem(IDC_EDIT2)->ShowWindow(bFlag ? SW_SHOW : SW_HIDE);
GetDlgItem(IDC_EDIT3)->ShowWindow(bFlag ? SW_SHOW : SW_HIDE);
// other 4
GetDlgItem(IDC_EDIT4)->ShowWindow(!bFlag ? SW_SHOW : SW_HIDE);
GetDlgItem(IDC_EDIT5)->ShowWindow(!bFlag ? SW_SHOW : SW_HIDE);
GetDlgItem(IDC_EDIT6)->ShowWindow(!bFlag ? SW_SHOW : SW_HIDE);
GetDlgItem(IDC_EDIT7)->ShowWindow(!bFlag ? SW_SHOW : SW_HIDE);
}

Then one doesn't need to mess with on-screen coordiates - they set in resource editor.

Hope it helps...
0

Featured Post

Independent Software Vendors: 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

715 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