C++systreeview32 ,怎么 知道点击的哪个节点,并根据点击的节点响应不同的事件....

莫名其妙的人参果 2016-11-08 05:48:34
[/img]
BOOL OnclickTree(NMHDR* pNMHDR)
{
POINT point;
TVHITTESTINFO thti;
HTREEITEM htItem;
GetCursorPos(&point);
ScreenToClient(hwndTreeView, &point);
thti.pt = point;
thti.flags = TVHT_TORIGHT;
htItem = TreeView_HitTest(hwndTreeView, &thti);
if (htItem != NULL)
{

ClientToScreen(hwndTreeView, &point);
TreeView_SelectItem(hwndTreeView, htItem);
/*
int i=TreeView_GetItem(hwndTreeView, htItem);
switch (i)
{
case 1:ShowTextOnEdit("1");
break;
case 0:ShowTextOnEdit("0");
break;
case 2:ShowTextOnEdit("2");
break;
case 3:ShowTextOnEdit("3");
break;
case 4:ShowTextOnEdit("4");
break;
default:ShowTextOnEdit("6");
break;
}
*/
return TRUE;
}
return FALSE;
}

我的目的是通过switch (i) 知道我左键单击了哪个节点...但是现在得到的i,基本是0偶尔一个1,然后还有问题就是点着点着内存出错...就失去响应了...注释掉这部分后 随意点...不会出错。
求问怎么 知道点击的哪个节点.....其他方法也行,,, 没用MFC....
TreeView_GetItem(hwndTreeView, htItem); 是这句的问题,只留下这句点着点着就出错了。。。。
...全文
215 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2016-11-09
  • 打赏
  • 举报
回复
赵4老师 2016-11-08
  • 打赏
  • 举报
回复
Setting a Breakpoint on a Message Received by a Windows Function You can set message breakpoints to stop the debugger when a particular WndProc function message is received. Note Message breakpoints work only on x86- or Pentium-based systems. To set a breakpoint on a message From the Edit menu, click Breakpoints. The Breakpoints dialog box appears. Click the Messages tab. In the Break At WndProc text box, type the name of the Windows function. If you are setting a breakpoint during a debug session, the list contains the exported functions in your project. In the Set One Breakpoint For Each Message To Watch list box, select the message. To set another breakpoint, press ENTER, and then repeat steps 3 and 4. The Breakpoints list displays the currently active breakpoints. Click OK to set the breakpoints. Note If you interrupt execution while Windows or other system code is running, the results can be unpredictable.
  • 打赏
  • 举报
回复
第一个图片搞错了 ,有红圈那个图上错了,是第二个图片才是有用的
  • 打赏
  • 举报
回复
引用 4 楼 zhao4zhong1 的回复:
我只是提醒你可以针对某个窗口的某条消息设置断点而已。
恩 谢谢了,我还是结贴算了。我现在是该用什么都不明白...所以搞清楚这个怎么用也没啥意义。也许这个东西就不是用在这里的。。。。
赵4老师 2016-11-08
  • 打赏
  • 举报
回复
我只是提醒你可以针对某个窗口的某条消息设置断点而已。
  • 打赏
  • 举报
回复
引用 2 楼 zhao4zhong1 的回复:
Setting a Breakpoint on a Message Received by a Windows Function You can set message breakpoints to stop the debugger when a particular WndProc function message is received. Note Message breakpoints work only on x86- or Pentium-based systems. To set a breakpoint on a message From the Edit menu, click Breakpoints. The Breakpoints dialog box appears. Click the Messages tab. In the Break At WndProc text box, type the name of the Windows function. If you are setting a breakpoint during a debug session, the list contains the exported functions in your project. In the Set One Breakpoint For Each Message To Watch list box, select the message. To set another breakpoint, press ENTER, and then repeat steps 3 and 4. The Breakpoints list displays the currently active breakpoints. Click OK to set the breakpoints. Note If you interrupt execution while Windows or other system code is running, the results can be unpredictable.
怎么说了?.断点就不用了...这个错误 我大概猜到一些,TreeView_GetItem(hwndTreeView, htItem);返货的是节点属性是一个结构,因为顶层节点没有父节点导致的......然后导致程序出错,所以这个完全不能这么用, 求大神指导个合适方法... 你搞这么多英文...我还是用翻译软件才明白...

64,318

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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