终于看出来你的m_ShowInfor是什么东西,原来是一个CEdit,真不好猜哦! void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE ); 功能:Call this function to select a range of characters in an edit control 调用此函数能在EDIT Control中选择某范围的字符串参数 nStartChar Specifies the starting position. If nStartChar is 0 and nEndChar is –1, all the text in the edit control is selected. If nStartChar is –1, any current selection is removed. 指定开始位置,如果nStartChar 为0并且nEndChar 为-1,则选择所有文字,如果nStartChar 为-1,则不选择任何文字nEndCharSpecifies the ending position. 指定结束位置ResCall this function to select a range of characters in an edit control.For more information, seeEM_SETSEL in the Win32 documentation. 帮你大概翻译一下
void ReplaceSel( LPCTSTR lpszNewText, BOOL bCanUndo = FALSE );Parameters 参数lpszNewTextPoints to a null-terminated string containing the replacement text. 替换的文字 bCanUndoTo specify that this function can be undone, set the value of this parameter to TRUE . The default value is FALSE. 如果此选项为TRUE,则用户可按Ctrl+Z取消此操作 ResCall this function to replace the current selection in an edit control with the text specified by lpszNewText. Replaces only a portion of the text in an edit control. If you want to replace all of the text, use the CWnd::SetWindowText member function. If there is no current selection, the replacement text is inserted at the current cursor location.功能:把所选文字替换成lpszNewText的文字
看函数名,看得出。
m_ShowInfor.SetSel(-1, -1);//这样可能是全选,也可能是全不选
第一个参数是从第几个记录开始选择,第二个参数是选择到第几个项目,例如m_ShowInfor.SetSel(0, 100);则会把第0~100条记录选上
m_ShowInfor.ReplaceSel(w_str);
应该是把当前选择的项目的字符串替换成w_str的值
void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE );
功能:Call this function to select a range of characters in an edit control
调用此函数能在EDIT Control中选择某范围的字符串参数
nStartChar
Specifies the starting position. If nStartChar is 0 and nEndChar is –1, all the text in the edit control is selected. If nStartChar is –1, any current selection is removed.
指定开始位置,如果nStartChar 为0并且nEndChar 为-1,则选择所有文字,如果nStartChar 为-1,则不选择任何文字nEndCharSpecifies the ending position.
指定结束位置ResCall this function to select a range of characters in an edit control.For more information, seeEM_SETSEL in the Win32 documentation.
帮你大概翻译一下
参数lpszNewTextPoints to a null-terminated string containing the replacement text.
替换的文字
bCanUndoTo specify that this function can be undone, set the value of this parameter to TRUE . The default value is FALSE.
如果此选项为TRUE,则用户可按Ctrl+Z取消此操作
ResCall this function to replace the current selection in an edit control with the text specified by lpszNewText. Replaces only a portion of the text in an edit control. If you want to replace all of the text, use the CWnd::SetWindowText member function. If there is no current selection, the replacement text is inserted at the current cursor location.功能:把所选文字替换成lpszNewText的文字
[email protected]
m_ShowInfor.SetSel(-1, -1);//这样可能是全选,也可能是全不选
终于看出来你的m_ShowInfor是什么东西,原来是一个CEdit,真不好猜哦!晕
m_ShowInfor除了CEdit或者CRichEdit以外还有其他的类的对象?m_ShowInfor.SetSel(-1, -1);//选择最末尾。。
m_ShowInfor.SetSel(0, -1);//选择全部
1,【, BOOL bCanUndo = FALSE】可以缺省吗。为什么?
2,m_ShowInfor.ReplaceSel(w_title)不是应该有两个参数吗?
3,ReplaceSel是否和SetSel配对使用?
4,void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE );
SetSel也有三个参数,为什么可以用两个?
我刚接触vc,多谢了!!!!
{ // TODO: Add your control notification handler code here
m_ShowInfor.SetWindowText("");
CString NodeInfor;
char w_title[100];
char w_str[500];
char w_eol[3] = {0x0d,0x0a,0}; Stud *p_out;
p_out=p_head;
int i=0;
if (p_head!=NULL) //add the title for the NodeLink
sprintf(w_title, "%5s%15s%15s", "NodeNo.","Number","Name");
strcat(w_title, w_eol);
m_ShowInfor.SetSel(-1, -1);
m_ShowInfor.ReplaceSel(w_title);
do
{
i++;
sprintf(w_str, "%5i %20i %15s",i,p_out->num,p_out->name);
strcat(w_str, w_eol);
m_ShowInfor.SetSel(-1, -1);
m_ShowInfor.ReplaceSel(w_str);
p_out=p_out->next;
}
while(p_out!=NULL);}能否解释一下sprintf(w_title, "%5s%15s%15s", "NodeNo.","Number","Name");
《sprintf》的具体用法?