📄 subject_20985.htm
字号:
<p>
序号:20985 发表者:longren 发表日期:2002-11-12 18:33:41
<br>主题:特别简单的问题
<br>内容:现在我要在单文档中显示时间,代码如下,这二行代码应该加到什么地方,还需要添加什么的。假如我是建立的是一个对话框呢,对话框上有一个编辑控件,我要时间显示在编辑框中,怎么搞啊,照别人的程序敲了这么久的,这么小的问题,还是不会啊。<BR>COleDateTime myTime = COleDateTime::GetCurrentTime();<BR>CString strTime = myTime.Format(_T("%Y-%m-%d %H:%M:%S"));
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:Guns & Roses 回复日期:2002-11-12 19:06:53
<br>内容:BOOL SetWindowText(<BR> HWND hWnd, // handle to window or control<BR> LPCTSTR lpString // title or text<BR>);<BR>函数可以做到。hWnd:控件的句柄;lpString:是要设置的文本;<BR>这是一个Win32函数.<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:longren 回复日期:2002-11-12 19:27:20
<br>内容:那么这个句柄是文档吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:树爱兵 回复日期:2002-11-12 19:58:23
<br>内容:<BR>在对话框如下:<BR>void Timedlg::OnTimer(UINT nIDEvent) <BR>{<BR> // TODO: Add your message handler code here and/or call default<BR> <BR> CTime time;<BR> time=CTime::GetCurrentTime(); //得到当前时间;<BR><BR> <BR> CString s=time.Format("%H:%M:%S"); //转换时间格式<BR> m_nedit1=s; //m_edit1为edit控件变量<BR> <BR> UpdateData(FALSE);<BR> CDialog::OnTimer(nIDEvent);<BR>}<BR><BR>在initdialog 中设置<BR><BR>BOOL Timedlg::OnInitDialog() <BR>{<BR> CDialog::OnInitDialog();<BR> SetTimer(1,1000,NULL);<BR> return TRUE; <BR><BR>}<BR><BR><BR>void Timedlg::OnClose() <BR>{<BR> <BR> KillTimer(1); <BR> CDialog::OnClose();<BR>}<BR><BR>------------------------------------------------------------------------<BR>置于单问档<BR>可这样在Ondraw()函数中<BR><BR>COleDateTime myTime = COleDateTime::GetCurrentTime();<BR>CString strTime = myTime.Format(_T("%Y-%m-%d %H:%M:%S")); <BR>pDC->TextOut(100,100,strTime);
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Guns & Roses 回复日期:2002-11-12 20:28:04
<br>内容:hWnd:是编辑控件的句柄。<BR>lpString:是要设置的文本字符串的指针;
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:longren 回复日期:2002-11-12 21:56:23
<br>内容:非常感谢树爱兵的详细解答。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -