just declare in the header
in the .h file
Code:
CStatic txtFileName;
in the .cpp file for the window
#define ID_FILENAME 101
....::OnCreate(.....)
{
txtFileName.Create( sText, dwStyle, rect, this, ID_FILENAME );
.....
}
....::SetFileName( CString strFilename )
{
CDC* pdc = txtFileName.GetDC();
CSize size = pdc->GetTextExtent( strFilename );
CRect r;
txtFileName.GetWindowRect( &r );
int area1 = r.Width() * r.Height();
int area2 = size.cx * size.cy;
if( r.Width() < size.cx && area1 < area2 + size.cy )
{
//resize the window
txtFileName.SetWindowPos(NULL, 0, 0, r.Height() + size.cy, SWP_NOMOVE | SWP_NOZORDER);
}
txtFileName.SetWindowText( strFileName );
}
I have not tested the above code but with some fine tuning it will work....