在视图类的鼠标移动事件中如何获取鼠标移动事件创建的时间?

xqlu2007 2011-12-23 11:56:20
我知道MSG结构中有一个时间字段,但鼠标移动事件中如何获取鼠标移动事件创建的时间?下面函数原型中根本就没有事件创建时间的参数.
void CMyView::OnMouseMove(UINT nFlags, CPoint point)
{
……
如何获取鼠标移动事件创建的时间?
……
}
...全文
64 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xqlu2007 2011-12-24
  • 打赏
  • 举报
回复
LONG x=GetMessageTime();
语句中的x是LONG型,如何从它求出年月日时分秒值,能求毫秒吗?
xqlu2007 2011-12-24
  • 打赏
  • 举报
回复
刚才我自己的回复有错,取消,别耽误大家时间
xqlu2007 2011-12-24
  • 打赏
  • 举报
回复
前面几位的回答我用下面的方法试过了:
CTime t=GetCurrentTime();
Sleep(3000);
LONG x=GetMessageTime();
结果显示是一样的,说明两种方法得到的时间是一样的.

然后我运行程序时把系统时间打开(屏幕右下角双击)
再看着秒针来运行程序,比如秒针指到50秒时单击,结果显示的两个都是53秒,也就是说第一次获得的时间是我单击后系统休眠3秒后才得到的,但事实上我是先取时间再休眠的,真的很奇怪!!
如果我把sleep语句去掉,结果两个时间都与我单击时的时间一致.
请大家再分析一下!!
adhua198 2011-12-23
  • 打赏
  • 举报
回复
CTime::GetCurrentTime()获取系统当前时间,然后format成你想要显示的时间格式的字符串
hping1016 2011-12-23
  • 打赏
  • 举报
回复
或者
GetMessageTime
The GetMessageTime function retrieves the message time for the last message retrieved by the GetMessage function. The time is a long integer that specifies the elapsed time, in milliseconds, from the time the system was started to the time the message was created (that is, placed in the thread's message queue).
hping1016 2011-12-23
  • 打赏
  • 举报
回复
MSG msg;
GetMessage(&msg, NULL, 0, 0)

===========================================================================
MSG Structure

--------------------------------------------------------------------------------

The MSG structure contains message information from a thread's message queue.

Syntax

typedef struct {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG, *PMSG;
Members

hwnd
Handle to the window whose window procedure receives the message.
message
Specifies the message identifier. Applications can only use the low word; the high word is reserved by the system.
wParam
Specifies additional information about the message. The exact meaning depends on the value of the message member.
lParam
Specifies additional information about the message. The exact meaning depends on the value of the message member.
time
Specifies the time at which the message was posted.
pt
Specifies the cursor position, in screen coordinates, when the message was posted.
yayafu 2011-12-23
  • 打赏
  • 举报
回复
CTime::GetCurrentTime()就是时间啊
shen_wei 2011-12-23
  • 打赏
  • 举报
回复
CTime ::GetCurrentTime() 用这个来获取时间
夫人的泡泡鱼 2011-12-23
  • 打赏
  • 举报
回复
需要时间精确吗?可以在获得鼠标事件中GetCurrentTime()

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧