如题.
还有就是从一个Edit中取得一个字符串,怎么把它转换成整型?
还有就是从一个Edit中取得一个字符串,怎么把它转换成整型?
解决方案 »
- VC6工程向导里面的Utility project到底是干什么用的,这种工程是用来生成什么东西的?
- 在vs2008中添加一个IDispatch的借口
- 请教如何得到指定进程和网络通信的数据包和阻止指定IP的数据包呢?
- 系统启动的时候,三个地方可以实现自启动,那个地方会比较快啊
- [求助]一个文件操作的问题
- 关天链表的问题
- 为什么会这样。。。用DeviceIoControl没有结果返回(2000下读硬盘序列号)
- Direct3D简单问题请教!
- 关于ADO,记录集生存期的问题!
- 如何一次从注册表中读出几个简直
- 大虾请进!为何我在VB中调用自己用VC写的一个DLL总是不成功?
- 请教各位,关于控件的问题!
m_Edit.Create(ES_LEFT|ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP ,rect,this,IDC_EDIT);
m_Edit.ShowWindow(SW_SHOW);
CString str;
GetDlgItemText(IDC_EDIT,str);
int i=atoi(str);
This method creates the Windows CE edit control and attaches it to the CEdit object.To construct a CEdit object, call the CEdit constructor, then call Create. BOOL Create(
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID );
Parameters
dwStyle
Specifies the style of an edit control style. Apply any combination of edit styles to the control.
rect
Specifies the size and position of an edit control. Can be a CRect object or RECT structure.
pParentWnd
Specifies the parent window of an edit control usually a CDialog. It must not be NULL.
nID
Specifies the identifier of the edit control.
Return Value
Nonzero if initialization is successful; otherwise, it is zero.
int i;
atoi(str);
CEdit *m_edit = new CEdit;m_edit->Create(ES_LEFT|ES_AUTOVSCROLL, CRect(0,0,200,200),this, 500/*自定义ID*/);最后用完就 delete m_edit; 就可以了, 是分别的三句话,放在合适位置。
取字符串简单,
CString str;
m_edit->GetWindowText(str);
int aaa = atoi(str); aaa 就是转出来的整数了。
m_wndEdit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_MULTILINE|ES_WANTRETURN,CRect(0,0,100,02),this,101);
this为父窗口指针,101为ID号,可根据实际代码修改。
int nTemp = atoi(m_strEdit.GetBuffer(0))
m_strEdit为字符串
In yout InitDiloag()
...
#ifdef IDC_EDIT_NEW1
#define IDC_EDIT_NEW1 10011
#endifm_pEdit = new CEdit;
m_pEdit->Create(SW_SHOW|SW_CHILD|SW_VISIBLE, CRect(5, 5, 15, 100), this, IDC_EDIT_NEW1);char sz[255];
((CEdit *)GetDlgItem(IDC_EDIT))->GetWindowText(sz, 255);int n = ::atoi(sz);
不要直接用atoi()函数进行转换。atoi()存在安全隐患。比如“aaa"用atoi()进行转换为0。
用sscanf()进行转换。
CRect r(1,1,50,50);
CEdit edit;
edit.Create(ES_LEFT|ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP ,
r,this,IDC_EDIT);
edit.ShowWindow(SW_SHOW);