Link to home
Start Free TrialLog in
Avatar of tcf22
tcf22

asked on

Forcing Read-only text field to the right

I have an MFC text box that contains a file path. I'm running short on screen real estate, and the text box is smaller than the path. I want to have the text box display the end of the filepath instead of the beginning. Is there an easy way to do this?
Avatar of Member_2_1001466
Member_2_1001466

You need to change it to ownerdrawn. Then you can test the size of the full string and display only the right hand part.  
You can send a WM_SETSEL message to the control passing position of last character. Something like:

CString text = "c:\\your main folder\\your subfolder\\additional folder\\the file.txt";

yourControl.SetWindowText(text);
yourControl.SetSel(text.GetLenght(), text.GetLenght());

ASKER CERTIFIED SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Correction:

void CTestDlgDlg::ShowFilePath(const CString& strPath, UINT idcEdit)
{
     CWnd*     pEdit = GetDlgItem(idcEdit);
     ...


Regards, Alex