Click here to Skip to main content
15,895,423 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello there :) ,

I'm an "Absolut Beginner":confused:

Does anyone know, how to save X,Y-Coordinates, Height and Width of Textfields in a TXT-File?
I've created an own Text Editor in where I place 2-3 (graphic-)Frames and 2-3 Textboxes .

Thank You in Advance

Alexander
Posted
Comments
Henry Minute 16-Feb-11 17:10pm    
It might help people to give you the most accurate answer if you edit your question to say if it is Managed or Unmanaged C++, if you know. :)

Hi Alexander,
If you want to save X,Y-Coordinates, Height and Width of Specific Textfields then try with following:
C++
CRect rcRect;
char strTmp[6];
CString strCord("TextBox1 :");

// Point to specified EditBox
CEdit *pWnd= (CEdit *)GetDlgItem(IDC_EDIT1); //Id of Edit Control
pWnd->GetClientRect(rcRect);
pWnd->ClientToScreen(rcRect);

// Build String for saving Coordinates into txt file
sprintf(strTmp," X=%d,",rcRect.left);
strCord += strTmp ;
sprintf(strTmp," Y=%d,",rcRect.top);
strCord += strTmp ;
sprintf(strTmp," H=%d,",rcRect.right);
strCord += strTmp ;
sprintf(strTmp," W=%d,",rcRect.bottom);
strCord += strTmp ;

// Save Coordinates into txt file
CFile DataEntry;
DataEntry.Open("C:\\DataEntry.txt",CFile::modeCreate |CFile::modeWrite);
DataEntry.Write(strCord,strCord.GetLength());
DataEntry.Close();

And if u want to save all Textfields the try with following

Wnd *pWnd = GetWindow(GW_CHILD);
char strControl[20];

while(pWnd)
{
   ::GetClassName(ped->GetSafeHwnd(),strControl,20);
   if (!strcmpi(strControl,"Edit") )
   {
      // Above logic will go here....
   }
   pWnd = pWnd->GetNextWindow();
}
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900