Click to See Complete Forum and Search --> : Passing the address of a textbox


gfr1
July 18th, 2005, 08:49 AM
The routine below gets the address of the Edit box that currently has focus and passes that information to a function that checks to see if the text in the control is in the correct format i.e. time(##:##:##.###) This works in MFC how can I do the same thing in a .NET Forms app.

void CConvertDlg::CheckFormat(CString &buff, const int &type)
{
// This functions gets get the address of the current edit box and
// passes that information on to timeformat a libaray routinewhich checks for
// correct format

CWnd *pWnd;
CEdit *Edit;
int id;

pWnd = GetFocus();
id = pWnd->GetDlgCtrlID();
Edit = (CEdit*)GetDlgItem(id);
TimeFormat(Edit,buff,type);
UpdateData(FALSE);
}

NoHero
July 18th, 2005, 10:46 AM
Check the following example: Using .NET regular expressions to create an masked edit control. (http://msdn.microsoft.com/vcsharp/downloads/samples/23samples/)

Andy Tacker
July 19th, 2005, 05:12 AM
NoHero's given a good link...

simply, you create a function and instead to CEdit* you pass TextBox type to function and in return you can set Boolean return value.

if(TimeFormat(myTextBox))
GoDoMoreWork();
else
ShowErrorMessage();