Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you clear a screen?

Status
Not open for further replies.

real

Programmer
Jan 20, 2001
15
US
i have 5 edit boxes that need to be cleared. 3 of them i can clear but i can not figure out how to clear the other 2.

these i can clear:
_sFirstName = "";
_sLastname = "";
_sTotalPay = "";

UpdateData(FALSE);

these i cannot:
_nPayRate
_nHrsWrkd

charles

 
The SetWindowText function could probably be used to accomplish this. If you use Class Wizard to associate a CEdit control with each edit box, you should be able to do something like this:

_editPayRate.SetWindowText( "" );
_editHrsWrkd.SetWindowText( "" );

assuming, of course, that your edit controls were named _editPayRate and _editHrsWrkd.

You can read about SetWindowText at


An alternative method is to use the SetSel and Clear functions of the CEdit class:
_editPayRate.SetSel( 0, -1 );
_editPayRate.Clear( );

For info on this, please see

 
aiight, the code i have for the _nPayRate and the _nHrsWrkd is :

_sTotalPay.Format( "%9.2f", _nHrsWrkd * _nPayRate);

and to clear the screen i have:

void CTimeCardDlg::OnClrmsg()
{

// Clear the message
_sFirstname = "";
_sLastName = "";
_sTotalPay = "";

// Update the screen
UpdateData(FALSE);
}

but when i type to try and clear the other two _n's it doesnt work. can ne1 tell me what im doing wrong?

 
The variables you're working with are "value" variables and what you need are "control" variables. Under the variables tab of the ClassWizard, add two more variables for each of your edit boxes, only this time select "control" in the first combo box. Then to clear them you do this (assuming that your control variables are called _wndPayRate and _wndHrsWrkd):
Code:
...
UpdateData(FALSE);
_wndPayRate.SetWindowText("");
_wndHrsWrkd.SetWindowText("");

An alternative to creating control variables is this (assuming your control IDs are IDC_PAYRATE and IDC_HRSWRKD):
Code:
...
UpdateData(FALSE);
GetDlgItem(IDC_PAYRATE)->SetWindowText("");
GetDlgItem(IDC_HRSWRKD)->SetWindowText("");

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top