如何在TXT文件中保存文本框的X,Y坐标,高度和宽度? [英] ?How to save X,Y-Coordinates, Height and Width of Textbox in TXT-File?

查看:122
本文介绍了如何在TXT文件中保存文本框的X,Y坐标,高度和宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好:),

我是绝对的初学者":confused:

有谁知道如何在TXT文件中保存X,Y坐标,文本字段的高度和宽度?
我创建了一个自己的文本编辑器,在其中放置了2-3个(图形框架)和2-3个文本框.

预先感谢您

亚历山大

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

推荐答案

亚历山大,
如果要保存特定文本字段的X,Y坐标,高度和宽度,请尝试以下操作:
Hi Alexander,
If you want to save X,Y-Coordinates, Height and Width of Specific Textfields then try with following:
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();
}


这应该有用:

http://www.functionx.com/cpp/articles/filestreaming.htm [ ^

:)
This should be of use:

http://www.functionx.com/cpp/articles/filestreaming.htm[^

:)


这篇关于如何在TXT文件中保存文本框的X,Y坐标,高度和宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆